@appbaseio/reactivesearch-vue 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +1780 -413
  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-11307285.js → Button-e0b7c1f6.js} +1 -1
  6. package/dist/cjs/DataSearch-eec21890.js +2171 -0
  7. package/dist/cjs/DataSearch.js +18 -2107
  8. package/dist/cjs/{DropDown-7aa3d0d2.js → DropDown-e4381fcc.js} +1 -1
  9. package/dist/cjs/{Input-3cc3fa59.js → Input-0d7b25ad.js} +1 -1
  10. package/dist/cjs/MultiDropdownList.js +3 -3
  11. package/dist/cjs/MultiList.js +1 -1
  12. package/dist/cjs/RangeInput.js +1 -1
  13. package/dist/cjs/ReactiveList.js +1 -1
  14. package/dist/cjs/SelectedFilters.js +1 -1
  15. package/dist/cjs/SingleDropdownList.js +3 -3
  16. package/dist/cjs/SingleList.js +1 -1
  17. package/dist/cjs/ToggleButton.js +1 -1
  18. package/dist/cjs/index.js +10 -9
  19. package/dist/cjs/install-4886582d.js +1244 -0
  20. package/dist/cjs/install.js +24 -29
  21. package/dist/cjs/version.js +1 -1
  22. package/dist/es/{Button-91561391.js → Button-33de88e6.js} +1 -1
  23. package/dist/es/DataSearch-42f547cd.js +2158 -0
  24. package/dist/es/DataSearch.js +17 -2106
  25. package/dist/es/{DropDown-60a426a2.js → DropDown-ff6ad982.js} +1 -1
  26. package/dist/es/{Input-08bb1bcf.js → Input-e339e63a.js} +1 -1
  27. package/dist/es/MultiDropdownList.js +3 -3
  28. package/dist/es/MultiList.js +1 -1
  29. package/dist/es/RangeInput.js +1 -1
  30. package/dist/es/ReactiveList.js +1 -1
  31. package/dist/es/SelectedFilters.js +1 -1
  32. package/dist/es/SingleDropdownList.js +3 -3
  33. package/dist/es/SingleList.js +1 -1
  34. package/dist/es/ToggleButton.js +1 -1
  35. package/dist/es/index.js +6 -6
  36. package/dist/es/install-54ebd72e.js +1237 -0
  37. package/dist/es/install.js +22 -31
  38. package/dist/es/version.js +1 -1
  39. package/package.json +2 -2
@@ -1,2111 +1,22 @@
1
- import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-0f24d612.js';
3
- import VueTypes from 'vue-types';
4
- import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
5
- import { getQueryOptions } from '@appbaseio/reactivecore/lib/utils/helper';
1
+ import '@appbaseio/reactivecore';
2
+ import './_rollupPluginBabelHelpers-0f24d612.js';
3
+ import 'vue-types';
4
+ import '@appbaseio/reactivecore/lib/utils/constants';
5
+ import '@appbaseio/reactivecore/lib/utils/helper';
6
6
  import 'emotion';
7
- import styled, { css, cx, injectGlobal } from '@appbaseio/vue-emotion';
7
+ import '@appbaseio/vue-emotion';
8
8
  import 'polished';
9
- import { t as types } from './vueTypes-687b2304.js';
9
+ import './vueTypes-687b2304.js';
10
10
  import '@appbaseio/reactivecore/lib/utils/transform';
11
11
  import 'redux';
12
- import { g as getComponent, h as hasCustomRenderer, f as updateCustomQuery, u as updateDefaultQuery, i as isQueryIdentical, j as getQuerySuggestionsComponent, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, m as hasQuerySuggestionsRenderer, c as connect } from './index-78920565.js';
13
- import { C as ComponentWrapper } from './ComponentWrapper-0f3431d1.js';
14
- import { T as Title } from './Title-3522ff56.js';
15
- import { F as Flex } from './Flex-8770345d.js';
16
- import hotkeys from 'hotkeys-js';
17
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './CancelSvg-c2c03a35.js';
18
- import { n as noSuggestions, s as suggestionsContainer, I as Input, a as suggestions } from './Input-08bb1bcf.js';
12
+ import './index-78920565.js';
13
+ import './ComponentWrapper-0f3431d1.js';
14
+ import './Title-3522ff56.js';
15
+ import './Flex-8770345d.js';
16
+ import 'hotkeys-js';
17
+ export { D as default } from './DataSearch-42f547cd.js';
18
+ import './CancelSvg-c2c03a35.js';
19
+ import './Input-e339e63a.js';
19
20
  import 'compute-scroll-into-view';
20
- import { C as Container } from './Container-18b03fde.js';
21
- import Highlight from 'vue-highlight-words';
22
-
23
- var _templateObject;
24
- var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: stretch;\n width: 100%;\n"])));
25
- InputGroup.defaultProps = {
26
- className: 'input-group'
27
- };
28
-
29
- var _templateObject$1;
30
- var InputAddon = styled('span')(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #fafafa;\n border: 1px solid #ccc;\n border-radius: 2px;\n color: rgba(0, 0, 0, 0.85);\n font-size: 14px;\n font-weight: 400;\n padding: 0 11px;\n position: relative;\n transition: all 0.3s;\n box-sizing: border-box;\n overflow: hidden;\n\n &:first-of-type {\n border-right: none;\n }\n &:last-of-type {\n border-left: none;\n }\n"])));
31
- InputAddon.defaultProps = {
32
- className: 'input-addon'
33
- };
34
-
35
- var getClassName = helper.getClassName;
36
- var SuggestionWrapper = {
37
- name: 'SuggestionWrapper',
38
- props: {
39
- innerClassName: types.string,
40
- themePreset: types.themePreset,
41
- innerClass: types.style
42
- },
43
- render: function render() {
44
- var h = arguments[0];
45
- var _this$$props = this.$props,
46
- themePreset = _this$$props.themePreset,
47
- innerClass = _this$$props.innerClass,
48
- innerClassName = _this$$props.innerClassName;
49
- return h("div", {
50
- "class": noSuggestions(themePreset) + " " + getClassName(innerClass, innerClassName || '')
51
- }, [h("li", [this.$scopedSlots["default"]()])]);
52
- }
53
- };
54
-
55
- var _templateObject$2;
56
- var highlightStyle = {
57
- fontWeight: 600,
58
- padding: 0,
59
- backgroundColor: 'transparent',
60
- color: 'inherit'
61
- };
62
- var PredictiveSuggestion = styled('span')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteralLoose(["\n\t.highlight {\n\t\tbackground: transparent;\n\t\tcolor: inherit;\n\t\tfont-weight: 600;\n\t\tpadding: 0;\n\t}\n"])));
63
- var SuggestionItem = {
64
- name: 'SuggestionItem',
65
- props: {
66
- currentValue: types.string,
67
- suggestion: types.any
68
- },
69
- render: function render() {
70
- var h = arguments[0];
71
- var _this$suggestion = this.suggestion,
72
- label = _this$suggestion.label,
73
- value = _this$suggestion.value,
74
- title = _this$suggestion.title,
75
- description = _this$suggestion.description,
76
- image = _this$suggestion.image,
77
- isPredictiveSuggestion = _this$suggestion.isPredictiveSuggestion;
78
-
79
- if (label) {
80
- // label has highest precedence
81
- return typeof label === 'string' ? h("div", {
82
- "class": "trim"
83
- }, [isPredictiveSuggestion ? h(PredictiveSuggestion, {
84
- "domProps": {
85
- "innerHTML": label
86
- }
87
- }) : h(Highlight, {
88
- "attrs": {
89
- "searchWords": this.currentValue.split(' '),
90
- "textToHighlight": label,
91
- "autoEscape": true,
92
- "highlightStyle": highlightStyle
93
- }
94
- })]) : label;
95
- }
96
-
97
- if (title || image || description) {
98
- return h(Flex, {
99
- "attrs": {
100
- "alignItems": "center",
101
- "css": {
102
- width: '100%'
103
- }
104
- }
105
- }, [image && h("div", {
106
- "attrs": {
107
- "css": {
108
- margin: 'auto',
109
- marginRight: 10
110
- }
111
- }
112
- }, [h("img", {
113
- "attrs": {
114
- "src": image,
115
- "alt": " ",
116
- "height": "50px",
117
- "width": "50px",
118
- "css": {
119
- objectFit: 'contain'
120
- }
121
- }
122
- })]), h(Flex, {
123
- "attrs": {
124
- "direction": "column",
125
- "css": {
126
- width: image ? 'calc(100% - 60px)' : '100%'
127
- }
128
- }
129
- }, [title && h("div", {
130
- "class": "trim"
131
- }, [h(Highlight, {
132
- "attrs": {
133
- "searchWords": this.currentValue.split(' '),
134
- "textToHighlight": title,
135
- "highlightStyle": highlightStyle
136
- },
137
- "class": css({
138
- fontSize: '1rem'
139
- })
140
- })]), description && h("div", {
141
- "class": cx('trim', css({
142
- marginTop: 3
143
- }))
144
- }, [h(Highlight, {
145
- "attrs": {
146
- "searchWords": this.currentValue.split(' '),
147
- "textToHighlight": description,
148
- "highlightStyle": highlightStyle
149
- }
150
- })])])]);
151
- }
152
-
153
- return value;
154
- }
155
- };
156
-
157
- var SearchSvg = {
158
- functional: true,
159
- render: function render(h) {
160
- return h("svg", {
161
- "attrs": {
162
- "alt": "Search",
163
- "height": "14",
164
- "width": "10",
165
- "xmlns": "http://www.w3.org/2000/svg",
166
- "viewBox": "0 0 15 15"
167
- },
168
- "class": "search-icon"
169
- }, [h("title", ["Search"]), h("path", {
170
- "attrs": {
171
- "d": 'M6.02945,10.20327a4.17382,4.17382,0,1,1,4.17382-4.17382A4.15609,4.15609,0,0,1,6.02945,10.20327Zm9.69195,4.2199L10.8989,9.59979A5.88021,5.88021,0,0,0,12.058,6.02856,6.00467,6.00467,0,1,0,9.59979,10.8989l4.82338,4.82338a.89729.89729,0,0,0,1.29912,0,.89749.89749,0,0,0-.00087-1.29909Z'
172
- }
173
- })]);
174
- }
175
- };
176
-
177
- var _templateObject$3;
178
-
179
- injectGlobal(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteralLoose(["\n\t#el_TvxDfTAtKp {\n\t\tstroke: none;\n\t\tstroke-width: 1;\n\t\tfill: none;\n\t}\n\t#el_D93PK3GbmJ {\n\t\t-webkit-transform: translate(163px, 131px);\n\t\ttransform: translate(163px, 131px);\n\t\tfill: #d8d8d8;\n\t}\n"])));
180
- var MicSvg = {
181
- name: 'MicSvg',
182
- props: ['className'],
183
- render: function render() {
184
- var h = arguments[0];
185
- return h("svg", {
186
- "attrs": {
187
- "viewBox": "0 0 480 480",
188
- "xmlns": "http://www.w3.org/2000/svg",
189
- "id": "el_xS0FRzQjJ",
190
- "width": 28,
191
- "height": 28,
192
- "className": this.$props.className
193
- },
194
- "style": {
195
- transform: 'scale(1.5)'
196
- }
197
- }, [h("g", {
198
- "attrs": {
199
- "id": "el_TvxDfTAtKp",
200
- "fillRule": "evenodd"
201
- }
202
- }, [h("g", {
203
- "attrs": {
204
- "id": "el_D93PK3GbmJ",
205
- "fillRule": "nonzero"
206
- },
207
- "style": {
208
- fill: '#595959'
209
- }
210
- }, [h("path", {
211
- "attrs": {
212
- "d": "M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z",
213
- "id": "el_uly3EwA2O3"
214
- }
215
- }), h("path", {
216
- "attrs": {
217
- "d": "M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,-2.84217094e-14 76.9864699,-2.84217094e-14 C55.8825877,-2.84217094e-14 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z",
218
- "id": "el_tnDbR4ytu4"
219
- }
220
- })])])]);
221
- }
222
- };
223
-
224
- var _templateObject$4;
225
-
226
- injectGlobal(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n\t#el_X81iT9kZYo {\n\t\tstroke: none;\n\t\tstroke-width: 1;\n\t\tfill: none;\n\t}\n\t#el_gMpyalCphp {\n\t\t-webkit-transform: translate(163px, 131px);\n\t\ttransform: translate(163px, 131px);\n\t}\n\t#el_c7H-3u-D4l {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_qhFcdAAFwo {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_M8X8g37WOI {\n\t\tstroke: #e83137;\n\t\tstroke-width: 21;\n\t}\n"])));
227
- var MuteSvg = {
228
- name: 'MuteSvg',
229
- props: ['className'],
230
- render: function render() {
231
- var h = arguments[0];
232
- return h("svg", {
233
- "style": {
234
- transform: 'scale(1.5)'
235
- },
236
- "attrs": {
237
- "viewBox": "0 0 480 480",
238
- "xmlns": "http://www.w3.org/2000/svg",
239
- "id": "el_D1rEpH2zj",
240
- "width": 28,
241
- "height": 28,
242
- "className": this.$props.className
243
- }
244
- }, [h("g", {
245
- "attrs": {
246
- "id": "el_X81iT9kZYo",
247
- "fillRule": "evenodd"
248
- }
249
- }, [h("g", {
250
- "attrs": {
251
- "id": "el_gMpyalCphp"
252
- }
253
- }, [h("path", {
254
- "attrs": {
255
- "d": "M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z",
256
- "id": "el_c7H-3u-D4l",
257
- "fillRule": "nonzero"
258
- },
259
- "style": {
260
- fill: '#595959'
261
- }
262
- }), h("path", {
263
- "attrs": {
264
- "d": "M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,-2.84217094e-14 76.9864699,-2.84217094e-14 C55.8825877,-2.84217094e-14 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z",
265
- "id": "el_qhFcdAAFwo",
266
- "fillRule": "nonzero"
267
- },
268
- "style": {
269
- fill: '#595959'
270
- }
271
- }), h("path", {
272
- "attrs": {
273
- "d": "M11.5,206.5 L142.5,12.5",
274
- "id": "el_M8X8g37WOI",
275
- "strokeLinecap": "round",
276
- "strokeLinejoin": "round"
277
- }
278
- })])])]);
279
- }
280
- };
281
-
282
- var _templateObject$5;
283
-
284
- injectGlobal(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteralLoose(["\n\t@-webkit-keyframes kf_el_6WKby7wXqV_an_qqO-rxbNc {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t13.89% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_6WKby7wXqV_an_qqO-rxbNc {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t13.89% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_Wi-my975tM_an_XhXP1epXB {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t27.78% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_Wi-my975tM_an_XhXP1epXB {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t27.78% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_DkfFFTaFxy8_an_T2XxzvIaA {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t41.67% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_DkfFFTaFxy8_an_T2XxzvIaA {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t41.67% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_34IgwiMB5rf_an_TPom3H2LI {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t55.56% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_34IgwiMB5rf_an_TPom3H2LI {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t55.56% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_DeebuCsPTGA_an_aYTRBE7Na {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t69.44% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_DeebuCsPTGA_an_aYTRBE7Na {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t69.44% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_ZOjjrPTvyrv_an_l_BjBNzXw {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t83.33% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_ZOjjrPTvyrv_an_l_BjBNzXw {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t83.33% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_2FATegVmf0K_an_wLg4ofuFx {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t97.22% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_2FATegVmf0K_an_wLg4ofuFx {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t97.22% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t#el_hiibMG0x- * {\n\t\t-webkit-animation-duration: 1.2s;\n\t\tanimation-duration: 1.2s;\n\t\t-webkit-animation-iteration-count: infinite;\n\t\tanimation-iteration-count: infinite;\n\t\t-webkit-animation-timing-function: cubic-bezier(0, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0, 0, 1, 1);\n\t}\n\t#el_QJeJ_2CDw5 {\n\t\tstroke: none;\n\t\tstroke-width: 1;\n\t\tfill: none;\n\t}\n\t#el_UYYCfubTRf {\n\t\t-webkit-transform: translate(163px, 123px);\n\t\ttransform: translate(163px, 123px);\n\t}\n\t#el_uzZNtK32Zi {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_EYKQ2N9Kgy {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_6SDP2LAgKC {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t}\n\t#el_-Vm65Ltfy7 {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_q04iZcSim4 {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_6WKby7wXqV {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_6WKby7wXqV_an_qqO-rxbNc;\n\t\tanimation-name: kf_el_6WKby7wXqV_an_qqO-rxbNc;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_9bggsfQOtU {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_NKxqi9eIym {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_Wi-my975tM {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_Wi-my975tM_an_XhXP1epXB;\n\t\tanimation-name: kf_el_Wi-my975tM_an_XhXP1epXB;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_zclQ34fvf7 {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_1OsvRT8HkeZ {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_DkfFFTaFxy8 {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_DkfFFTaFxy8_an_T2XxzvIaA;\n\t\tanimation-name: kf_el_DkfFFTaFxy8_an_T2XxzvIaA;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_aa9sjx4H0vA {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_tea114vWg0J {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_34IgwiMB5rf {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_34IgwiMB5rf_an_TPom3H2LI;\n\t\tanimation-name: kf_el_34IgwiMB5rf_an_TPom3H2LI;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_z5u6RAFhx7d {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_7nfuWmA5Uhy {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_DeebuCsPTGA {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_DeebuCsPTGA_an_aYTRBE7Na;\n\t\tanimation-name: kf_el_DeebuCsPTGA_an_aYTRBE7Na;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el__ZcqlS20zcw {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_8DnEQnD7VWV {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_ZOjjrPTvyrv {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_ZOjjrPTvyrv_an_l_BjBNzXw;\n\t\tanimation-name: kf_el_ZOjjrPTvyrv_an_l_BjBNzXw;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_FYYKCI_u24e {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_XZty4MnTp5Y {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_2FATegVmf0K {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_2FATegVmf0K_an_wLg4ofuFx;\n\t\tanimation-name: kf_el_2FATegVmf0K_an_wLg4ofuFx;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_RMT1KUfbdF8 {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_RgLcovvFiO1 {\n\t\tfill: #d8d8d8;\n\t}\n"])));
285
- var ListenSvg = {
286
- name: 'ListenSvg',
287
- props: ['className'],
288
- render: function render() {
289
- var h = arguments[0];
290
- return h("svg", {
291
- "attrs": {
292
- "viewBox": "0 0 480 480",
293
- "xmlns": "http://www.w3.org/2000/svg",
294
- "xmlnsXlink": "http://www.w3.org/1999/xlink",
295
- "id": "el_hiibMG0x-",
296
- "width": 28,
297
- "height": 29,
298
- "className": this.$props.className
299
- },
300
- "style": {
301
- transform: 'scale(1.5)'
302
- }
303
- }, [h("defs", [h("path", {
304
- "attrs": {
305
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
306
- "id": "path-1"
307
- }
308
- }), h("path", {
309
- "attrs": {
310
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
311
- "id": "path-3"
312
- }
313
- }), h("path", {
314
- "attrs": {
315
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
316
- "id": "path-5"
317
- }
318
- }), h("path", {
319
- "attrs": {
320
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
321
- "id": "path-7"
322
- }
323
- }), h("path", {
324
- "attrs": {
325
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
326
- "id": "path-9"
327
- }
328
- }), h("path", {
329
- "attrs": {
330
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
331
- "id": "path-11"
332
- }
333
- }), h("path", {
334
- "attrs": {
335
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
336
- "id": "path-13"
337
- }
338
- }), h("path", {
339
- "attrs": {
340
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
341
- "id": "path-15"
342
- }
343
- })]), h("g", {
344
- "attrs": {
345
- "id": "el_QJeJ_2CDw5",
346
- "fillRule": "evenodd"
347
- }
348
- }, [h("g", {
349
- "attrs": {
350
- "id": "el_UYYCfubTRf"
351
- }
352
- }, [h("path", {
353
- "attrs": {
354
- "d": "M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z",
355
- "id": "el_uzZNtK32Zi",
356
- "fillRule": "nonzero"
357
- },
358
- "style": {
359
- fill: '#0B6AFF'
360
- }
361
- }), h("path", {
362
- "attrs": {
363
- "d": "M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,0 76.9864699,0 C55.8825877,0 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z",
364
- "id": "el_EYKQ2N9Kgy",
365
- "fillRule": "nonzero"
366
- }
367
- }), h("g", {
368
- "attrs": {
369
- "id": "el_6SDP2LAgKC"
370
- }
371
- }, [h("mask", {
372
- "attrs": {
373
- "id": "mask-2",
374
- "fill": "#fff"
375
- }
376
- }, [h("use", {
377
- "attrs": {
378
- "xlink:href": "#path-1"
379
- }
380
- })]), h("path", {
381
- "attrs": {
382
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
383
- "id": "el_-Vm65Ltfy7",
384
- "fillRule": "nonzero",
385
- "mask": "url(#mask-2)"
386
- }
387
- }), h("rect", {
388
- "attrs": {
389
- "id": "el_q04iZcSim4",
390
- "mask": "url(#mask-2)",
391
- "x": "0.279",
392
- "width": "77",
393
- "height": "130"
394
- }
395
- })]), h("g", {
396
- "attrs": {
397
- "id": "el_6WKby7wXqV"
398
- }
399
- }, [h("mask", {
400
- "attrs": {
401
- "id": "mask-4",
402
- "fill": "#fff"
403
- }
404
- }, [h("use", {
405
- "attrs": {
406
- "xlink:href": "#path-3"
407
- }
408
- })]), h("path", {
409
- "attrs": {
410
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
411
- "id": "el_9bggsfQOtU",
412
- "fillRule": "nonzero",
413
- "mask": "url(#mask-4)"
414
- }
415
- }), h("rect", {
416
- "attrs": {
417
- "id": "el_NKxqi9eIym",
418
- "mask": "url(#mask-4)",
419
- "x": "0.279",
420
- "width": "77",
421
- "height": "115"
422
- }
423
- })]), h("g", {
424
- "attrs": {
425
- "id": "el_Wi-my975tM"
426
- }
427
- }, [h("mask", {
428
- "attrs": {
429
- "id": "mask-6",
430
- "fill": "#fff"
431
- }
432
- }, [h("use", {
433
- "attrs": {
434
- "xlink:href": "#path-5"
435
- }
436
- })]), h("path", {
437
- "attrs": {
438
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
439
- "id": "el_zclQ34fvf7",
440
- "fillRule": "nonzero",
441
- "mask": "url(#mask-6)"
442
- }
443
- }), h("rect", {
444
- "attrs": {
445
- "id": "el_1OsvRT8HkeZ",
446
- "mask": "url(#mask-6)",
447
- "x": "0.279",
448
- "width": "77",
449
- "height": "100"
450
- }
451
- })]), h("g", {
452
- "attrs": {
453
- "id": "el_DkfFFTaFxy8"
454
- }
455
- }, [h("mask", {
456
- "attrs": {
457
- "id": "mask-8",
458
- "fill": "#fff"
459
- }
460
- }, [h("use", {
461
- "attrs": {
462
- "xlink:href": "#path-7"
463
- }
464
- })]), h("path", {
465
- "attrs": {
466
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
467
- "id": "el_aa9sjx4H0vA",
468
- "fillRule": "nonzero",
469
- "mask": "url(#mask-8)"
470
- }
471
- }), h("rect", {
472
- "attrs": {
473
- "id": "el_tea114vWg0J",
474
- "mask": "url(#mask-8)",
475
- "x": "0.279",
476
- "width": "77",
477
- "height": "85"
478
- }
479
- })]), h("g", {
480
- "attrs": {
481
- "id": "el_34IgwiMB5rf"
482
- }
483
- }, [h("mask", {
484
- "attrs": {
485
- "id": "mask-10",
486
- "fill": "#fff"
487
- }
488
- }, [h("use", {
489
- "attrs": {
490
- "xlink:href": "#path-9"
491
- }
492
- })]), h("path", {
493
- "attrs": {
494
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
495
- "id": "el_z5u6RAFhx7d",
496
- "fillRule": "nonzero",
497
- "mask": "url(#mask-10)"
498
- }
499
- }), h("rect", {
500
- "attrs": {
501
- "id": "el_7nfuWmA5Uhy",
502
- "mask": "url(#mask-10)",
503
- "x": "0.279",
504
- "width": "77",
505
- "height": "70"
506
- }
507
- })]), h("g", {
508
- "attrs": {
509
- "id": "el_DeebuCsPTGA"
510
- }
511
- }, [h("mask", {
512
- "attrs": {
513
- "id": "mask-12",
514
- "fill": "#fff"
515
- }
516
- }, [h("use", {
517
- "attrs": {
518
- "xlink:href": "#path-11"
519
- }
520
- })]), h("path", {
521
- "attrs": {
522
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
523
- "id": "el__ZcqlS20zcw",
524
- "fillRule": "nonzero",
525
- "mask": "url(#mask-12)"
526
- }
527
- }), h("rect", {
528
- "attrs": {
529
- "id": "el_8DnEQnD7VWV",
530
- "mask": "url(#mask-12)",
531
- "x": "0.279",
532
- "width": "77",
533
- "height": "55"
534
- }
535
- })]), h("g", {
536
- "attrs": {
537
- "id": "el_ZOjjrPTvyrv"
538
- }
539
- }, [h("mask", {
540
- "attrs": {
541
- "id": "mask-14",
542
- "fill": "#fff"
543
- }
544
- }, [h("use", {
545
- "attrs": {
546
- "xlink:href": "#path-13"
547
- }
548
- })]), h("path", {
549
- "attrs": {
550
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
551
- "id": "el_FYYKCI_u24e",
552
- "fillRule": "nonzero",
553
- "mask": "url(#mask-14)"
554
- }
555
- }), h("rect", {
556
- "attrs": {
557
- "id": "el_XZty4MnTp5Y",
558
- "mask": "url(#mask-14)",
559
- "x": "0.279",
560
- "width": "77",
561
- "height": "40"
562
- }
563
- })]), h("g", {
564
- "attrs": {
565
- "id": "el_2FATegVmf0K"
566
- }
567
- }, [h("mask", {
568
- "attrs": {
569
- "id": "mask-16",
570
- "fill": "#fff"
571
- }
572
- }, [h("use", {
573
- "attrs": {
574
- "xlink:href": "#path-15"
575
- }
576
- })]), h("path", {
577
- "attrs": {
578
- "d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
579
- "id": "el_RMT1KUfbdF8",
580
- "fillRule": "nonzero",
581
- "mask": "url(#mask-16)"
582
- }
583
- }), h("rect", {
584
- "attrs": {
585
- "id": "el_RgLcovvFiO1",
586
- "mask": "url(#mask-16)",
587
- "x": "0.279",
588
- "width": "77",
589
- "height": "25"
590
- }
591
- })])])])]);
592
- }
593
- };
594
-
595
- var STATUS = {
596
- inactive: 'INACTIVE',
597
- stopped: 'STOPPED',
598
- active: 'ACTIVE',
599
- denied: 'DENIED'
600
- };
601
- var Mic = {
602
- name: 'Mic',
603
- props: {
604
- children: types.title,
605
- lang: VueTypes.string.def('en-US'),
606
- iconPosition: VueTypes.string.def('left'),
607
- handleResult: types.func,
608
- onNoMatch: types.func,
609
- onError: types.func,
610
- getInstance: types.func,
611
- render: types.func,
612
- className: types.string,
613
- applyClearStyle: VueTypes.bool,
614
- showIcon: VueTypes.bool
615
- },
616
- methods: {
617
- getComponent: function getComponent$1() {
618
- var status = this.$data.status;
619
- var data = {
620
- handleClick: this.handleClick,
621
- status: status
622
- };
623
- return getComponent(data, this);
624
- },
625
- stopMic: function stopMic() {
626
- if (this.instance) {
627
- this.status = STATUS.inactive;
628
- this.instance.stop();
629
- this.instance = null;
630
- }
631
- },
632
- handleClick: function handleClick() {
633
- var _this = this;
634
-
635
- this.results = [];
636
-
637
- if (window && window.SpeechRecognition) {
638
- var status = this.$data.status;
639
-
640
- if (status === STATUS.active) {
641
- this.status = STATUS.inactive;
642
- }
643
-
644
- var _this$$props = this.$props,
645
- handleResult = _this$$props.handleResult,
646
- onNoMatch = _this$$props.onNoMatch,
647
- onError = _this$$props.onError,
648
- lang = _this$$props.lang,
649
- getInstance = _this$$props.getInstance;
650
- var _window = window,
651
- SpeechRecognition = _window.SpeechRecognition;
652
-
653
- if (this.instance && this.status !== STATUS.denied) {
654
- this.status = STATUS.inactive;
655
- this.instance.stop();
656
- this.instance = null;
657
- return;
658
- }
659
-
660
- this.instance = new SpeechRecognition();
661
- this.instance.continuous = true;
662
- this.instance.interimResults = true;
663
- this.instance.lang = lang;
664
-
665
- if (getInstance) {
666
- getInstance(this.instance);
667
- }
668
-
669
- this.instance.start();
670
-
671
- this.instance.onstart = function () {
672
- _this.status = STATUS.active;
673
- };
674
-
675
- this.instance.onresult = function (_ref) {
676
- var results = _ref.results,
677
- timeStamp = _ref.timeStamp;
678
-
679
- _this.stopMic();
680
-
681
- if (handleResult) {
682
- handleResult({
683
- results: results,
684
- timeStamp: timeStamp
685
- });
686
- }
687
-
688
- _this.results.push({
689
- results: results,
690
- timeStamp: timeStamp
691
- });
692
- };
693
-
694
- this.instance.onnomatch = function (e) {
695
- return onNoMatch ? onNoMatch(e) : console.warn(e);
696
- };
697
-
698
- this.instance.onerror = function (e) {
699
- if (e.error === 'no-speech' || e.error === 'audio-capture') {
700
- _this.status = STATUS.inactive;
701
- } else if (e.error === 'not-allowed') {
702
- _this.status = STATUS.denied;
703
- }
704
-
705
- console.error(e);
706
-
707
- if (onError) {
708
- onError(e);
709
- }
710
- };
711
- /* Below Two methods run when Continuous is False */
712
-
713
-
714
- this.instance.onspeechend = function () {
715
- _this.status = STATUS.inactive;
716
- };
717
-
718
- this.instance.onaudioend = function () {
719
- _this.status = STATUS.inactive;
720
- };
721
- }
722
- }
723
- },
724
- computed: {
725
- hasCustomRenderer: function hasCustomRenderer$1() {
726
- return hasCustomRenderer(this);
727
- },
728
- Icon: function Icon() {
729
- var h = this.$createElement;
730
- var status = this.$data.status;
731
- var className = this.$props.className;
732
-
733
- switch (status) {
734
- case STATUS.active:
735
- return h(ListenSvg, {
736
- "attrs": {
737
- "className": className
738
- },
739
- "nativeOn": {
740
- "click": this.handleClick
741
- }
742
- });
743
-
744
- case STATUS.stopped:
745
- case STATUS.denied:
746
- return h(MuteSvg, {
747
- "attrs": {
748
- "className": className
749
- },
750
- "nativeOn": {
751
- "click": this.handleClick
752
- }
753
- });
754
-
755
- default:
756
- return h(MicSvg, {
757
- "attrs": {
758
- "className": className
759
- },
760
- "nativeOn": {
761
- "click": this.handleClick
762
- }
763
- });
764
- }
765
- }
766
- },
767
- data: function data() {
768
- return {
769
- status: STATUS.inactive
770
- };
771
- },
772
- created: function created() {
773
- this.results = [];
774
-
775
- if (typeof window !== 'undefined') {
776
- window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition || null;
777
-
778
- if (!window.SpeechRecognition) {
779
- console.error('SpeechRecognition is not supported in this browser. Please check the browser compatibility at https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition#Browser_compatibility.');
780
- }
781
- }
782
- },
783
- render: function render() {
784
- var h = arguments[0];
785
-
786
- if (this.hasCustomRenderer) {
787
- return this.getComponent();
788
- }
789
-
790
- return h(IconWrapper, [this.Icon]);
791
- }
792
- };
793
-
794
- var CustomSvg = {
795
- name: 'CustomSvg',
796
- props: {
797
- className: String,
798
- icon: Function,
799
- type: String
800
- },
801
- data: function data() {
802
- return {
803
- customIcon: this.$props.icon && typeof this.$props.icon === 'function' ? this.$props.icon() : null
804
- };
805
- },
806
- render: function render() {
807
- var h = arguments[0];
808
-
809
- if (this.customIcon) {
810
- return h("div", {
811
- "class": this.$props.className
812
- }, [this.customIcon]);
813
- }
814
-
815
- if (this.$props.type === 'popular-search-icon') {
816
- return h("svg", {
817
- "attrs": {
818
- "xmlns": "http://www.w3.org/2000/svg",
819
- "alt": "Popular Searches",
820
- "height": "20",
821
- "width": "20",
822
- "viewBox": "0 0 24 24"
823
- },
824
- "style": {
825
- fill: '#707070'
826
- },
827
- "class": this.$props.className
828
- }, [h("path", {
829
- "attrs": {
830
- "d": "M0 0h24v24H0z",
831
- "fill": "none"
832
- }
833
- }), h("path", {
834
- "attrs": {
835
- "d": "M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"
836
- }
837
- })]);
838
- } else {
839
- return h("svg", {
840
- "attrs": {
841
- "xmlns": "http://www.w3.org/2000/svg",
842
- "alt": "Recent Searches",
843
- "height": "20",
844
- "width": "20",
845
- "viewBox": "0 0 24 24"
846
- },
847
- "style": {
848
- fill: '#707070'
849
- },
850
- "class": this.$props.className
851
- }, [h("path", {
852
- "attrs": {
853
- "d": "M0 0h24v24H0z",
854
- "fill": "none"
855
- }
856
- }), h("path", {
857
- "attrs": {
858
- "d": "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"
859
- }
860
- })]);
861
- }
862
- }
863
- };
864
-
865
- var updateQuery = Actions.updateQuery,
866
- setQueryOptions = Actions.setQueryOptions,
867
- setCustomQuery = Actions.setCustomQuery,
868
- setDefaultQuery = Actions.setDefaultQuery,
869
- setCustomHighlightOptions = Actions.setCustomHighlightOptions,
870
- recordSuggestionClick = Actions.recordSuggestionClick,
871
- loadPopularSuggestions = Actions.loadPopularSuggestions,
872
- getRecentSearches = Actions.getRecentSearches;
873
- var debounce = helper.debounce,
874
- checkValueChange = helper.checkValueChange,
875
- getClassName$1 = helper.getClassName,
876
- extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
877
- getOptionsForCustomQuery = helper.getOptionsForCustomQuery,
878
- isEqual = helper.isEqual,
879
- getCompositeAggsQuery = helper.getCompositeAggsQuery,
880
- withClickIds = helper.withClickIds,
881
- getResultStats = helper.getResultStats,
882
- handleOnSuggestions = helper.handleOnSuggestions,
883
- getTopSuggestions = helper.getTopSuggestions,
884
- normalizeDataField = helper.normalizeDataField;
885
- var DataSearch = {
886
- name: 'DataSearch',
887
- data: function data() {
888
- var props = this.$props;
889
- this.__state = {
890
- currentValue: '',
891
- isOpen: false,
892
- normalizedSuggestions: [],
893
- isPending: false
894
- };
895
- this.internalComponent = props.componentId + "__internal";
896
- return this.__state;
897
- },
898
- inject: {
899
- theme: {
900
- from: 'theme_reactivesearch'
901
- }
902
- },
903
- created: function created() {
904
- var _this$$props = this.$props,
905
- enableQuerySuggestions = _this$$props.enableQuerySuggestions,
906
- renderQuerySuggestions = _this$$props.renderQuerySuggestions,
907
- enableRecentSearches = _this$$props.enableRecentSearches,
908
- distinctField = _this$$props.distinctField,
909
- distinctFieldConfig = _this$$props.distinctFieldConfig,
910
- index = _this$$props.index; // TODO: Remove in 2.0
911
-
912
- if (enableQuerySuggestions) {
913
- console.warn('Warning(ReactiveSearch): The `enableQuerySuggestions` prop has been marked as deprecated, please use the `enablePopularSuggestions` prop instead.');
914
- } // TODO: Remove in 2.0
915
-
916
-
917
- if (renderQuerySuggestions) {
918
- console.warn('Warning(ReactiveSearch): The `renderQuerySuggestions` prop has been marked as deprecated, please use the `renderPopularSuggestions` prop instead.');
919
- }
920
-
921
- if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
922
- console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
923
- }
924
-
925
- if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
926
- console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
927
- }
928
-
929
- if (!this.enableAppbase && index) {
930
- console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
931
- }
932
-
933
- this.loadPopularSuggestions(this.$props.componentId);
934
- this.currentValue = this.selectedValue || '';
935
-
936
- if (enableRecentSearches) {
937
- this.getRecentSearches();
938
- }
939
-
940
- this.handleTextChange = debounce(this.handleText, this.$props.debounce); // Set custom and default queries in store
941
-
942
- updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.currentValue);
943
- updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.currentValue);
944
- },
945
- computed: {
946
- suggestionsList: function suggestionsList() {
947
- var suggestionsList = [];
948
-
949
- if (!this.$data.currentValue && this.$props.defaultSuggestions && this.$props.defaultSuggestions.length) {
950
- suggestionsList = this.$props.defaultSuggestions;
951
- } else if (this.$data.currentValue) {
952
- suggestionsList = this.normalizedSuggestions;
953
- }
954
-
955
- return withClickIds(suggestionsList);
956
- },
957
- topSuggestions: function topSuggestions() {
958
- if (!this.currentValue) {
959
- return [];
960
- }
961
-
962
- return this.enableQuerySuggestions || this.enablePopularSuggestions ? this.normalizedPopularSuggestions : [];
963
- },
964
- normalizedRecentSearches: function normalizedRecentSearches() {
965
- return this.recentSearches || [];
966
- },
967
- normalizedPopularSuggestions: function normalizedPopularSuggestions() {
968
- return getTopSuggestions( // use default popular suggestions if value is empty
969
- this.currentValue ? this.popularSuggestions : this.defaultPopularSuggestions || [], this.currentValue, this.showDistinctSuggestions);
970
- },
971
- defaultSearchSuggestions: function defaultSearchSuggestions() {
972
- var isPopularSuggestionsEnabled = this.enableQuerySuggestions || this.enablePopularSuggestions;
973
-
974
- if (this.currentValue) {
975
- return [];
976
- }
977
-
978
- var customDefaultPopularSuggestions = (this.defaultPopularSuggestions || []).map(function (suggestion) {
979
- return _extends({}, suggestion, {
980
- _popular_suggestion: true
981
- });
982
- });
983
- var customNormalizedRecentSearches = (this.normalizedRecentSearches || []).map(function (search) {
984
- return _extends({}, search, {
985
- _recent_search: true
986
- });
987
- });
988
- var defaultSuggestions = isPopularSuggestionsEnabled ? [].concat(customNormalizedRecentSearches, customDefaultPopularSuggestions || []) : customNormalizedRecentSearches;
989
- return getTopSuggestions( // use default popular suggestions if value is empty
990
- defaultSuggestions, this.currentValue, this.showDistinctSuggestions);
991
- },
992
- hasCustomRenderer: function hasCustomRenderer$1() {
993
- return hasCustomRenderer(this);
994
- },
995
- stats: function stats() {
996
- return getResultStats(this);
997
- }
998
- },
999
- props: {
1000
- options: types.options,
1001
- autoFocus: VueTypes.bool,
1002
- autosuggest: VueTypes.bool.def(true),
1003
- beforeValueChange: types.func,
1004
- className: VueTypes.string.def(''),
1005
- clearIcon: types.children,
1006
- componentId: types.stringRequired,
1007
- customHighlight: types.func,
1008
- customQuery: types.func,
1009
- defaultQuery: types.func,
1010
- dataField: VueTypes.oneOfType([VueTypes.string, VueTypes.shape({
1011
- field: VueTypes.string,
1012
- weight: VueTypes.number
1013
- }), VueTypes.arrayOf(VueTypes.string), VueTypes.arrayOf({
1014
- field: VueTypes.string,
1015
- weight: VueTypes.number
1016
- })]),
1017
- aggregationField: types.string,
1018
- aggregationSize: VueTypes.number,
1019
- size: VueTypes.number,
1020
- debounce: VueTypes.number.def(0),
1021
- defaultValue: types.string,
1022
- excludeFields: types.excludeFields,
1023
- value: types.value,
1024
- defaultSuggestions: types.suggestions,
1025
- enableSynonyms: VueTypes.bool.def(true),
1026
- enableQuerySuggestions: VueTypes.bool.def(false),
1027
- enablePopularSuggestions: VueTypes.bool.def(false),
1028
- enableRecentSearches: VueTypes.bool.def(false),
1029
- fieldWeights: types.fieldWeights,
1030
- filterLabel: types.string,
1031
- fuzziness: types.fuzziness,
1032
- highlight: VueTypes.bool,
1033
- highlightField: types.stringOrArray,
1034
- icon: types.children,
1035
- iconPosition: VueTypes.oneOf(['left', 'right']).def('left'),
1036
- includeFields: types.includeFields,
1037
- innerClass: types.style,
1038
- innerRef: VueTypes.string.def('searchInputField'),
1039
- render: types.func,
1040
- renderQuerySuggestions: types.func,
1041
- renderPopularSuggestions: types.func,
1042
- parseSuggestion: types.func,
1043
- renderNoSuggestion: types.title,
1044
- renderError: types.title,
1045
- placeholder: VueTypes.string.def('Search'),
1046
- queryFormat: VueTypes.oneOf(['and', 'or']).def('or'),
1047
- react: types.react,
1048
- showClear: VueTypes.bool.def(true),
1049
- showDistinctSuggestions: VueTypes.bool.def(true),
1050
- showFilter: VueTypes.bool.def(true),
1051
- showIcon: VueTypes.bool.def(true),
1052
- title: types.title,
1053
- theme: types.style,
1054
- URLParams: VueTypes.bool.def(false),
1055
- strictSelection: VueTypes.bool.def(false),
1056
- nestedField: types.string,
1057
- enablePredictiveSuggestions: VueTypes.bool.def(false),
1058
- recentSearchesIcon: VueTypes.any,
1059
- popularSearchesIcon: VueTypes.any,
1060
- // mic props
1061
- showVoiceSearch: VueTypes.bool.def(false),
1062
- getMicInstance: types.func,
1063
- renderMic: types.func,
1064
- distinctField: types.string,
1065
- distinctFieldConfig: types.props,
1066
- //
1067
- focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])).def(['/']),
1068
- addonBefore: VueTypes.any,
1069
- addonAfter: VueTypes.any,
1070
- expandSuggestionsContainer: VueTypes.bool.def(true),
1071
- index: VueTypes.string
1072
- },
1073
- beforeMount: function beforeMount() {
1074
- if (this.$props.highlight) {
1075
- if (this.customHighlight && typeof this.customHighlight === 'function') {
1076
- this.setCustomHighlightOptions(this.componentId, this.customHighlight(this.$props));
1077
- }
1078
-
1079
- var queryOptions = DataSearch.highlightQuery(this.$props) || {};
1080
- this.queryOptions = _extends({}, queryOptions, this.getBasicQueryOptions());
1081
- this.setQueryOptions(this.$props.componentId, this.queryOptions);
1082
- } else {
1083
- this.queryOptions = this.getBasicQueryOptions();
1084
- this.setQueryOptions(this.$props.componentId, this.queryOptions);
1085
- }
1086
-
1087
- if (this.selectedValue) {
1088
- this.setValue(this.selectedValue, true);
1089
- } else if (this.$props.value) {
1090
- this.setValue(this.$props.value, true);
1091
- } else if (this.$props.defaultValue) {
1092
- this.setValue(this.$props.defaultValue, true);
1093
- }
1094
- },
1095
- mounted: function mounted() {
1096
- this.listenForFocusShortcuts();
1097
- },
1098
- watch: {
1099
- highlight: function highlight() {
1100
- this.updateQueryOptions();
1101
- },
1102
- dataField: function dataField() {
1103
- this.updateQueryOptions();
1104
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1105
- },
1106
- highlightField: function highlightField() {
1107
- this.updateQueryOptions();
1108
- },
1109
- fieldWeights: function fieldWeights() {
1110
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1111
- },
1112
- fuzziness: function fuzziness() {
1113
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1114
- },
1115
- queryFormat: function queryFormat() {
1116
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1117
- },
1118
- defaultValue: function defaultValue(newVal) {
1119
- this.setValue(newVal, true, this.$props);
1120
- },
1121
- value: function value(newVal, oldVal) {
1122
- if (!isEqual(newVal, oldVal)) {
1123
- this.setValue(newVal, true, this.$props, undefined, false);
1124
- }
1125
- },
1126
- defaultQuery: function defaultQuery(newVal, oldVal) {
1127
- if (!isQueryIdentical(newVal, oldVal, this.$data.currentValue, this.$props)) {
1128
- this.updateDefaultQueryHandler(this.$data.currentValue, this.$props);
1129
- }
1130
- },
1131
- customQuery: function customQuery(newVal, oldVal) {
1132
- if (!isQueryIdentical(newVal, oldVal, this.$data.currentValue, this.$props)) {
1133
- this.updateQueryHandler(this.componentId, this.$data.currentValue, this.$props);
1134
- }
1135
- },
1136
- suggestions: function suggestions(newVal) {
1137
- if (Array.isArray(newVal) && this.$data.currentValue.trim().length) {
1138
- // shallow check allows us to set suggestions even if the next set
1139
- // of suggestions are same as the current one
1140
- this.$emit('suggestions', newVal);
1141
- this.normalizedSuggestions = this.onSuggestions(newVal);
1142
- }
1143
- },
1144
- selectedValue: function selectedValue(newVal, oldVal) {
1145
- if (oldVal !== newVal && this.$data.currentValue !== newVal) {
1146
- if (!newVal && this.$data.currentValue) {
1147
- // selected value is cleared, call onValueSelected
1148
- this.onValueSelectedHandler('', causes.CLEAR_VALUE);
1149
- }
1150
-
1151
- this.setValue(newVal || '', true, this.$props);
1152
- }
1153
- },
1154
- focusShortcuts: function focusShortcuts() {
1155
- this.listenForFocusShortcuts();
1156
- }
1157
- },
1158
- methods: {
1159
- handleText: function handleText(value) {
1160
- if (this.$props.autosuggest) {
1161
- this.updateDefaultQueryHandler(value, this.$props);
1162
- } else {
1163
- this.updateQueryHandler(this.$props.componentId, value, this.$props);
1164
- }
1165
- },
1166
- validateDataField: function validateDataField() {
1167
- var propName = 'dataField';
1168
- var componentName = DataSearch.name;
1169
- var props = this.$props;
1170
- var requiredError = propName + " supplied to " + componentName + " is required. Validation failed.";
1171
- var propValue = props[propName];
1172
-
1173
- if (!this.enableAppbase) {
1174
- if (!propValue) {
1175
- console.error(requiredError);
1176
- return;
1177
- }
1178
-
1179
- if (typeof propValue !== 'string' && typeof propValue !== 'object' && !Array.isArray(propValue)) {
1180
- console.error("Invalid " + propName + " supplied to " + componentName + ". Validation failed.");
1181
- return;
1182
- }
1183
-
1184
- if (Array.isArray(propValue) && propValue.length === 0) {
1185
- console.error(requiredError);
1186
- }
1187
- }
1188
- },
1189
- updateQueryOptions: function updateQueryOptions() {
1190
- if (this.customHighlight && typeof this.customHighlight === 'function') {
1191
- this.setCustomHighlightOptions(this.componentId, this.customHighlight(this.$props));
1192
- }
1193
-
1194
- var queryOptions = DataSearch.highlightQuery(this.$props) || {};
1195
- this.queryOptions = _extends({}, queryOptions, this.getBasicQueryOptions());
1196
- this.setQueryOptions(this.$props.componentId, this.queryOptions);
1197
- },
1198
- getComponent: function getComponent$1(downshiftProps, isQuerySuggestionsRender) {
1199
- if (downshiftProps === void 0) {
1200
- downshiftProps = {};
1201
- }
1202
-
1203
- if (isQuerySuggestionsRender === void 0) {
1204
- isQuerySuggestionsRender = false;
1205
- }
1206
-
1207
- var currentValue = this.$data.currentValue;
1208
- var data = {
1209
- error: this.error,
1210
- loading: this.isLoading,
1211
- downshiftProps: downshiftProps,
1212
- data: this.suggestionsList,
1213
- promotedData: this.promotedResults,
1214
- aggregationData: this.aggregationData,
1215
- rawData: this.rawData,
1216
- customData: this.customData,
1217
- value: currentValue,
1218
- triggerClickAnalytics: this.triggerClickAnalytics,
1219
- resultStats: this.stats,
1220
- querySuggestions: this.normalizedPopularSuggestions,
1221
- popularSuggestions: this.normalizedPopularSuggestions
1222
- };
1223
-
1224
- if (isQuerySuggestionsRender) {
1225
- return getQuerySuggestionsComponent({
1226
- downshiftProps: downshiftProps,
1227
- data: this.normalizedPopularSuggestions,
1228
- value: currentValue,
1229
- loading: this.isLoading,
1230
- error: this.error
1231
- }, this);
1232
- }
1233
-
1234
- return getComponent(data, this);
1235
- },
1236
- // returns size and aggs property
1237
- getBasicQueryOptions: function getBasicQueryOptions() {
1238
- var aggregationField = this.$props.aggregationField;
1239
- var queryOptions = getQueryOptions(this.$props);
1240
-
1241
- if (aggregationField) {
1242
- queryOptions.aggs = getCompositeAggsQuery({
1243
- props: this.$props,
1244
- showTopHits: true
1245
- }).aggs;
1246
- }
1247
-
1248
- return queryOptions;
1249
- },
1250
- onSuggestions: function onSuggestions(results) {
1251
- return handleOnSuggestions(results, this.$data.currentValue, this);
1252
- },
1253
- handleSearchIconClick: function handleSearchIconClick() {
1254
- var currentValue = this.currentValue;
1255
-
1256
- if (currentValue.trim()) {
1257
- this.isPending = false;
1258
- this.setValue(currentValue, true);
1259
- this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
1260
- }
1261
- },
1262
- setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen) {
1263
- var _this = this;
1264
-
1265
- if (isDefaultValue === void 0) {
1266
- isDefaultValue = false;
1267
- }
1268
-
1269
- if (props === void 0) {
1270
- props = this.$props;
1271
- }
1272
-
1273
- if (toggleIsOpen === void 0) {
1274
- toggleIsOpen = true;
1275
- }
1276
-
1277
- var performUpdate = function performUpdate() {
1278
- // Refresh recent searches when value becomes empty
1279
- if (!value && _this.currentValue && _this.enableRecentSearches) {
1280
- _this.getRecentSearches();
1281
- }
1282
-
1283
- _this.currentValue = value;
1284
-
1285
- if (isDefaultValue) {
1286
- if (_this.$props.autosuggest) {
1287
- if (toggleIsOpen) {
1288
- _this.isOpen = false;
1289
- }
1290
-
1291
- _this.updateDefaultQueryHandler(value, _this.$props);
1292
- } // in case of strict selection only SUGGESTION_SELECT should be able
1293
- // to set the query otherwise the value should reset
1294
-
1295
-
1296
- if (props.strictSelection) {
1297
- if (cause === causes.SUGGESTION_SELECT || value === '') {
1298
- _this.updateQueryHandler(props.componentId, value, props);
1299
- } else {
1300
- _this.setValue('', true);
1301
- }
1302
- } else {
1303
- _this.updateQueryHandler(props.componentId, value, props);
1304
- }
1305
- } else {
1306
- // debounce for handling text while typing
1307
- _this.handleTextChange(value);
1308
- }
1309
-
1310
- _this.$emit('valueChange', value);
1311
-
1312
- _this.$emit('value-change', value); // Set the already fetched suggestions if query is same as used last to fetch the hits
1313
-
1314
-
1315
- if (value === _this.lastUsedQuery) {
1316
- _this.suggestions = _this.onSuggestions(_this.suggestions); // invoke on suggestions
1317
-
1318
- _this.$emit('suggestions', _this.suggestions);
1319
- } else if (!value) {
1320
- // reset suggestions
1321
- _this.suggestions = []; // invoke on suggestions
1322
-
1323
- _this.$emit('suggestions', _this.suggestions);
1324
- }
1325
- };
1326
-
1327
- checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1328
- },
1329
- updateDefaultQueryHandler: function updateDefaultQueryHandler(value, props) {
1330
- var defaultQueryOptions;
1331
- var query = DataSearch.defaultQuery(value, props);
1332
-
1333
- if (this.defaultQuery) {
1334
- var defaultQueryToBeSet = this.defaultQuery(value, props) || {};
1335
- var defaultQueryObj = extractQueryFromCustomQuery(defaultQueryToBeSet);
1336
-
1337
- if (defaultQueryObj) {
1338
- query = defaultQueryObj;
1339
- }
1340
-
1341
- defaultQueryOptions = getOptionsForCustomQuery(defaultQueryToBeSet); // Update calculated default query in store
1342
-
1343
- updateDefaultQuery(props.componentId, this.setDefaultQuery, props, value);
1344
- }
1345
-
1346
- this.setQueryOptions(this.internalComponent, _extends({}, this.queryOptions, defaultQueryOptions), false);
1347
- this.updateQuery({
1348
- componentId: this.internalComponent,
1349
- query: query,
1350
- value: value,
1351
- componentType: componentTypes.dataSearch
1352
- });
1353
- },
1354
- updateQueryHandler: function updateQueryHandler(componentId, value, props) {
1355
- var customQuery = props.customQuery,
1356
- filterLabel = props.filterLabel,
1357
- showFilter = props.showFilter,
1358
- URLParams = props.URLParams;
1359
- var customQueryOptions;
1360
- var defaultQueryTobeSet = DataSearch.defaultQuery(value, props);
1361
- var query = defaultQueryTobeSet;
1362
-
1363
- if (customQuery) {
1364
- var customQueryTobeSet = customQuery(value, props);
1365
- var queryTobeSet = extractQueryFromCustomQuery(customQueryTobeSet);
1366
-
1367
- if (queryTobeSet) {
1368
- query = queryTobeSet;
1369
- }
1370
-
1371
- customQueryOptions = getOptionsForCustomQuery(customQueryTobeSet);
1372
- updateCustomQuery(props.componentId, this.setCustomQuery, props, value);
1373
- this.setQueryOptions(componentId, _extends({}, this.queryOptions, customQueryOptions), false);
1374
- }
1375
-
1376
- if (!this.isPending) {
1377
- this.updateQuery({
1378
- componentId: componentId,
1379
- query: query,
1380
- value: value,
1381
- label: filterLabel,
1382
- showFilter: showFilter,
1383
- URLParams: URLParams,
1384
- componentType: 'DATASEARCH'
1385
- });
1386
- }
1387
- },
1388
- // need to review
1389
- handleFocus: function handleFocus(event) {
1390
- this.isOpen = true;
1391
- this.$emit('focus', event);
1392
- },
1393
- handleVoiceResults: function handleVoiceResults(_ref) {
1394
- var results = _ref.results;
1395
-
1396
- if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
1397
- this.isPending = false;
1398
- this.setValue(results[0][0].transcript.trim(), true);
1399
- }
1400
- },
1401
- triggerQuery: function triggerQuery(_temp) {
1402
- var _ref2 = _temp === void 0 ? false : _temp,
1403
- _ref2$isOpen = _ref2.isOpen,
1404
- isOpen = _ref2$isOpen === void 0 ? false : _ref2$isOpen;
1405
-
1406
- var value = this.$props.value;
1407
-
1408
- if (value !== undefined) {
1409
- this.isPending = false;
1410
- this.setValue(this.$props.value, !isOpen);
1411
- }
1412
- },
1413
- triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
1414
- // click analytics would only work client side and after javascript loads
1415
- var docId = documentId;
1416
-
1417
- if (!docId) {
1418
- var hitData = this.suggestionsList.find(function (hit) {
1419
- return hit._click_id === searchPosition;
1420
- });
1421
-
1422
- if (hitData && hitData.source && hitData.source._id) {
1423
- docId = hitData.source._id;
1424
- }
1425
- }
1426
-
1427
- this.recordSuggestionClick(searchPosition, docId);
1428
- },
1429
- clearValue: function clearValue() {
1430
- this.isPending = false;
1431
- this.setValue('', true);
1432
- this.onValueSelectedHandler('', causes.CLEAR_VALUE);
1433
- },
1434
- handleKeyDown: function handleKeyDown(event, highlightedIndex) {
1435
- var value = this.$props.value;
1436
-
1437
- if (value !== undefined) {
1438
- this.isPending = true;
1439
- } // if a suggestion was selected, delegate the handling to suggestion handler
1440
-
1441
-
1442
- if (event.key === 'Enter' && highlightedIndex === null) {
1443
- this.setValue(event.target.value, true);
1444
- this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
1445
- } // Need to review
1446
-
1447
-
1448
- this.$emit('keyDown', event, this.triggerQuery);
1449
- this.$emit('key-down', event, this.triggerQuery);
1450
- },
1451
- onInputChange: function onInputChange(e) {
1452
- var inputValue = e.target.value;
1453
-
1454
- if (!this.$data.isOpen) {
1455
- this.isOpen = true;
1456
- }
1457
-
1458
- var value = this.$props.value;
1459
-
1460
- if (value === undefined) {
1461
- this.setValue(inputValue);
1462
- } else {
1463
- this.isPending = true;
1464
- this.$emit('change', inputValue, this.triggerQuery, e);
1465
- }
1466
- },
1467
- onSuggestionSelected: function onSuggestionSelected(suggestion) {
1468
- var value = this.$props.value; // Record analytics for selected suggestions
1469
-
1470
- this.triggerClickAnalytics(suggestion._click_id);
1471
-
1472
- if (value === undefined) {
1473
- this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT);
1474
- } else {
1475
- this.isPending = false;
1476
- this.$emit('change', suggestion.value, this.triggerQuery);
1477
- }
1478
-
1479
- this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
1480
- },
1481
- onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
1482
- if (currentValue === void 0) {
1483
- currentValue = this.$data.currentValue;
1484
- }
1485
-
1486
- for (var _len = arguments.length, cause = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1487
- cause[_key - 1] = arguments[_key];
1488
- }
1489
-
1490
- this.$emit.apply(this, ['valueSelected', currentValue].concat(cause));
1491
- this.$emit.apply(this, ['value-selected', currentValue].concat(cause));
1492
- },
1493
- handleStateChange: function handleStateChange(changes) {
1494
- var isOpen = changes.isOpen;
1495
- this.isOpen = isOpen;
1496
- },
1497
- getBackgroundColor: function getBackgroundColor(highlightedIndex, index) {
1498
- var isDark = this.themePreset === 'dark';
1499
-
1500
- if (isDark) {
1501
- return highlightedIndex === index ? '#555' : '#424242';
1502
- }
1503
-
1504
- return highlightedIndex === index ? '#eee' : '#fff';
1505
- },
1506
- renderIcon: function renderIcon() {
1507
- var h = this.$createElement;
1508
-
1509
- if (this.$props.showIcon) {
1510
- return this.$props.icon || h(SearchSvg);
1511
- }
1512
-
1513
- return null;
1514
- },
1515
- renderErrorComponent: function renderErrorComponent() {
1516
- var h = this.$createElement;
1517
- var renderError = this.$scopedSlots.renderError || this.$props.renderError;
1518
-
1519
- if (this.error && renderError && this.$data.currentValue && !this.isLoading) {
1520
- return h(SuggestionWrapper, {
1521
- "attrs": {
1522
- "innerClass": this.$props.innerClass,
1523
- "innerClassName": "error",
1524
- "theme": this.theme,
1525
- "themePreset": this.themePreset
1526
- }
1527
- }, [isFunction(renderError) ? renderError(this.error) : renderError]);
1528
- }
1529
-
1530
- return null;
1531
- },
1532
- renderCancelIcon: function renderCancelIcon() {
1533
- var h = this.$createElement;
1534
-
1535
- if (this.$props.showClear) {
1536
- return this.$props.clearIcon || h(CancelSvg);
1537
- }
1538
-
1539
- return null;
1540
- },
1541
- renderNoSuggestions: function renderNoSuggestions(finalSuggestionsList) {
1542
- if (finalSuggestionsList === void 0) {
1543
- finalSuggestionsList = [];
1544
- }
1545
-
1546
- var h = this.$createElement;
1547
- var _this$$props2 = this.$props,
1548
- theme = _this$$props2.theme,
1549
- innerClass = _this$$props2.innerClass;
1550
- var renderNoSuggestion = this.$scopedSlots.renderNoSuggestion || this.$props.renderNoSuggestion;
1551
- var renderError = this.$scopedSlots.renderError || this.$props.renderError;
1552
- var _this$$data = this.$data,
1553
- isOpen = _this$$data.isOpen,
1554
- currentValue = _this$$data.currentValue;
1555
-
1556
- if (renderNoSuggestion && isOpen && !finalSuggestionsList.length && !this.isLoading && currentValue && !(renderError && this.error)) {
1557
- return h(SuggestionWrapper, {
1558
- "attrs": {
1559
- "innerClass": innerClass,
1560
- "themePreset": this.themePreset,
1561
- "theme": theme,
1562
- "innerClassName": "noSuggestion"
1563
- },
1564
- "scopedSlots": {
1565
- "default": function _default() {
1566
- return typeof renderNoSuggestion === 'function' ? renderNoSuggestion(currentValue) : renderNoSuggestion;
1567
- }
1568
- }
1569
- });
1570
- }
1571
-
1572
- return null;
1573
- },
1574
- renderInputAddonBefore: function renderInputAddonBefore() {
1575
- var h = this.$createElement;
1576
- var addonBefore = this.$scopedSlots.addonBefore;
1577
-
1578
- if (addonBefore) {
1579
- return h(InputAddon, [addonBefore()]);
1580
- }
1581
-
1582
- return null;
1583
- },
1584
- renderInputAddonAfter: function renderInputAddonAfter() {
1585
- var h = this.$createElement;
1586
- var addonAfter = this.$scopedSlots.addonAfter;
1587
-
1588
- if (addonAfter) {
1589
- return h(InputAddon, [addonAfter()]);
1590
- }
1591
-
1592
- return null;
1593
- },
1594
- renderIcons: function renderIcons() {
1595
- var h = this.$createElement;
1596
- var _this$$props3 = this.$props,
1597
- iconPosition = _this$$props3.iconPosition,
1598
- showClear = _this$$props3.showClear,
1599
- innerClass = _this$$props3.innerClass,
1600
- getMicInstance = _this$$props3.getMicInstance,
1601
- showVoiceSearch = _this$$props3.showVoiceSearch,
1602
- showIcon = _this$$props3.showIcon;
1603
- var renderMic = this.$scopedSlots.renderMic || this.$props.renderMic;
1604
- var currentValue = this.$data.currentValue;
1605
- return h("div", [h(IconGroup, {
1606
- "attrs": {
1607
- "groupPosition": "right",
1608
- "positionType": "absolute"
1609
- }
1610
- }, [currentValue && showClear && h(IconWrapper, {
1611
- "on": {
1612
- "click": this.clearValue
1613
- },
1614
- "attrs": {
1615
- "showIcon": showIcon,
1616
- "isClearIcon": true
1617
- }
1618
- }, [this.renderCancelIcon()]), showVoiceSearch && h(Mic, {
1619
- "attrs": {
1620
- "getInstance": getMicInstance,
1621
- "render": renderMic,
1622
- "handleResult": this.handleVoiceResults,
1623
- "className": getClassName$1(innerClass, 'mic') || null
1624
- }
1625
- }), iconPosition === 'right' && showIcon && h(IconWrapper, {
1626
- "on": {
1627
- "click": this.handleSearchIconClick
1628
- }
1629
- }, [this.renderIcon()])]), h(IconGroup, {
1630
- "attrs": {
1631
- "groupPosition": "left",
1632
- "positionType": "absolute"
1633
- }
1634
- }, [iconPosition === 'left' && showIcon && h(IconWrapper, {
1635
- "on": {
1636
- "click": this.handleSearchIconClick
1637
- }
1638
- }, [this.renderIcon()])])]);
1639
- },
1640
- focusSearchBox: function focusSearchBox(event) {
1641
- var _this$$refs, _this$$refs$this$$pro;
1642
-
1643
- var elt = event.target || event.srcElement;
1644
- var tagName = elt.tagName;
1645
-
1646
- if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
1647
- // already in an input
1648
- return;
1649
- }
1650
-
1651
- (_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
1652
- },
1653
- listenForFocusShortcuts: function listenForFocusShortcuts() {
1654
- var _this2 = this;
1655
-
1656
- var _this$$props$focusSho = this.$props.focusShortcuts,
1657
- focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
1658
-
1659
- if (isEmpty(focusShortcuts)) {
1660
- return;
1661
- }
1662
-
1663
- var shortcutsString = parseFocusShortcuts(focusShortcuts).join(','); // handler for alphabets and other key combinations
1664
-
1665
- hotkeys(shortcutsString, // eslint-disable-next-line no-unused-vars
1666
-
1667
- /* eslint-disable no-shadow */
1668
- function (event, handler) {
1669
- // Prevent the default refresh event under WINDOWS system
1670
- event.preventDefault();
1671
-
1672
- _this2.focusSearchBox(event);
1673
- }); // if one of modifier keys are used, they are handled below
1674
-
1675
- hotkeys('*', function (event) {
1676
- var modifierKeys = extractModifierKeysFromFocusShortcuts(focusShortcuts);
1677
- if (modifierKeys.length === 0) return;
1678
-
1679
- for (var index = 0; index < modifierKeys.length; index += 1) {
1680
- var element = modifierKeys[index];
1681
-
1682
- if (hotkeys[element]) {
1683
- _this2.focusSearchBox(event);
1684
-
1685
- break;
1686
- }
1687
- }
1688
- });
1689
- }
1690
- },
1691
- render: function render() {
1692
- var _this3 = this;
1693
-
1694
- var h = arguments[0];
1695
- var _this$$props4 = this.$props,
1696
- theme = _this$$props4.theme,
1697
- size = _this$$props4.size,
1698
- expandSuggestionsContainer = _this$$props4.expandSuggestionsContainer;
1699
- var _this$$scopedSlots = this.$scopedSlots,
1700
- recentSearchesIcon = _this$$scopedSlots.recentSearchesIcon,
1701
- popularSearchesIcon = _this$$scopedSlots.popularSearchesIcon;
1702
- var hasSuggestions = this.currentValue ? this.suggestionsList.length || this.topSuggestions.length : this.defaultSearchSuggestions.length;
1703
- return h(Container, {
1704
- "class": this.$props.className
1705
- }, [this.$props.title && h(Title, {
1706
- "class": getClassName$1(this.$props.innerClass, 'title') || ''
1707
- }, [this.$props.title]), this.$props.defaultSuggestions || this.$props.autosuggest ? h(Downshift, {
1708
- "attrs": {
1709
- "id": this.$props.componentId + "-downshift",
1710
- "handleChange": this.onSuggestionSelected,
1711
- "handleMouseup": this.handleStateChange,
1712
- "isOpen": this.$data.isOpen
1713
- },
1714
- "scopedSlots": {
1715
- "default": function _default(_ref3) {
1716
- var getInputEvents = _ref3.getInputEvents,
1717
- getInputProps = _ref3.getInputProps,
1718
- getItemProps = _ref3.getItemProps,
1719
- getItemEvents = _ref3.getItemEvents,
1720
- isOpen = _ref3.isOpen,
1721
- highlightedIndex = _ref3.highlightedIndex,
1722
- setHighlightedIndex = _ref3.setHighlightedIndex;
1723
-
1724
- var renderSuggestionsContainer = function renderSuggestionsContainer() {
1725
- return h("div", [_this3.hasCustomRenderer && _this3.getComponent({
1726
- isOpen: isOpen,
1727
- getItemProps: getItemProps,
1728
- getItemEvents: getItemEvents,
1729
- highlightedIndex: highlightedIndex
1730
- }), _this3.renderErrorComponent(), !_this3.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1731
- "class": suggestions(_this3.themePreset, theme) + " " + getClassName$1(_this3.$props.innerClass, 'list')
1732
- }, [_this3.suggestionsList.slice(0, size || 10).map(function (item, index) {
1733
- return h("li", {
1734
- "domProps": _extends({}, getItemProps({
1735
- item: item
1736
- })),
1737
- "on": _extends({}, getItemEvents({
1738
- item: item
1739
- })),
1740
- "key": index + 1 + "-" + item.value,
1741
- "style": {
1742
- backgroundColor: _this3.getBackgroundColor(highlightedIndex, index)
1743
- }
1744
- }, [h(SuggestionItem, {
1745
- "attrs": {
1746
- "currentValue": _this3.currentValue,
1747
- "suggestion": item
1748
- }
1749
- })]);
1750
- }), _this3.defaultSearchSuggestions.map(function (sugg, index) {
1751
- return h("li", {
1752
- "domProps": _extends({}, getItemProps({
1753
- item: sugg
1754
- })),
1755
- "on": _extends({}, getItemEvents({
1756
- item: sugg
1757
- })),
1758
- "key": _this3.suggestionsList.length + index + 1 + "-" + sugg.value,
1759
- "style": {
1760
- backgroundColor: _this3.getBackgroundColor(highlightedIndex, _this3.suggestionsList.length + index),
1761
- justifyContent: 'flex-start'
1762
- }
1763
- }, [h("div", {
1764
- "style": {
1765
- padding: '0 10px 0 0'
1766
- }
1767
- }, [sugg.source && sugg.source._recent_search && h(CustomSvg, {
1768
- "attrs": {
1769
- "className": getClassName$1(_this3.$props.innerClass, 'recent-search-icon') || null,
1770
- "icon": recentSearchesIcon,
1771
- "type": "recent-search-icon"
1772
- }
1773
- }), sugg.source && sugg.source._popular_suggestion && h(CustomSvg, {
1774
- "attrs": {
1775
- "className": getClassName$1(_this3.$props.innerClass, 'popular-search-icon') || null,
1776
- "icon": popularSearchesIcon,
1777
- "type": "popular-search-icon"
1778
- }
1779
- })]), h(SuggestionItem, {
1780
- "attrs": {
1781
- "currentValue": _this3.currentValue,
1782
- "suggestion": sugg
1783
- }
1784
- })]);
1785
- }), hasQuerySuggestionsRenderer(_this3) ? _this3.getComponent({
1786
- isOpen: isOpen,
1787
- getItemProps: getItemProps,
1788
- getItemEvents: getItemEvents,
1789
- highlightedIndex: highlightedIndex
1790
- }, true) : _this3.topSuggestions.map(function (sugg, index) {
1791
- return h("li", {
1792
- "domProps": _extends({}, getItemProps({
1793
- item: sugg
1794
- })),
1795
- "on": _extends({}, getItemEvents({
1796
- item: sugg
1797
- })),
1798
- "key": _this3.suggestionsList.length + index + 1 + "-" + sugg.value,
1799
- "style": {
1800
- backgroundColor: _this3.getBackgroundColor(highlightedIndex, _this3.suggestionsList.length + index),
1801
- justifyContent: 'flex-start'
1802
- }
1803
- }, [h("div", {
1804
- "style": {
1805
- padding: '0 10px 0 0'
1806
- }
1807
- }, [h(CustomSvg, {
1808
- "attrs": {
1809
- "className": getClassName$1(_this3.$props.innerClass, 'popular-search-icon') || null,
1810
- "icon": popularSearchesIcon,
1811
- "type": "popular-search-icon"
1812
- }
1813
- })]), h(SuggestionItem, {
1814
- "attrs": {
1815
- "currentValue": _this3.currentValue,
1816
- "suggestion": sugg
1817
- }
1818
- })]);
1819
- })]) : _this3.renderNoSuggestions(_this3.suggestionsList)]);
1820
- };
1821
-
1822
- return h("div", {
1823
- "class": suggestionsContainer
1824
- }, [h(InputGroup, [_this3.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1825
- "attrs": {
1826
- "id": _this3.$props.componentId + "-input",
1827
- "showIcon": _this3.$props.showIcon,
1828
- "showClear": _this3.$props.showClear,
1829
- "iconPosition": _this3.$props.iconPosition,
1830
- "placeholder": _this3.$props.placeholder,
1831
- "autoFocus": _this3.$props.autoFocus,
1832
- "themePreset": _this3.themePreset,
1833
- "autocomplete": "off"
1834
- },
1835
- "ref": _this3.$props.innerRef,
1836
- "class": getClassName$1(_this3.$props.innerClass, 'input'),
1837
- "on": _extends({}, getInputEvents({
1838
- onInput: _this3.onInputChange,
1839
- onBlur: function onBlur(e) {
1840
- _this3.$emit('blur', e, _this3.triggerQuery);
1841
- },
1842
- onFocus: _this3.handleFocus,
1843
- onKeyPress: function onKeyPress(e) {
1844
- _this3.$emit('keyPress', e, _this3.triggerQuery);
1845
-
1846
- _this3.$emit('key-press', e, _this3.triggerQuery);
1847
- },
1848
- onKeyDown: function onKeyDown(e) {
1849
- return _this3.handleKeyDown(e, highlightedIndex);
1850
- },
1851
- onKeyUp: function onKeyUp(e) {
1852
- _this3.$emit('keyUp', e, _this3.triggerQuery);
1853
-
1854
- _this3.$emit('key-up', e, _this3.triggerQuery);
1855
- },
1856
- onClick: function onClick() {
1857
- setHighlightedIndex(null);
1858
- }
1859
- })),
1860
- "domProps": _extends({}, getInputProps({
1861
- value: _this3.$data.currentValue === null ? '' : _this3.$data.currentValue
1862
- }))
1863
- }), _this3.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this3.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer()]);
1864
- }
1865
- }
1866
- }) : h("div", {
1867
- "class": suggestionsContainer
1868
- }, [h(InputGroup, [this.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1869
- "class": getClassName$1(this.$props.innerClass, 'input') || '',
1870
- "attrs": {
1871
- "placeholder": this.$props.placeholder,
1872
- "iconPosition": this.$props.iconPosition,
1873
- "showIcon": this.$props.showIcon,
1874
- "showClear": this.$props.showClear,
1875
- "themePreset": this.themePreset
1876
- },
1877
- "on": _extends({}, {
1878
- blur: function blur(e) {
1879
- _this3.$emit('blur', e, _this3.triggerQuery);
1880
- },
1881
- keypress: function keypress(e) {
1882
- _this3.$emit('keyPress', e, _this3.triggerQuery);
1883
-
1884
- _this3.$emit('key-press', e, _this3.triggerQuery);
1885
- },
1886
- input: this.onInputChange,
1887
- focus: function focus(e) {
1888
- _this3.$emit('focus', e, _this3.triggerQuery);
1889
- },
1890
- keydown: function keydown(e) {
1891
- _this3.$emit('keyDown', e, _this3.triggerQuery);
1892
-
1893
- _this3.$emit('key-down', e, _this3.triggerQuery);
1894
- },
1895
- keyup: function keyup(e) {
1896
- _this3.$emit('keyUp', e, _this3.triggerQuery);
1897
-
1898
- _this3.$emit('key-up', e, _this3.triggerQuery);
1899
- }
1900
- }),
1901
- "domProps": _extends({}, {
1902
- autofocus: this.$props.autoFocus,
1903
- value: this.$data.currentValue ? this.$data.currentValue : ''
1904
- }),
1905
- "ref": this.$props.innerRef
1906
- }), this.renderIcons()]), this.renderInputAddonAfter()])])]);
1907
- },
1908
- destroyed: function destroyed() {
1909
- document.removeEventListener('keydown', this.onKeyDown);
1910
- }
1911
- };
1912
-
1913
- DataSearch.defaultQuery = function (value, props) {
1914
- var finalQuery = null;
1915
-
1916
- if (value) {
1917
- var fields = normalizeDataField(props.dataField, props.fieldWeights);
1918
- finalQuery = {
1919
- bool: {
1920
- should: DataSearch.shouldQuery(value, fields, props),
1921
- minimum_should_match: '1'
1922
- }
1923
- };
1924
- }
1925
-
1926
- if (value === '') {
1927
- finalQuery = null;
1928
- }
1929
-
1930
- if (finalQuery && props.nestedField) {
1931
- return {
1932
- query: {
1933
- nested: {
1934
- path: props.nestedField,
1935
- query: finalQuery
1936
- }
1937
- }
1938
- };
1939
- }
1940
-
1941
- return finalQuery;
1942
- };
1943
-
1944
- DataSearch.shouldQuery = function (value, dataFields, props) {
1945
- var finalQuery = [];
1946
- var phrasePrefixFields = [];
1947
- var fields = dataFields.map(function (dataField) {
1948
- var queryField = "" + dataField.field + (dataField.weight ? "^" + dataField.weight : '');
1949
-
1950
- if (!(dataField.field.endsWith('.keyword') || dataField.field.endsWith('.autosuggest') || dataField.field.endsWith('.search'))) {
1951
- phrasePrefixFields.push(queryField);
1952
- }
1953
-
1954
- return queryField;
1955
- });
1956
-
1957
- if (props.searchOperators || props.queryString) {
1958
- return {
1959
- query: value,
1960
- fields: fields,
1961
- default_operator: props.queryFormat
1962
- };
1963
- }
1964
-
1965
- if (props.queryFormat === 'and') {
1966
- finalQuery.push({
1967
- multi_match: {
1968
- query: value,
1969
- fields: fields,
1970
- type: 'cross_fields',
1971
- operator: 'and'
1972
- }
1973
- });
1974
- finalQuery.push({
1975
- multi_match: {
1976
- query: value,
1977
- fields: fields,
1978
- type: 'phrase',
1979
- operator: 'and'
1980
- }
1981
- });
1982
-
1983
- if (phrasePrefixFields.length > 0) {
1984
- finalQuery.push({
1985
- multi_match: {
1986
- query: value,
1987
- fields: phrasePrefixFields,
1988
- type: 'phrase_prefix',
1989
- operator: 'and'
1990
- }
1991
- });
1992
- }
1993
-
1994
- return finalQuery;
1995
- }
1996
-
1997
- finalQuery.push({
1998
- multi_match: {
1999
- query: value,
2000
- fields: fields,
2001
- type: 'best_fields',
2002
- operator: 'or',
2003
- fuzziness: props.fuzziness ? props.fuzziness : 0
2004
- }
2005
- });
2006
- finalQuery.push({
2007
- multi_match: {
2008
- query: value,
2009
- fields: fields,
2010
- type: 'phrase',
2011
- operator: 'or'
2012
- }
2013
- });
2014
-
2015
- if (phrasePrefixFields.length > 0) {
2016
- finalQuery.push({
2017
- multi_match: {
2018
- query: value,
2019
- fields: phrasePrefixFields,
2020
- type: 'phrase_prefix',
2021
- operator: 'or'
2022
- }
2023
- });
2024
- }
2025
-
2026
- return finalQuery;
2027
- };
2028
-
2029
- DataSearch.highlightQuery = function (props) {
2030
- if (props.customHighlight) {
2031
- return props.customHighlight(props);
2032
- }
2033
-
2034
- if (!props.highlight) {
2035
- return null;
2036
- }
2037
-
2038
- var fields = {};
2039
- var highlightField = props.highlightField ? props.highlightField : props.dataField;
2040
-
2041
- if (typeof highlightField === 'string') {
2042
- fields[highlightField] = {};
2043
- } else if (Array.isArray(highlightField)) {
2044
- highlightField.forEach(function (item) {
2045
- fields[item] = {};
2046
- });
2047
- }
2048
-
2049
- return {
2050
- highlight: _extends({
2051
- pre_tags: ['<mark>'],
2052
- post_tags: ['</mark>'],
2053
- fields: fields
2054
- }, props.highlightField && {
2055
- require_field_match: false
2056
- })
2057
- };
2058
- };
2059
-
2060
- DataSearch.hasInternalComponent = function () {
2061
- return true;
2062
- };
2063
-
2064
- var mapStateToProps = function mapStateToProps(state, props) {
2065
- return {
2066
- selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
2067
- suggestions: state.hits[props.componentId] && state.hits[props.componentId].hits,
2068
- rawData: state.rawData[props.componentId],
2069
- aggregationData: state.compositeAggregations[props.componentId] || [],
2070
- isLoading: !!state.isLoading[props.componentId + "_active"],
2071
- themePreset: state.config.themePreset,
2072
- error: state.error[props.componentId],
2073
- analytics: state.analytics,
2074
- enableAppbase: state.config.enableAppbase,
2075
- headers: state.appbaseRef.headers,
2076
- promotedResults: state.promotedResults[props.componentId] || [],
2077
- customData: state.customData[props.componentId],
2078
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
2079
- total: state.hits[props.componentId] && state.hits[props.componentId].total,
2080
- hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
2081
- popularSuggestions: state.querySuggestions[props.componentId],
2082
- defaultPopularSuggestions: state.defaultPopularSuggestions[props.componentId],
2083
- componentProps: state.props[props.componentId],
2084
- lastUsedQuery: state.queryToHits[props.componentId],
2085
- recentSearches: state.recentSearches.data
2086
- };
2087
- };
2088
-
2089
- var mapDispatchToProps = {
2090
- setQueryOptions: setQueryOptions,
2091
- updateQuery: updateQuery,
2092
- setCustomQuery: setCustomQuery,
2093
- setDefaultQuery: setDefaultQuery,
2094
- setCustomHighlightOptions: setCustomHighlightOptions,
2095
- recordSuggestionClick: recordSuggestionClick,
2096
- loadPopularSuggestions: loadPopularSuggestions,
2097
- getRecentSearches: getRecentSearches
2098
- };
2099
- var DSConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(DataSearch), {
2100
- componentType: componentTypes.dataSearch,
2101
- internalComponent: DataSearch.hasInternalComponent()
2102
- });
2103
-
2104
- DataSearch.install = function (Vue) {
2105
- Vue.component(DataSearch.name, DSConnected);
2106
- }; // Add componentType for SSR
2107
-
2108
-
2109
- DataSearch.componentType = componentTypes.dataSearch;
2110
-
2111
- export default DataSearch;
21
+ import './Container-18b03fde.js';
22
+ import 'vue-highlight-words';