@appbaseio/reactivesearch-vue 1.25.0 → 1.27.0-gamma.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +1822 -512
  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/{CancelSvg-62d42af4.js → CancelSvg-4aa35935.js} +1 -14
  6. package/dist/cjs/{ComponentWrapper-32481890.js → ComponentWrapper-10bad289.js} +1 -1
  7. package/dist/cjs/DataSearch-37dfdf39.js +2154 -0
  8. package/dist/cjs/DataSearch.js +18 -2101
  9. package/dist/cjs/{DropDown-5847d6e4.js → DropDown-0076babc.js} +18 -13
  10. package/dist/cjs/DynamicRangeSlider.js +48 -12
  11. package/dist/cjs/{Input-3cc3fa59.js → Input-a9ee53ed.js} +1 -1
  12. package/dist/cjs/MultiDropdownList.js +10 -9
  13. package/dist/cjs/MultiList.js +19 -14
  14. package/dist/cjs/MultiRange.js +4 -4
  15. package/dist/cjs/RangeInput.js +10 -6
  16. package/dist/cjs/RangeSlider.js +19 -22
  17. package/dist/cjs/ReactiveBase.js +2 -2
  18. package/dist/cjs/ReactiveComponent.js +3 -3
  19. package/dist/cjs/ReactiveList.js +14 -4
  20. package/dist/cjs/ResultCard.js +1 -1
  21. package/dist/cjs/ResultList.js +1 -1
  22. package/dist/cjs/SelectedFilters.js +8 -6
  23. package/dist/cjs/SingleDropdownList.js +9 -8
  24. package/dist/cjs/SingleList.js +6 -6
  25. package/dist/cjs/SingleRange.js +4 -4
  26. package/dist/cjs/StateProvider.js +7 -3
  27. package/dist/cjs/ToggleButton.js +4 -4
  28. package/dist/cjs/{index-89c39a9e.js → index-4509aa45.js} +10 -4
  29. package/dist/cjs/index.js +14 -13
  30. package/dist/cjs/install-d95c7185.js +1204 -0
  31. package/dist/cjs/install.js +28 -33
  32. package/dist/cjs/ssr-0ee35a09.js +39 -0
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/cjs/{vueTypes-4c19b4c8.js → vueTypes-57d01f18.js} +3 -3
  35. package/dist/es/{CancelSvg-e0cace2d.js → CancelSvg-c2c03a35.js} +1 -14
  36. package/dist/es/{ComponentWrapper-4f85a67e.js → ComponentWrapper-0f3431d1.js} +1 -1
  37. package/dist/es/DataSearch-77325036.js +2141 -0
  38. package/dist/es/DataSearch.js +17 -2100
  39. package/dist/es/{DropDown-1ee01031.js → DropDown-0dd8f2a3.js} +18 -13
  40. package/dist/es/DynamicRangeSlider.js +48 -12
  41. package/dist/es/{Input-08bb1bcf.js → Input-10b1d62d.js} +1 -1
  42. package/dist/es/MultiDropdownList.js +10 -9
  43. package/dist/es/MultiList.js +19 -14
  44. package/dist/es/MultiRange.js +4 -4
  45. package/dist/es/RangeInput.js +10 -6
  46. package/dist/es/RangeSlider.js +19 -22
  47. package/dist/es/ReactiveBase.js +2 -2
  48. package/dist/es/ReactiveComponent.js +3 -3
  49. package/dist/es/ReactiveList.js +14 -4
  50. package/dist/es/ResultCard.js +1 -1
  51. package/dist/es/ResultList.js +1 -1
  52. package/dist/es/SelectedFilters.js +8 -6
  53. package/dist/es/SingleDropdownList.js +9 -8
  54. package/dist/es/SingleList.js +6 -6
  55. package/dist/es/SingleRange.js +4 -4
  56. package/dist/es/StateProvider.js +7 -3
  57. package/dist/es/ToggleButton.js +4 -4
  58. package/dist/es/{index-cb1950b6.js → index-78920565.js} +10 -4
  59. package/dist/es/index.js +10 -10
  60. package/dist/es/install-432674ef.js +1197 -0
  61. package/dist/es/install.js +26 -35
  62. package/dist/es/ssr-a41dfea9.js +33 -0
  63. package/dist/es/version.js +1 -1
  64. package/dist/es/{vueTypes-fb61bb7b.js → vueTypes-687b2304.js} +3 -3
  65. package/package.json +5 -5
  66. package/dist/cjs/ssr-08e95ede.js +0 -39
  67. package/dist/es/ssr-5d255b08.js +0 -33
@@ -0,0 +1,1204 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var configureStore = require('@appbaseio/reactivecore');
6
+ var configureStore__default = _interopDefault(configureStore);
7
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f127c8b7.js');
8
+ var VueTypes = _interopDefault(require('vue-types'));
9
+ var constants = require('@appbaseio/reactivecore/lib/utils/constants');
10
+ var helper = require('@appbaseio/reactivecore/lib/utils/helper');
11
+ var styled = require('@appbaseio/vue-emotion');
12
+ var styled__default = _interopDefault(styled);
13
+ var vueTypes = require('./vueTypes-57d01f18.js');
14
+ var ReactiveList = require('./ReactiveList.js');
15
+ var index = require('./index-4509aa45.js');
16
+ var ComponentWrapper = require('./ComponentWrapper-10bad289.js');
17
+ var Title = require('./Title-584a8cc8.js');
18
+ var ReactiveBase = require('./ReactiveBase.js');
19
+ var hotkeys = _interopDefault(require('hotkeys-js'));
20
+ var DataSearch = require('./DataSearch-37dfdf39.js');
21
+ var CancelSvg = require('./CancelSvg-4aa35935.js');
22
+ var Input = require('./Input-a9ee53ed.js');
23
+ var Container = require('./Container-526efa6a.js');
24
+ var SingleList = require('./SingleList.js');
25
+ var MultiList = require('./MultiList.js');
26
+ var SingleDropdownList = require('./SingleDropdownList.js');
27
+ var MultiDropdownList = require('./MultiDropdownList.js');
28
+ var ToggleButton = require('./ToggleButton.js');
29
+ var ReactiveComponent = require('./ReactiveComponent.js');
30
+ var SelectedFilters = require('./SelectedFilters.js');
31
+ var SingleRange = require('./SingleRange.js');
32
+ var MultiRange = require('./MultiRange.js');
33
+ var ResultCard = require('./ResultCard.js');
34
+ var ResultList = require('./ResultList.js');
35
+ var RangeSlider = require('./RangeSlider.js');
36
+ var DynamicRangeSlider = require('./DynamicRangeSlider.js');
37
+ var StateProvider = require('./StateProvider.js');
38
+ var RangeInput = require('./RangeInput.js');
39
+
40
+ var _templateObject;
41
+ var AutofillSvgIcon = styled__default('button')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tmargin-left: auto;\n\tposition: relative;\n\tright: -3px;\n\tborder: none;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0;\n\tz-index: 111000;\n\n\tsvg {\n\t\tcursor: pointer;\n\t\tfill: #707070;\n\t\theight: 20px;\n\t}\n\n\t&:hover {\n\t\tsvg {\n\t\t\tfill: #1c1a1a;\n\t\t}\n\t}\n"])));
42
+ var AutoFillSvg = {
43
+ name: 'AutoFillSvg',
44
+ render: function render() {
45
+ var h = arguments[0];
46
+ return h(AutofillSvgIcon, {
47
+ "on": {
48
+ "click": this.$listeners.click
49
+ }
50
+ }, [h("svg", {
51
+ "attrs": {
52
+ "viewBox": "0 0 24 24"
53
+ }
54
+ }, [h("path", {
55
+ "attrs": {
56
+ "d": "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
57
+ }
58
+ })])]);
59
+ },
60
+ methods: {
61
+ clicked: function clicked(e) {
62
+ e.stopPropagation();
63
+ window.console.log('hey', e);
64
+ }
65
+ }
66
+ };
67
+
68
+ var updateQuery = configureStore.Actions.updateQuery,
69
+ setCustomQuery = configureStore.Actions.setCustomQuery,
70
+ setDefaultQuery = configureStore.Actions.setDefaultQuery,
71
+ recordSuggestionClick = configureStore.Actions.recordSuggestionClick;
72
+ var _debounce = configureStore.helper.debounce,
73
+ checkValueChange = configureStore.helper.checkValueChange,
74
+ getClassName = configureStore.helper.getClassName,
75
+ isEqual = configureStore.helper.isEqual,
76
+ getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery,
77
+ withClickIds = configureStore.helper.withClickIds,
78
+ getResultStats = configureStore.helper.getResultStats,
79
+ normalizeDataField = configureStore.helper.normalizeDataField;
80
+ var SearchBox = {
81
+ name: 'SearchBox',
82
+ data: function data() {
83
+ var props = this.$props;
84
+ this.__state = {
85
+ currentValue: '',
86
+ isOpen: false,
87
+ normalizedSuggestions: []
88
+ };
89
+ this.internalComponent = props.componentId + "__internal";
90
+ return this.__state;
91
+ },
92
+ inject: {
93
+ theme: {
94
+ from: 'theme_reactivesearch'
95
+ }
96
+ },
97
+ created: function created() {
98
+ var _this$$props = this.$props,
99
+ distinctField = _this$$props.distinctField,
100
+ distinctFieldConfig = _this$$props.distinctFieldConfig,
101
+ index = _this$$props.index;
102
+
103
+ if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
104
+ console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
105
+ }
106
+
107
+ if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
108
+ console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
109
+ }
110
+
111
+ if (!this.enableAppbase && index) {
112
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
113
+ }
114
+
115
+ this.currentValue = this.selectedValue || this.value || this.defaultValue || '';
116
+ this.handleTextChange = _debounce(this.handleText, this.$props.debounce);
117
+ this.setValue(this.currentValue, true, this.$props, undefined, false, this.selectedCategory); // Set custom and default queries in store
118
+
119
+ this.triggerCustomQuery(this.currentValue, this.selectedCategory);
120
+ this.triggerDefaultQuery(this.currentValue);
121
+ },
122
+ computed: {
123
+ hasCustomRenderer: function hasCustomRenderer() {
124
+ return index.hasCustomRenderer(this);
125
+ },
126
+ stats: function stats() {
127
+ return getResultStats(this);
128
+ }
129
+ },
130
+ props: {
131
+ autoFocus: VueTypes.bool,
132
+ autosuggest: VueTypes.bool.def(true),
133
+ beforeValueChange: vueTypes.types.func,
134
+ className: VueTypes.string.def(''),
135
+ clearIcon: vueTypes.types.children,
136
+ componentId: vueTypes.types.stringRequired,
137
+ customHighlight: vueTypes.types.func,
138
+ customQuery: vueTypes.types.func,
139
+ defaultQuery: vueTypes.types.func,
140
+ dataField: VueTypes.oneOfType([VueTypes.string, VueTypes.shape({
141
+ field: VueTypes.string,
142
+ weight: VueTypes.number
143
+ }), VueTypes.arrayOf(VueTypes.string), VueTypes.arrayOf({
144
+ field: VueTypes.string,
145
+ weight: VueTypes.number
146
+ })]),
147
+ aggregationField: vueTypes.types.string,
148
+ aggregationSize: VueTypes.number,
149
+ size: VueTypes.number,
150
+ debounce: VueTypes.number.def(0),
151
+ defaultValue: vueTypes.types.string,
152
+ excludeFields: vueTypes.types.excludeFields,
153
+ value: vueTypes.types.value,
154
+ defaultSuggestions: vueTypes.types.suggestions,
155
+ enableSynonyms: VueTypes.bool.def(true),
156
+ enableQuerySuggestions: VueTypes.bool.def(false),
157
+ enablePopularSuggestions: VueTypes.bool.def(false),
158
+ enableRecentSuggestions: VueTypes.bool.def(false),
159
+ fieldWeights: vueTypes.types.fieldWeights,
160
+ filterLabel: vueTypes.types.string,
161
+ fuzziness: vueTypes.types.fuzziness,
162
+ highlight: VueTypes.bool,
163
+ highlightField: vueTypes.types.stringOrArray,
164
+ icon: vueTypes.types.children,
165
+ iconPosition: VueTypes.oneOf(['left', 'right']).def('left'),
166
+ includeFields: vueTypes.types.includeFields,
167
+ innerClass: vueTypes.types.style,
168
+ innerRef: VueTypes.string.def('searchInputField'),
169
+ render: vueTypes.types.func,
170
+ renderNoSuggestion: vueTypes.types.title,
171
+ renderError: vueTypes.types.title,
172
+ placeholder: VueTypes.string.def('Search'),
173
+ queryFormat: VueTypes.oneOf(['and', 'or']).def('or'),
174
+ react: vueTypes.types.react,
175
+ showClear: VueTypes.bool.def(true),
176
+ showDistinctSuggestions: VueTypes.bool.def(true),
177
+ showFilter: VueTypes.bool.def(true),
178
+ showIcon: VueTypes.bool.def(true),
179
+ title: vueTypes.types.title,
180
+ theme: vueTypes.types.style,
181
+ URLParams: VueTypes.bool.def(false),
182
+ strictSelection: VueTypes.bool.def(false),
183
+ nestedField: vueTypes.types.string,
184
+ enablePredictiveSuggestions: VueTypes.bool.def(false),
185
+ recentSearchesIcon: VueTypes.any,
186
+ popularSearchesIcon: VueTypes.any,
187
+ // mic props
188
+ showVoiceSearch: VueTypes.bool.def(false),
189
+ getMicInstance: vueTypes.types.func,
190
+ renderMic: vueTypes.types.func,
191
+ distinctField: vueTypes.types.string,
192
+ distinctFieldConfig: vueTypes.types.props,
193
+ //
194
+ focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])).def(['/']),
195
+ addonBefore: VueTypes.any,
196
+ addonAfter: VueTypes.any,
197
+ expandSuggestionsContainer: VueTypes.bool.def(true),
198
+ index: VueTypes.string,
199
+ popularSuggestionsConfig: VueTypes.object,
200
+ recentSuggestionsConfig: VueTypes.object,
201
+ applyStopwords: VueTypes.bool,
202
+ customStopwords: vueTypes.types.stringArray,
203
+ onData: vueTypes.types.func,
204
+ renderItem: vueTypes.types.func
205
+ },
206
+ mounted: function mounted() {
207
+ this.listenForFocusShortcuts();
208
+ },
209
+ watch: {
210
+ dataField: function dataField(newVal, oldVal) {
211
+ if (!isEqual(newVal, oldVal)) {
212
+ this.triggerCustomQuery(this.$data.currentValue);
213
+ }
214
+ },
215
+ fieldWeights: function fieldWeights() {
216
+ this.triggerCustomQuery(this.$data.currentValue);
217
+ },
218
+ fuzziness: function fuzziness() {
219
+ this.triggerCustomQuery(this.$data.currentValue);
220
+ },
221
+ queryFormat: function queryFormat() {
222
+ this.triggerCustomQuery(this.$data.currentValue);
223
+ },
224
+ defaultValue: function defaultValue(newVal) {
225
+ this.setValue(newVal, true, this.$props);
226
+ },
227
+ value: function value(newVal, oldVal) {
228
+ if (!isEqual(newVal, oldVal)) {
229
+ this.setValue(newVal, true, this.$props, newVal === '' ? configureStore.causes.CLEAR_VALUE : undefined, false);
230
+ }
231
+ },
232
+ defaultQuery: function defaultQuery(newVal, oldVal) {
233
+ if (!index.isQueryIdentical(newVal, oldVal, this.$data.currentValue, this.$props)) {
234
+ this.triggerDefaultQuery(this.$data.currentValue);
235
+ }
236
+ },
237
+ customQuery: function customQuery(newVal, oldVal) {
238
+ if (!index.isQueryIdentical(newVal, oldVal, this.$data.currentValue, this.$props)) {
239
+ this.triggerCustomQuery(this.$data.currentValue);
240
+ }
241
+ },
242
+ suggestions: function suggestions(newVal) {
243
+ var suggestionsList = [];
244
+
245
+ if (Array.isArray(newVal) && newVal.length) {
246
+ suggestionsList = [].concat(withClickIds(newVal));
247
+ } else if (Array.isArray(this.$props.defaultSuggestions) && this.$props.defaultSuggestions.length) {
248
+ suggestionsList = [].concat(withClickIds(this.$props.defaultSuggestions));
249
+ }
250
+
251
+ this.normalizedSuggestions = suggestionsList;
252
+ },
253
+ selectedValue: function selectedValue(newVal, oldVal) {
254
+ if (oldVal !== newVal && this.$data.currentValue !== newVal) {
255
+ if (!newVal && this.$data.currentValue) {
256
+ // selected value is cleared, call onValueSelected
257
+ this.onValueSelectedHandler('', configureStore.causes.CLEAR_VALUE);
258
+ }
259
+
260
+ if (this.$props.value === undefined) {
261
+ this.setValue(newVal || '', true, this.$props);
262
+ }
263
+ }
264
+ },
265
+ focusShortcuts: function focusShortcuts() {
266
+ this.listenForFocusShortcuts();
267
+ },
268
+ rawData: function rawData(newVal) {
269
+ this.$emit('on-data', {
270
+ data: this.normalizedSuggestions,
271
+ rawData: newVal,
272
+ aggregationData: this.aggregationData,
273
+ loading: this.isLoading,
274
+ error: this.isError
275
+ });
276
+ },
277
+ aggregationData: function aggregationData(newVal) {
278
+ this.$emit('on-data', {
279
+ data: this.normalizedSuggestions,
280
+ rawData: this.rawData,
281
+ aggregationData: newVal,
282
+ loading: this.isLoading,
283
+ error: this.isError
284
+ });
285
+ },
286
+ loading: function loading(newVal) {
287
+ this.$emit('on-data', {
288
+ data: this.normalizedSuggestions,
289
+ rawData: this.rawData,
290
+ aggregationData: this.aggregationData,
291
+ loading: newVal,
292
+ error: this.isError
293
+ });
294
+ },
295
+ error: function error(newVal) {
296
+ this.$emit('on-data', {
297
+ data: this.normalizedSuggestions,
298
+ rawData: this.rawData,
299
+ aggregationData: this.aggregationData,
300
+ loading: this.isLoading,
301
+ error: newVal
302
+ });
303
+ },
304
+ debounce: function debounce(newVal, oldVal) {
305
+ if (!isEqual(newVal, oldVal)) {
306
+ this.handleTextChange = _debounce(this.handleText, newVal);
307
+ }
308
+ }
309
+ },
310
+ methods: {
311
+ handleText: function handleText(value, cause) {
312
+ if (cause === configureStore.causes.CLEAR_VALUE) {
313
+ this.triggerCustomQuery(value);
314
+ this.triggerDefaultQuery(value);
315
+ } else if (this.$props.autosuggest) {
316
+ this.triggerDefaultQuery(value);
317
+ } else {
318
+ this.triggerCustomQuery(value);
319
+ }
320
+ },
321
+ validateDataField: function validateDataField() {
322
+ var propName = 'dataField';
323
+ var componentName = SearchBox.name;
324
+ var props = this.$props;
325
+ var requiredError = propName + " supplied to " + componentName + " is required. Validation failed.";
326
+ var propValue = props[propName];
327
+
328
+ if (!this.enableAppbase) {
329
+ if (!propValue) {
330
+ console.error(requiredError);
331
+ return;
332
+ }
333
+
334
+ if (typeof propValue !== 'string' && typeof propValue !== 'object' && !Array.isArray(propValue)) {
335
+ console.error("Invalid " + propName + " supplied to " + componentName + ". Validation failed.");
336
+ return;
337
+ }
338
+
339
+ if (Array.isArray(propValue) && propValue.length === 0) {
340
+ console.error(requiredError);
341
+ }
342
+ }
343
+ },
344
+ getComponent: function getComponent(downshiftProps) {
345
+ if (downshiftProps === void 0) {
346
+ downshiftProps = {};
347
+ }
348
+
349
+ var currentValue = this.$data.currentValue;
350
+ var data = {
351
+ error: this.error,
352
+ loading: this.isLoading,
353
+ downshiftProps: downshiftProps,
354
+ data: this.normalizedSuggestions,
355
+ rawData: this.rawData,
356
+ value: currentValue,
357
+ resultStats: this.stats
358
+ };
359
+ return index.getComponent(data, this);
360
+ },
361
+ // returns size and aggs property
362
+ getBasicQueryOptions: function getBasicQueryOptions() {
363
+ var aggregationField = this.$props.aggregationField;
364
+ var queryOptions = helper.getQueryOptions(this.$props);
365
+
366
+ if (aggregationField) {
367
+ queryOptions.aggs = getCompositeAggsQuery({
368
+ props: this.$props,
369
+ showTopHits: true
370
+ }).aggs;
371
+ }
372
+
373
+ return queryOptions;
374
+ },
375
+ handleSearchIconClick: function handleSearchIconClick() {
376
+ var currentValue = this.currentValue;
377
+
378
+ if (currentValue.trim()) {
379
+ this.setValue(currentValue, true);
380
+ this.onValueSelectedHandler(currentValue, configureStore.causes.SEARCH_ICON_CLICK);
381
+ }
382
+ },
383
+ setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
384
+ var _this = this;
385
+
386
+ if (isDefaultValue === void 0) {
387
+ isDefaultValue = false;
388
+ }
389
+
390
+ if (props === void 0) {
391
+ props = this.$props;
392
+ }
393
+
394
+ if (toggleIsOpen === void 0) {
395
+ toggleIsOpen = true;
396
+ }
397
+
398
+ if (categoryValue === void 0) {
399
+ categoryValue = undefined;
400
+ }
401
+
402
+ var performUpdate = function performUpdate() {
403
+ _this.currentValue = value;
404
+
405
+ if (isDefaultValue) {
406
+ if (_this.$props.autosuggest) {
407
+ if (toggleIsOpen) {
408
+ _this.isOpen = false;
409
+ }
410
+
411
+ _this.triggerDefaultQuery(value);
412
+ } // in case of strict selection only SUGGESTION_SELECT should be able
413
+ // to set the query otherwise the value should reset
414
+
415
+
416
+ if (props.strictSelection) {
417
+ if (cause === configureStore.causes.SUGGESTION_SELECT || value === '') {
418
+ _this.triggerCustomQuery(value, categoryValue);
419
+ } else {
420
+ _this.setValue('', true);
421
+ }
422
+ } else if (props.value === undefined) {
423
+ _this.triggerCustomQuery(value, categoryValue);
424
+ }
425
+ } else {
426
+ // debounce for handling text while typing
427
+ _this.handleTextChange(value, cause);
428
+ }
429
+
430
+ _this.$emit('valueChange', value);
431
+
432
+ _this.$emit('value-change', value);
433
+ };
434
+
435
+ checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
436
+ },
437
+ triggerDefaultQuery: function triggerDefaultQuery(paramValue) {
438
+ if (!this.$props.autosuggest) {
439
+ return;
440
+ }
441
+
442
+ var value = typeof paramValue !== 'string' ? this.currentValue : paramValue;
443
+ var query = SearchBox.defaultQuery(value, this.$props);
444
+
445
+ if (this.defaultQuery) {
446
+ var defaultQueryToBeSet = this.defaultQuery(value, this.$props) || {};
447
+
448
+ if (defaultQueryToBeSet.query) {
449
+ query = defaultQueryToBeSet.query;
450
+ } // Update calculated default query in store
451
+
452
+
453
+ index.updateDefaultQuery(this.$props.componentId, this.setDefaultQuery, this.$props, value);
454
+ }
455
+
456
+ this.updateQuery({
457
+ componentId: this.internalComponent,
458
+ query: query,
459
+ value: value,
460
+ componentType: constants.componentTypes.searchBox
461
+ });
462
+ },
463
+ triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
464
+ if (categoryValue === void 0) {
465
+ categoryValue = undefined;
466
+ }
467
+
468
+ var _this$$props2 = this.$props,
469
+ customQuery = _this$$props2.customQuery,
470
+ filterLabel = _this$$props2.filterLabel,
471
+ showFilter = _this$$props2.showFilter,
472
+ URLParams = _this$$props2.URLParams;
473
+ var value = typeof paramValue !== 'string' ? this.$data.currentValue : paramValue;
474
+ var defaultQueryTobeSet = SearchBox.defaultQuery("" + value + (categoryValue ? " in " + categoryValue : ''), this.$props);
475
+ var query = defaultQueryTobeSet;
476
+
477
+ if (customQuery) {
478
+ var customQueryTobeSet = customQuery(value, this.$props);
479
+ var queryTobeSet = customQueryTobeSet.query;
480
+
481
+ if (queryTobeSet) {
482
+ query = queryTobeSet;
483
+ }
484
+
485
+ index.updateCustomQuery(this.$props.componentId, this.setCustomQuery, this.$props, value);
486
+ }
487
+
488
+ this.updateQuery({
489
+ componentId: this.$props.componentId,
490
+ query: query,
491
+ value: value,
492
+ label: filterLabel,
493
+ showFilter: showFilter,
494
+ URLParams: URLParams,
495
+ componentType: constants.componentTypes.searchBox,
496
+ category: categoryValue
497
+ });
498
+ },
499
+ handleFocus: function handleFocus(event) {
500
+ if (this.$props.autosuggest) {
501
+ this.isOpen = true;
502
+ }
503
+
504
+ this.$emit('focus', event);
505
+ },
506
+ handleVoiceResults: function handleVoiceResults(_ref) {
507
+ var results = _ref.results;
508
+
509
+ if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
510
+ this.setValue(results[0][0].transcript.trim(), true);
511
+ }
512
+ },
513
+ triggerQuery: function triggerQuery(_ref2) {
514
+ var _ref2$isOpen = _ref2.isOpen,
515
+ isOpen = _ref2$isOpen === void 0 ? undefined : _ref2$isOpen,
516
+ _ref2$customQuery = _ref2.customQuery,
517
+ customQuery = _ref2$customQuery === void 0 ? true : _ref2$customQuery,
518
+ _ref2$defaultQuery = _ref2.defaultQuery,
519
+ defaultQuery = _ref2$defaultQuery === void 0 ? true : _ref2$defaultQuery,
520
+ _ref2$value = _ref2.value,
521
+ value = _ref2$value === void 0 ? undefined : _ref2$value,
522
+ _ref2$categoryValue = _ref2.categoryValue,
523
+ categoryValue = _ref2$categoryValue === void 0 ? undefined : _ref2$categoryValue;
524
+
525
+ if (typeof isOpen === 'boolean') {
526
+ this.isOpen = isOpen;
527
+ }
528
+
529
+ if (customQuery) {
530
+ this.triggerCustomQuery(value, categoryValue);
531
+ }
532
+
533
+ if (defaultQuery) {
534
+ this.triggerDefaultQuery(value);
535
+ }
536
+ },
537
+ triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
538
+ // click analytics would only work client side and after javascript loads
539
+ var docId = documentId;
540
+
541
+ if (!docId) {
542
+ var hitData = this.normalizedSuggestions.find(function (hit) {
543
+ return hit._click_id === searchPosition;
544
+ });
545
+
546
+ if (hitData && hitData.source && hitData.source._id) {
547
+ docId = hitData.source._id;
548
+ }
549
+ }
550
+
551
+ this.recordSuggestionClick(searchPosition, docId);
552
+ },
553
+ clearValue: function clearValue() {
554
+ this.setValue('', false, this.$props, configureStore.causes.CLEAR_VALUE, false);
555
+ this.onValueSelectedHandler('', configureStore.causes.CLEAR_VALUE);
556
+ },
557
+ handleKeyDown: function handleKeyDown(event, highlightedIndex) {
558
+ // if a suggestion was selected, delegate the handling to suggestion handler
559
+ if (event.key === 'Enter' && highlightedIndex === null) {
560
+ this.setValue(event.target.value, true);
561
+ this.onValueSelectedHandler(event.target.value, configureStore.causes.ENTER_PRESS);
562
+ } // Need to review
563
+
564
+
565
+ this.$emit('keyDown', event, this.triggerQuery);
566
+ this.$emit('key-down', event, this.triggerQuery);
567
+ },
568
+ onInputChange: function onInputChange(e) {
569
+ var _this2 = this;
570
+
571
+ var inputValue = e.target.value;
572
+
573
+ if (!this.$data.isOpen && this.$props.autosuggest) {
574
+ this.isOpen = true;
575
+ }
576
+
577
+ var value = this.$props.value;
578
+
579
+ if (value === undefined) {
580
+ this.setValue(inputValue, false, this.$props, inputValue === '' ? configureStore.causes.CLEAR_VALUE : undefined);
581
+ } else {
582
+ this.$emit('change', inputValue, function (_ref3) {
583
+ var isOpen = _ref3.isOpen;
584
+ return _this2.triggerQuery({
585
+ defaultQuery: true,
586
+ customQuery: true,
587
+ value: inputValue,
588
+ isOpen: isOpen
589
+ });
590
+ }, e);
591
+ }
592
+ },
593
+ onSuggestionSelected: function onSuggestionSelected(suggestion) {
594
+ var _this3 = this;
595
+
596
+ this.isOpen = false;
597
+ var value = this.$props.value; // Record analytics for selected suggestions
598
+
599
+ this.triggerClickAnalytics(suggestion._click_id);
600
+
601
+ if (value === undefined) {
602
+ this.setValue(suggestion.value, true, this.$props, configureStore.causes.SUGGESTION_SELECT, false, suggestion._category);
603
+ } else {
604
+ this.$emit('change', suggestion.value, function (_ref4) {
605
+ var isOpen = _ref4.isOpen;
606
+ return _this3.triggerQuery({
607
+ isOpen: isOpen,
608
+ value: suggestion.value,
609
+ categoryValue: suggestion._category
610
+ });
611
+ });
612
+ }
613
+
614
+ this.onValueSelectedHandler(suggestion.value, configureStore.causes.SUGGESTION_SELECT, suggestion.source);
615
+ },
616
+ onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
617
+ if (currentValue === void 0) {
618
+ currentValue = this.$data.currentValue;
619
+ }
620
+
621
+ for (var _len = arguments.length, cause = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
622
+ cause[_key - 1] = arguments[_key];
623
+ }
624
+
625
+ this.$emit.apply(this, ['valueSelected', currentValue].concat(cause));
626
+ this.$emit.apply(this, ['value-selected', currentValue].concat(cause));
627
+ },
628
+ handleStateChange: function handleStateChange(changes) {
629
+ var isOpen = changes.isOpen;
630
+ this.isOpen = isOpen;
631
+ },
632
+ getBackgroundColor: function getBackgroundColor(highlightedIndex, index) {
633
+ var isDark = this.themePreset === 'dark';
634
+
635
+ if (isDark) {
636
+ return highlightedIndex === index ? '#555' : '#424242';
637
+ }
638
+
639
+ return highlightedIndex === index ? '#eee' : '#fff';
640
+ },
641
+ renderIcon: function renderIcon() {
642
+ var h = this.$createElement;
643
+
644
+ if (this.$props.showIcon) {
645
+ return this.$props.icon || h(DataSearch.SearchSvg);
646
+ }
647
+
648
+ return null;
649
+ },
650
+ renderErrorComponent: function renderErrorComponent() {
651
+ var h = this.$createElement;
652
+ var renderError = this.$scopedSlots.renderError || this.$props.renderError;
653
+
654
+ if (this.error && renderError && this.$data.currentValue && !this.isLoading) {
655
+ return h(DataSearch.SuggestionWrapper, {
656
+ "attrs": {
657
+ "innerClass": this.$props.innerClass,
658
+ "innerClassName": "error",
659
+ "theme": this.theme,
660
+ "themePreset": this.themePreset
661
+ }
662
+ }, [index.isFunction(renderError) ? renderError(this.error) : renderError]);
663
+ }
664
+
665
+ return null;
666
+ },
667
+ renderCancelIcon: function renderCancelIcon() {
668
+ var h = this.$createElement;
669
+
670
+ if (this.$props.showClear) {
671
+ return this.$props.clearIcon || h(CancelSvg.CancelSvg);
672
+ }
673
+
674
+ return null;
675
+ },
676
+ renderNoSuggestions: function renderNoSuggestions(finalSuggestionsList) {
677
+ if (finalSuggestionsList === void 0) {
678
+ finalSuggestionsList = [];
679
+ }
680
+
681
+ var h = this.$createElement;
682
+ var _this$$props3 = this.$props,
683
+ theme = _this$$props3.theme,
684
+ innerClass = _this$$props3.innerClass;
685
+ var renderNoSuggestion = this.$scopedSlots.renderNoSuggestion || this.$props.renderNoSuggestion;
686
+ var renderError = this.$scopedSlots.renderError || this.$props.renderError;
687
+ var _this$$data = this.$data,
688
+ isOpen = _this$$data.isOpen,
689
+ currentValue = _this$$data.currentValue;
690
+
691
+ if (renderNoSuggestion && isOpen && !finalSuggestionsList.length && !this.isLoading && currentValue && !(renderError && this.error)) {
692
+ return h(DataSearch.SuggestionWrapper, {
693
+ "attrs": {
694
+ "innerClass": innerClass,
695
+ "themePreset": this.themePreset,
696
+ "theme": theme,
697
+ "innerClassName": "noSuggestion"
698
+ },
699
+ "scopedSlots": {
700
+ "default": function _default() {
701
+ return typeof renderNoSuggestion === 'function' ? renderNoSuggestion(currentValue) : renderNoSuggestion;
702
+ }
703
+ }
704
+ });
705
+ }
706
+
707
+ return null;
708
+ },
709
+ renderInputAddonBefore: function renderInputAddonBefore() {
710
+ var h = this.$createElement;
711
+ var addonBefore = this.$scopedSlots.addonBefore;
712
+
713
+ if (addonBefore) {
714
+ return h(DataSearch.InputAddon, {
715
+ "attrs": {
716
+ "className": "addon-before"
717
+ }
718
+ }, [addonBefore()]);
719
+ }
720
+
721
+ return null;
722
+ },
723
+ renderInputAddonAfter: function renderInputAddonAfter() {
724
+ var h = this.$createElement;
725
+ var addonAfter = this.$scopedSlots.addonAfter;
726
+
727
+ if (addonAfter) {
728
+ return h(DataSearch.InputAddon, {
729
+ "attrs": {
730
+ "className": "addon-after"
731
+ }
732
+ }, [addonAfter()]);
733
+ }
734
+
735
+ return null;
736
+ },
737
+ renderIcons: function renderIcons() {
738
+ var h = this.$createElement;
739
+ var _this$$props4 = this.$props,
740
+ iconPosition = _this$$props4.iconPosition,
741
+ showClear = _this$$props4.showClear,
742
+ innerClass = _this$$props4.innerClass,
743
+ getMicInstance = _this$$props4.getMicInstance,
744
+ showVoiceSearch = _this$$props4.showVoiceSearch,
745
+ showIcon = _this$$props4.showIcon;
746
+ var renderMic = this.$scopedSlots.renderMic || this.$props.renderMic;
747
+ var currentValue = this.$data.currentValue;
748
+ return h("div", [h(CancelSvg.IconGroup, {
749
+ "attrs": {
750
+ "groupPosition": "right",
751
+ "positionType": "absolute"
752
+ }
753
+ }, [currentValue && showClear && h(CancelSvg.IconWrapper, {
754
+ "on": {
755
+ "click": this.clearValue
756
+ },
757
+ "attrs": {
758
+ "showIcon": showIcon,
759
+ "isClearIcon": true
760
+ }
761
+ }, [this.renderCancelIcon()]), showVoiceSearch && h(DataSearch.Mic, {
762
+ "attrs": {
763
+ "getInstance": getMicInstance,
764
+ "render": renderMic,
765
+ "handleResult": this.handleVoiceResults,
766
+ "className": getClassName(innerClass, 'mic') || null
767
+ }
768
+ }), iconPosition === 'right' && showIcon && h(CancelSvg.IconWrapper, {
769
+ "on": {
770
+ "click": this.handleSearchIconClick
771
+ }
772
+ }, [this.renderIcon()])]), h(CancelSvg.IconGroup, {
773
+ "attrs": {
774
+ "groupPosition": "left",
775
+ "positionType": "absolute"
776
+ }
777
+ }, [iconPosition === 'left' && showIcon && h(CancelSvg.IconWrapper, {
778
+ "on": {
779
+ "click": this.handleSearchIconClick
780
+ }
781
+ }, [this.renderIcon()])])]);
782
+ },
783
+ focusSearchBox: function focusSearchBox(event) {
784
+ var _this$$refs, _this$$refs$this$$pro;
785
+
786
+ var elt = event.target || event.srcElement;
787
+ var tagName = elt.tagName;
788
+
789
+ if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
790
+ // already in an input
791
+ return;
792
+ }
793
+
794
+ (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$this$$pro = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs$this$$pro.focus(); // eslint-disable-line
795
+ },
796
+ listenForFocusShortcuts: function listenForFocusShortcuts() {
797
+ var _this4 = this;
798
+
799
+ var _this$$props$focusSho = this.$props.focusShortcuts,
800
+ focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
801
+
802
+ if (index.isEmpty(focusShortcuts)) {
803
+ return;
804
+ }
805
+
806
+ var shortcutsString = index.parseFocusShortcuts(focusShortcuts).join(','); // handler for alphabets and other key combinations
807
+
808
+ hotkeys(shortcutsString, // eslint-disable-next-line no-unused-vars
809
+
810
+ /* eslint-disable no-shadow */
811
+ function (event, handler) {
812
+ // Prevent the default refresh event under WINDOWS system
813
+ event.preventDefault();
814
+
815
+ _this4.focusSearchBox(event);
816
+ }); // if one of modifier keys are used, they are handled below
817
+
818
+ hotkeys('*', function (event) {
819
+ var modifierKeys = index.extractModifierKeysFromFocusShortcuts(focusShortcuts);
820
+ if (modifierKeys.length === 0) return;
821
+
822
+ for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
823
+ var element = modifierKeys[index$1];
824
+
825
+ if (hotkeys[element]) {
826
+ _this4.focusSearchBox(event);
827
+
828
+ break;
829
+ }
830
+ }
831
+ });
832
+ },
833
+ onAutofillClick: function onAutofillClick(suggestion) {
834
+ var value = suggestion.value;
835
+ this.isOpen = true;
836
+ this.currentValue = value;
837
+ this.triggerDefaultQuery(value);
838
+ },
839
+ renderAutoFill: function renderAutoFill(suggestion) {
840
+ var _this5 = this;
841
+
842
+ var h = this.$createElement;
843
+
844
+ var handleAutoFillClick = function handleAutoFillClick(e) {
845
+ e.stopPropagation();
846
+
847
+ _this5.onAutofillClick(suggestion);
848
+ };
849
+ /* 👇 avoid showing autofill for category suggestions👇 */
850
+
851
+
852
+ return suggestion._category ? null : h(AutoFillSvg, {
853
+ "on": {
854
+ "click": handleAutoFillClick
855
+ }
856
+ });
857
+ }
858
+ },
859
+ render: function render() {
860
+ var _this6 = this;
861
+
862
+ var h = arguments[0];
863
+ var _this$$props5 = this.$props,
864
+ theme = _this$$props5.theme,
865
+ expandSuggestionsContainer = _this$$props5.expandSuggestionsContainer;
866
+ var _this$$scopedSlots = this.$scopedSlots,
867
+ recentSearchesIcon = _this$$scopedSlots.recentSearchesIcon,
868
+ popularSearchesIcon = _this$$scopedSlots.popularSearchesIcon;
869
+ var hasSuggestions = Array.isArray(this.normalizedSuggestions) && this.normalizedSuggestions.length;
870
+ var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
871
+ return h(Container.Container, {
872
+ "class": this.$props.className
873
+ }, [this.$props.title && h(Title.Title, {
874
+ "class": getClassName(this.$props.innerClass, 'title') || ''
875
+ }, [this.$props.title]), this.$props.autosuggest ? h(CancelSvg.Downshift, {
876
+ "attrs": {
877
+ "id": this.$props.componentId + "-downshift",
878
+ "handleChange": this.onSuggestionSelected,
879
+ "handleMouseup": this.handleStateChange,
880
+ "isOpen": this.$data.isOpen
881
+ },
882
+ "scopedSlots": {
883
+ "default": function _default(_ref5) {
884
+ var getInputEvents = _ref5.getInputEvents,
885
+ getInputProps = _ref5.getInputProps,
886
+ getItemProps = _ref5.getItemProps,
887
+ getItemEvents = _ref5.getItemEvents,
888
+ isOpen = _ref5.isOpen,
889
+ highlightedIndex = _ref5.highlightedIndex,
890
+ setHighlightedIndex = _ref5.setHighlightedIndex;
891
+
892
+ var renderSuggestionsDropdown = function renderSuggestionsDropdown() {
893
+ var getIcon = function getIcon(iconType) {
894
+ switch (iconType) {
895
+ case helper.suggestionTypes.Recent:
896
+ return recentSearchesIcon;
897
+
898
+ case helper.suggestionTypes.Popular:
899
+ return popularSearchesIcon;
900
+
901
+ default:
902
+ return null;
903
+ }
904
+ };
905
+
906
+ return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
907
+ isOpen: isOpen,
908
+ getItemProps: getItemProps,
909
+ getItemEvents: getItemEvents,
910
+ highlightedIndex: highlightedIndex
911
+ }), _this6.renderErrorComponent(), !_this6.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
912
+ "class": Input.suggestions(_this6.themePreset, theme) + " " + getClassName(_this6.$props.innerClass, 'list')
913
+ }, [_this6.normalizedSuggestions.map(function (item, index) {
914
+ return renderItem ? h("li", {
915
+ "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
916
+ item: item
917
+ })),
918
+ "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
919
+ item: item
920
+ })),
921
+ "key": index + 1 + "-" + item.value,
922
+ "style": {
923
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index),
924
+ justifyContent: 'flex-start',
925
+ alignItems: 'center'
926
+ }
927
+ }, [renderItem(item)]) : h("li", {
928
+ "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
929
+ item: item
930
+ })),
931
+ "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
932
+ item: item
933
+ })),
934
+ "key": index + 1 + "-" + item.value,
935
+ "style": {
936
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index),
937
+ justifyContent: 'flex-start',
938
+ alignItems: 'center'
939
+ }
940
+ }, [h("div", {
941
+ "style": {
942
+ padding: '0 10px 0 0',
943
+ display: 'flex'
944
+ }
945
+ }, [h(DataSearch.CustomSvg, {
946
+ "attrs": {
947
+ "className": getClassName(_this6.$props.innerClass, item._suggestion_type + "-search-icon") || null,
948
+ "icon": getIcon(item._suggestion_type),
949
+ "type": item._suggestion_type + "-search-icon"
950
+ }
951
+ })]), h(DataSearch.SuggestionItem, {
952
+ "attrs": {
953
+ "currentValue": _this6.currentValue,
954
+ "suggestion": item
955
+ }
956
+ }), _this6.renderAutoFill(item)]);
957
+ })]) : _this6.renderNoSuggestions(_this6.normalizedSuggestions)]);
958
+ };
959
+
960
+ return h("div", {
961
+ "class": Input.suggestionsContainer
962
+ }, [h(DataSearch.InputGroup, [_this6.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
963
+ "attrs": {
964
+ "id": _this6.$props.componentId + "-input",
965
+ "showIcon": _this6.$props.showIcon,
966
+ "showClear": _this6.$props.showClear,
967
+ "iconPosition": _this6.$props.iconPosition,
968
+ "placeholder": _this6.$props.placeholder,
969
+ "autoFocus": _this6.$props.autoFocus,
970
+ "themePreset": _this6.themePreset,
971
+ "autocomplete": "off"
972
+ },
973
+ "ref": _this6.$props.innerRef,
974
+ "class": getClassName(_this6.$props.innerClass, 'input'),
975
+ "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
976
+ onInput: _this6.onInputChange,
977
+ onBlur: function onBlur(e) {
978
+ _this6.$emit('blur', e, _this6.triggerQuery);
979
+ },
980
+ onFocus: _this6.handleFocus,
981
+ onKeyPress: function onKeyPress(e) {
982
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
983
+
984
+ _this6.$emit('key-press', e, _this6.triggerQuery);
985
+ },
986
+ onKeyDown: function onKeyDown(e) {
987
+ return _this6.handleKeyDown(e, highlightedIndex);
988
+ },
989
+ onKeyUp: function onKeyUp(e) {
990
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
991
+
992
+ _this6.$emit('key-up', e, _this6.triggerQuery);
993
+ },
994
+ onClick: function onClick() {
995
+ setHighlightedIndex(null);
996
+ }
997
+ })),
998
+ "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
999
+ value: _this6.$data.currentValue === null ? '' : _this6.$data.currentValue
1000
+ }))
1001
+ }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()]), _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsDropdown()]);
1002
+ }
1003
+ }
1004
+ }) : h("div", {
1005
+ "class": Input.suggestionsContainer
1006
+ }, [h(DataSearch.InputGroup, [this.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1007
+ "class": getClassName(this.$props.innerClass, 'input') || '',
1008
+ "attrs": {
1009
+ "placeholder": this.$props.placeholder,
1010
+ "iconPosition": this.$props.iconPosition,
1011
+ "showIcon": this.$props.showIcon,
1012
+ "showClear": this.$props.showClear,
1013
+ "themePreset": this.themePreset
1014
+ },
1015
+ "on": _rollupPluginBabelHelpers._extends({}, {
1016
+ blur: function blur(e) {
1017
+ _this6.$emit('blur', e, _this6.triggerQuery);
1018
+ },
1019
+ keypress: function keypress(e) {
1020
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1021
+
1022
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1023
+ },
1024
+ input: this.onInputChange,
1025
+ focus: function focus(e) {
1026
+ _this6.$emit('focus', e, _this6.triggerQuery);
1027
+ },
1028
+ keydown: function keydown(e) {
1029
+ _this6.$emit('keyDown', e, _this6.triggerQuery);
1030
+
1031
+ _this6.$emit('key-down', e, _this6.triggerQuery);
1032
+ },
1033
+ keyup: function keyup(e) {
1034
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1035
+
1036
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1037
+ }
1038
+ }),
1039
+ "domProps": _rollupPluginBabelHelpers._extends({}, {
1040
+ autofocus: this.$props.autoFocus,
1041
+ value: this.$data.currentValue ? this.$data.currentValue : ''
1042
+ }),
1043
+ "ref": this.$props.innerRef
1044
+ }), this.renderIcons()]), this.renderInputAddonAfter()])])]);
1045
+ },
1046
+ destroyed: function destroyed() {
1047
+ document.removeEventListener('keydown', this.onKeyDown);
1048
+ }
1049
+ };
1050
+
1051
+ SearchBox.defaultQuery = function (value, props) {
1052
+ var finalQuery = null;
1053
+ var fields = normalizeDataField(props.dataField, props.fieldWeights);
1054
+ finalQuery = {
1055
+ bool: {
1056
+ should: SearchBox.shouldQuery(value, fields, props),
1057
+ minimum_should_match: '1'
1058
+ }
1059
+ };
1060
+
1061
+ if (finalQuery && props.nestedField) {
1062
+ return {
1063
+ query: {
1064
+ nested: {
1065
+ path: props.nestedField,
1066
+ query: finalQuery
1067
+ }
1068
+ }
1069
+ };
1070
+ }
1071
+
1072
+ return finalQuery;
1073
+ };
1074
+
1075
+ SearchBox.shouldQuery = function (value, dataFields, props) {
1076
+ var finalQuery = [];
1077
+ var phrasePrefixFields = [];
1078
+ var fields = dataFields.map(function (dataField) {
1079
+ var queryField = "" + dataField.field + (dataField.weight ? "^" + dataField.weight : '');
1080
+
1081
+ if (!(dataField.field.endsWith('.keyword') || dataField.field.endsWith('.autosuggest') || dataField.field.endsWith('.search'))) {
1082
+ phrasePrefixFields.push(queryField);
1083
+ }
1084
+
1085
+ return queryField;
1086
+ });
1087
+
1088
+ if (props.searchOperators || props.queryString) {
1089
+ return {
1090
+ query: value,
1091
+ fields: fields,
1092
+ default_operator: props.queryFormat
1093
+ };
1094
+ }
1095
+
1096
+ if (props.queryFormat === 'and') {
1097
+ finalQuery.push({
1098
+ multi_match: {
1099
+ query: value,
1100
+ fields: fields,
1101
+ type: 'cross_fields',
1102
+ operator: 'and'
1103
+ }
1104
+ });
1105
+ finalQuery.push({
1106
+ multi_match: {
1107
+ query: value,
1108
+ fields: fields,
1109
+ type: 'phrase',
1110
+ operator: 'and'
1111
+ }
1112
+ });
1113
+
1114
+ if (phrasePrefixFields.length > 0) {
1115
+ finalQuery.push({
1116
+ multi_match: {
1117
+ query: value,
1118
+ fields: phrasePrefixFields,
1119
+ type: 'phrase_prefix',
1120
+ operator: 'and'
1121
+ }
1122
+ });
1123
+ }
1124
+
1125
+ return finalQuery;
1126
+ }
1127
+
1128
+ finalQuery.push({
1129
+ multi_match: {
1130
+ query: value,
1131
+ fields: fields,
1132
+ type: 'best_fields',
1133
+ operator: 'or',
1134
+ fuzziness: props.fuzziness ? props.fuzziness : 0
1135
+ }
1136
+ });
1137
+ finalQuery.push({
1138
+ multi_match: {
1139
+ query: value,
1140
+ fields: fields,
1141
+ type: 'phrase',
1142
+ operator: 'or'
1143
+ }
1144
+ });
1145
+
1146
+ if (phrasePrefixFields.length > 0) {
1147
+ finalQuery.push({
1148
+ multi_match: {
1149
+ query: value,
1150
+ fields: phrasePrefixFields,
1151
+ type: 'phrase_prefix',
1152
+ operator: 'or'
1153
+ }
1154
+ });
1155
+ }
1156
+
1157
+ return finalQuery;
1158
+ };
1159
+
1160
+ var mapStateToProps = function mapStateToProps(state, props) {
1161
+ return {
1162
+ selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
1163
+ selectedCategory: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].category || null,
1164
+ suggestions: state.hits[props.componentId] && state.hits[props.componentId].hits,
1165
+ rawData: state.rawData[props.componentId],
1166
+ aggregationData: state.compositeAggregations[props.componentId] || [],
1167
+ themePreset: state.config.themePreset,
1168
+ isLoading: !!state.isLoading[props.componentId + "_active"],
1169
+ error: state.error[props.componentId],
1170
+ enableAppbase: state.config.enableAppbase,
1171
+ time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
1172
+ total: state.hits[props.componentId] && state.hits[props.componentId].total,
1173
+ hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden
1174
+ };
1175
+ };
1176
+
1177
+ var mapDispatchToProps = {
1178
+ updateQuery: updateQuery,
1179
+ setCustomQuery: setCustomQuery,
1180
+ setDefaultQuery: setDefaultQuery,
1181
+ recordSuggestionClick: recordSuggestionClick
1182
+ };
1183
+ var DSConnected = ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchToProps)(SearchBox), {
1184
+ componentType: constants.componentTypes.searchBox,
1185
+ internalComponent: true
1186
+ });
1187
+
1188
+ SearchBox.install = function (Vue) {
1189
+ Vue.component(SearchBox.name, DSConnected);
1190
+ }; // Add componentType for SSR
1191
+
1192
+
1193
+ SearchBox.componentType = constants.componentTypes.searchBox;
1194
+
1195
+ var components = [ReactiveList.default, ResultCard.default, ResultList.default, ReactiveBase.default, DataSearch.DataSearch, SearchBox, SingleList.default, MultiList.default, SingleRange.default, MultiRange.default, RangeSlider.default, DynamicRangeSlider.default, ReactiveComponent.default, SelectedFilters.default, ToggleButton.default, SingleDropdownList.default, MultiDropdownList.default, StateProvider.default, RangeInput.default];
1196
+ function install (Vue) {
1197
+ components.map(function (component) {
1198
+ Vue.use(component);
1199
+ return null;
1200
+ });
1201
+ }
1202
+
1203
+ exports.SearchBox = SearchBox;
1204
+ exports.install = install;