@appbaseio/reactivesearch-vue 3.0.0-rc.5.alpha.5 → 3.0.0-rc.6

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 +39803 -35283
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +32 -32
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{Button-d4da7470.js → Button-9e179864.js} +13 -6
  6. package/dist/cjs/{ComponentWrapper-9146d811.js → ComponentWrapper-0b9ffb1a.js} +3 -0
  7. package/dist/cjs/DropDown-aef75c14.js +702 -0
  8. package/dist/cjs/DynamicRangeSlider.js +1 -1
  9. package/dist/cjs/{Input-497be42a.js → Input-56eba499.js} +71 -1
  10. package/dist/cjs/MultiDropdownList.js +6 -6
  11. package/dist/cjs/MultiList.js +3 -3
  12. package/dist/cjs/MultiRange.js +2 -2
  13. package/dist/cjs/{Pagination-b953a80a.js → Pagination-58a0cf3f.js} +2 -2
  14. package/dist/cjs/RangeInput.js +3 -3
  15. package/dist/cjs/RangeSlider.js +2 -2
  16. package/dist/cjs/ReactiveBase.js +4 -4
  17. package/dist/cjs/ReactiveComponent.js +2 -2
  18. package/dist/cjs/ReactiveGoogleMap.js +6 -5
  19. package/dist/cjs/ReactiveList.js +4 -4
  20. package/dist/cjs/ResultCard.js +1 -1
  21. package/dist/cjs/ResultList.js +1 -1
  22. package/dist/cjs/SelectedFilters.js +3 -2
  23. package/dist/cjs/SingleDropdownList.js +6 -6
  24. package/dist/cjs/SingleList.js +3 -3
  25. package/dist/cjs/SingleRange.js +2 -2
  26. package/dist/cjs/ToggleButton.js +4 -3
  27. package/dist/cjs/index.js +14 -13
  28. package/dist/cjs/install-70991c13.js +3820 -0
  29. package/dist/cjs/install.js +9 -9
  30. package/dist/cjs/version.js +1 -1
  31. package/dist/cjs/{vueTypes-1bf00978.js → vueTypes-a5f1745e.js} +18 -0
  32. package/dist/es/{Button-fd869491.js → Button-c2ff5178.js} +13 -6
  33. package/dist/es/{ComponentWrapper-8a3c388d.js → ComponentWrapper-a2635cfc.js} +3 -0
  34. package/dist/es/DropDown-39fedff8.js +693 -0
  35. package/dist/es/DynamicRangeSlider.js +1 -1
  36. package/dist/es/{Input-f7499ef8.js → Input-11d211d2.js} +71 -2
  37. package/dist/es/MultiDropdownList.js +6 -6
  38. package/dist/es/MultiList.js +3 -3
  39. package/dist/es/MultiRange.js +2 -2
  40. package/dist/es/{Pagination-c2745bec.js → Pagination-ae401c33.js} +2 -2
  41. package/dist/es/RangeInput.js +3 -3
  42. package/dist/es/RangeSlider.js +2 -2
  43. package/dist/es/ReactiveBase.js +4 -4
  44. package/dist/es/ReactiveComponent.js +2 -2
  45. package/dist/es/ReactiveGoogleMap.js +6 -5
  46. package/dist/es/ReactiveList.js +4 -4
  47. package/dist/es/ResultCard.js +1 -1
  48. package/dist/es/ResultList.js +1 -1
  49. package/dist/es/SelectedFilters.js +3 -2
  50. package/dist/es/SingleDropdownList.js +6 -6
  51. package/dist/es/SingleList.js +3 -3
  52. package/dist/es/SingleRange.js +2 -2
  53. package/dist/es/ToggleButton.js +4 -3
  54. package/dist/es/index.js +11 -11
  55. package/dist/es/install-8296e8da.js +3812 -0
  56. package/dist/es/install.js +9 -9
  57. package/dist/es/version.js +1 -1
  58. package/dist/es/{vueTypes-f1923c72.js → vueTypes-09cab4d3.js} +18 -0
  59. package/package.json +7 -5
  60. package/dist/cjs/CancelSvg-ab0f8b23.js +0 -409
  61. package/dist/cjs/DropDown-e7125b72.js +0 -299
  62. package/dist/cjs/SearchBox.js +0 -1853
  63. package/dist/cjs/install-3c4520bf.js +0 -874
  64. package/dist/es/CancelSvg-e7ae49e9.js +0 -401
  65. package/dist/es/DropDown-13afb4d2.js +0 -295
  66. package/dist/es/SearchBox.js +0 -1847
  67. package/dist/es/install-ff8b0750.js +0 -868
@@ -1,1847 +0,0 @@
1
- import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { SEARCH_COMPONENTS_MODES, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
- import _transformOn from '@vue/babel-helper-vue-transform-on';
4
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
5
- import { createVNode, createTextVNode, defineComponent, isVNode, mergeProps } from 'vue';
6
- import VueTypes from 'vue-types';
7
- import { getQueryOptions, suggestionTypes } from '@appbaseio/reactivecore/lib/utils/helper';
8
- import { styled, createGlobalStyle } from '@appbaseio/vue-emotion';
9
- import { css } from '@emotion/css';
10
- import 'polished';
11
- import { B as Button } from './Button-fd869491.js';
12
- import { t as types } from './vueTypes-f1923c72.js';
13
- import '@appbaseio/reactivecore/lib/utils/transform';
14
- import 'redux';
15
- import { g as getComponent, h as hasCustomRenderer, f as decodeHtml, i as isQueryIdentical, u as updateDefaultQuery, j as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-882489e1.js';
16
- import { C as ComponentWrapper } from './ComponentWrapper-8a3c388d.js';
17
- import { P as PreferencesConsumer } from './PreferencesConsumer-b058d14e.js';
18
- import { T as Title } from './Title-863dfa42.js';
19
- import { F as Flex } from './Flex-25792bc3.js';
20
- import hotkeys from 'hotkeys-js';
21
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './CancelSvg-e7ae49e9.js';
22
- import { n as noSuggestions, s as suggestionsContainer, I as Input, a as suggestions } from './Input-f7499ef8.js';
23
- import 'compute-scroll-into-view';
24
- import { C as Container } from './Container-d00219f7.js';
25
- import Highlight from 'vue-highlight-words';
26
-
27
- var _templateObject;
28
- var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: stretch;\n width: 100%;\n"])));
29
- InputGroup.defaultProps = {
30
- className: 'input-group'
31
- };
32
-
33
- var _templateObject$1;
34
- 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"])));
35
- InputAddon.defaultProps = {
36
- className: 'input-addon'
37
- };
38
-
39
- var getClassName = helper.getClassName;
40
- var SuggestionWrapper = {
41
- name: 'SuggestionWrapper',
42
- props: {
43
- innerClassName: types.string,
44
- themePreset: types.themePreset,
45
- innerClass: types.style
46
- },
47
- render: function render() {
48
- var _this$$props = this.$props,
49
- themePreset = _this$$props.themePreset,
50
- innerClass = _this$$props.innerClass,
51
- innerClassName = _this$$props.innerClassName;
52
- return createVNode("div", {
53
- "class": noSuggestions(themePreset) + " " + getClassName(innerClass, innerClassName || '')
54
- }, [createVNode("li", null, [this.$slots["default"]()])]);
55
- }
56
- };
57
-
58
- var _templateObject$2;
59
- var highlightStyle = {
60
- fontWeight: 600,
61
- padding: 0,
62
- backgroundColor: 'transparent',
63
- color: 'inherit'
64
- };
65
- 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"])));
66
- var SuggestionItem = {
67
- name: 'SuggestionItem',
68
- props: {
69
- currentValue: types.string,
70
- suggestion: types.any
71
- },
72
- render: function render() {
73
- var _this = this;
74
- var _this$suggestion = this.suggestion,
75
- label = _this$suggestion.label,
76
- value = _this$suggestion.value,
77
- title = _this$suggestion.title,
78
- description = _this$suggestion.description,
79
- image = _this$suggestion.image,
80
- isPredictiveSuggestion = _this$suggestion.isPredictiveSuggestion,
81
- _suggestion_type = _this$suggestion._suggestion_type,
82
- _category = _this$suggestion._category;
83
- if (label) {
84
- // label has highest precedence
85
- return typeof label === 'string' ? createVNode("div", {
86
- "class": "trim"
87
- }, [(_category ? false : isPredictiveSuggestion
88
- // eslint-disable-next-line
89
- || !!_suggestion_type) ? createVNode(PredictiveSuggestion, {
90
- "innerHTML": label
91
- }, null) : createVNode(Highlight, {
92
- "searchWords": _category ? [_category] : this.currentValue.split(' '),
93
- "textToHighlight": label,
94
- "autoEscape": true,
95
- "highlightStyle": highlightStyle
96
- }, null)]) : label;
97
- }
98
- if (title || image || description) {
99
- return createVNode(Flex, {
100
- "alignItems": "center",
101
- "css": {
102
- width: '100%'
103
- }
104
- }, {
105
- "default": function _default() {
106
- return [image && createVNode("div", {
107
- "css": {
108
- margin: 'auto',
109
- marginRight: 10
110
- }
111
- }, [createVNode("img", {
112
- "src": image,
113
- "alt": " ",
114
- "height": "50px",
115
- "width": "50px",
116
- "css": {
117
- objectFit: 'contain'
118
- }
119
- }, null)]), createVNode(Flex, {
120
- "direction": "column",
121
- "css": {
122
- width: image ? 'calc(100% - 60px)' : '100%'
123
- }
124
- }, {
125
- "default": function _default() {
126
- return [title && createVNode("div", {
127
- "class": "trim"
128
- }, [createVNode(Highlight, {
129
- "searchWords": _this.currentValue.split(' '),
130
- "textToHighlight": title,
131
- "highlightStyle": highlightStyle,
132
- "class": css({
133
- fontSize: '1rem'
134
- })
135
- }, null)]), description && createVNode("div", {
136
- "class": ['trim', css({
137
- marginTop: 3
138
- })]
139
- }, [createVNode(Highlight, {
140
- "searchWords": _this.currentValue.split(' '),
141
- "textToHighlight": description,
142
- "highlightStyle": highlightStyle
143
- }, null)])];
144
- }
145
- })];
146
- }
147
- });
148
- }
149
- return value;
150
- }
151
- };
152
-
153
- var SearchSvg = {
154
- name: 'SearchSvg',
155
- props: ['styles'],
156
- render: function render() {
157
- return createVNode("svg", {
158
- "alt": "Search",
159
- "class": "search-icon",
160
- "height": "12",
161
- "xmlns": "http://www.w3.org/2000/svg",
162
- "viewBox": "0 0 15 15",
163
- "style": _extends({
164
- transform: 'scale(1.35)',
165
- position: 'relative'
166
- }, this.$props.styles ? this.$props.styles : {})
167
- }, [createVNode("title", null, [createTextVNode("Search")]), createVNode("path", {
168
- "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'
169
- }, null)]);
170
- }
171
- };
172
-
173
- var _templateObject$3;
174
-
175
- // eslint-disable-next-line
176
- createGlobalStyle(_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"])));
177
- var MicSvg = {
178
- name: 'MicSvg',
179
- props: ['className'],
180
- render: function render() {
181
- return createVNode("svg", {
182
- "viewBox": "0 0 480 480",
183
- "xmlns": "http://www.w3.org/2000/svg",
184
- "id": "el_xS0FRzQjJ",
185
- "width": 28,
186
- "height": 28,
187
- "className": this.$props.className,
188
- "style": {
189
- transform: 'scale(1.5)'
190
- }
191
- }, [createVNode("g", {
192
- "id": "el_TvxDfTAtKp",
193
- "fillRule": "evenodd"
194
- }, [createVNode("g", {
195
- "id": "el_D93PK3GbmJ",
196
- "fillRule": "nonzero",
197
- "style": {
198
- fill: '#595959'
199
- }
200
- }, [createVNode("path", {
201
- "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",
202
- "id": "el_uly3EwA2O3"
203
- }, null), createVNode("path", {
204
- "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",
205
- "id": "el_tnDbR4ytu4"
206
- }, null)])])]);
207
- }
208
- };
209
-
210
- var _templateObject$4;
211
-
212
- // eslint-disable-next-line
213
- createGlobalStyle(_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"])));
214
- var MuteSvg = {
215
- name: 'MuteSvg',
216
- props: ['className'],
217
- render: function render() {
218
- return createVNode("svg", {
219
- "style": {
220
- transform: 'scale(1.5)'
221
- },
222
- "viewBox": "0 0 480 480",
223
- "xmlns": "http://www.w3.org/2000/svg",
224
- "id": "el_D1rEpH2zj",
225
- "width": 28,
226
- "height": 28,
227
- "className": this.$props.className
228
- }, [createVNode("g", {
229
- "id": "el_X81iT9kZYo",
230
- "fillRule": "evenodd"
231
- }, [createVNode("g", {
232
- "id": "el_gMpyalCphp"
233
- }, [createVNode("path", {
234
- "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",
235
- "id": "el_c7H-3u-D4l",
236
- "fillRule": "nonzero",
237
- "style": {
238
- fill: '#595959'
239
- }
240
- }, null), createVNode("path", {
241
- "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",
242
- "id": "el_qhFcdAAFwo",
243
- "fillRule": "nonzero",
244
- "style": {
245
- fill: '#595959'
246
- }
247
- }, null), createVNode("path", {
248
- "d": "M11.5,206.5 L142.5,12.5",
249
- "id": "el_M8X8g37WOI",
250
- "strokeLinecap": "round",
251
- "strokeLinejoin": "round"
252
- }, null)])])]);
253
- }
254
- };
255
-
256
- var _templateObject$5;
257
-
258
- // eslint-disable-next-line
259
- createGlobalStyle(_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"])));
260
- var ListenSvg = {
261
- name: 'ListenSvg',
262
- props: ['className'],
263
- render: function render() {
264
- return createVNode("svg", {
265
- "viewBox": "0 0 480 480",
266
- "xmlns": "http://www.w3.org/2000/svg",
267
- "xmlnsXlink": "http://www.w3.org/1999/xlink",
268
- "id": "el_hiibMG0x-",
269
- "width": 28,
270
- "height": 29,
271
- "className": this.$props.className,
272
- "style": {
273
- transform: 'scale(1.5)'
274
- }
275
- }, [createVNode("defs", null, [createVNode("path", {
276
- "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",
277
- "id": "path-1"
278
- }, null), createVNode("path", {
279
- "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",
280
- "id": "path-3"
281
- }, null), createVNode("path", {
282
- "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",
283
- "id": "path-5"
284
- }, null), createVNode("path", {
285
- "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",
286
- "id": "path-7"
287
- }, null), createVNode("path", {
288
- "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",
289
- "id": "path-9"
290
- }, null), createVNode("path", {
291
- "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",
292
- "id": "path-11"
293
- }, null), createVNode("path", {
294
- "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",
295
- "id": "path-13"
296
- }, null), createVNode("path", {
297
- "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",
298
- "id": "path-15"
299
- }, null)]), createVNode("g", {
300
- "id": "el_QJeJ_2CDw5",
301
- "fillRule": "evenodd"
302
- }, [createVNode("g", {
303
- "id": "el_UYYCfubTRf"
304
- }, [createVNode("path", {
305
- "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",
306
- "id": "el_uzZNtK32Zi",
307
- "fillRule": "nonzero",
308
- "style": {
309
- fill: '#0B6AFF'
310
- }
311
- }, null), createVNode("path", {
312
- "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",
313
- "id": "el_EYKQ2N9Kgy",
314
- "fillRule": "nonzero"
315
- }, null), createVNode("g", {
316
- "id": "el_6SDP2LAgKC"
317
- }, [createVNode("mask", {
318
- "id": "mask-2",
319
- "fill": "#fff"
320
- }, [createVNode("use", {
321
- "xlink:href": "#path-1"
322
- }, null)]), createVNode("path", {
323
- "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",
324
- "id": "el_-Vm65Ltfy7",
325
- "fillRule": "nonzero",
326
- "mask": "url(#mask-2)"
327
- }, null), createVNode("rect", {
328
- "id": "el_q04iZcSim4",
329
- "mask": "url(#mask-2)",
330
- "x": "0.279",
331
- "width": "77",
332
- "height": "130"
333
- }, null)]), createVNode("g", {
334
- "id": "el_6WKby7wXqV"
335
- }, [createVNode("mask", {
336
- "id": "mask-4",
337
- "fill": "#fff"
338
- }, [createVNode("use", {
339
- "xlink:href": "#path-3"
340
- }, null)]), createVNode("path", {
341
- "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",
342
- "id": "el_9bggsfQOtU",
343
- "fillRule": "nonzero",
344
- "mask": "url(#mask-4)"
345
- }, null), createVNode("rect", {
346
- "id": "el_NKxqi9eIym",
347
- "mask": "url(#mask-4)",
348
- "x": "0.279",
349
- "width": "77",
350
- "height": "115"
351
- }, null)]), createVNode("g", {
352
- "id": "el_Wi-my975tM"
353
- }, [createVNode("mask", {
354
- "id": "mask-6",
355
- "fill": "#fff"
356
- }, [createVNode("use", {
357
- "xlink:href": "#path-5"
358
- }, null)]), createVNode("path", {
359
- "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",
360
- "id": "el_zclQ34fvf7",
361
- "fillRule": "nonzero",
362
- "mask": "url(#mask-6)"
363
- }, null), createVNode("rect", {
364
- "id": "el_1OsvRT8HkeZ",
365
- "mask": "url(#mask-6)",
366
- "x": "0.279",
367
- "width": "77",
368
- "height": "100"
369
- }, null)]), createVNode("g", {
370
- "id": "el_DkfFFTaFxy8"
371
- }, [createVNode("mask", {
372
- "id": "mask-8",
373
- "fill": "#fff"
374
- }, [createVNode("use", {
375
- "xlink:href": "#path-7"
376
- }, null)]), createVNode("path", {
377
- "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",
378
- "id": "el_aa9sjx4H0vA",
379
- "fillRule": "nonzero",
380
- "mask": "url(#mask-8)"
381
- }, null), createVNode("rect", {
382
- "id": "el_tea114vWg0J",
383
- "mask": "url(#mask-8)",
384
- "x": "0.279",
385
- "width": "77",
386
- "height": "85"
387
- }, null)]), createVNode("g", {
388
- "id": "el_34IgwiMB5rf"
389
- }, [createVNode("mask", {
390
- "id": "mask-10",
391
- "fill": "#fff"
392
- }, [createVNode("use", {
393
- "xlink:href": "#path-9"
394
- }, null)]), createVNode("path", {
395
- "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",
396
- "id": "el_z5u6RAFhx7d",
397
- "fillRule": "nonzero",
398
- "mask": "url(#mask-10)"
399
- }, null), createVNode("rect", {
400
- "id": "el_7nfuWmA5Uhy",
401
- "mask": "url(#mask-10)",
402
- "x": "0.279",
403
- "width": "77",
404
- "height": "70"
405
- }, null)]), createVNode("g", {
406
- "id": "el_DeebuCsPTGA"
407
- }, [createVNode("mask", {
408
- "id": "mask-12",
409
- "fill": "#fff"
410
- }, [createVNode("use", {
411
- "xlink:href": "#path-11"
412
- }, null)]), createVNode("path", {
413
- "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",
414
- "id": "el__ZcqlS20zcw",
415
- "fillRule": "nonzero",
416
- "mask": "url(#mask-12)"
417
- }, null), createVNode("rect", {
418
- "id": "el_8DnEQnD7VWV",
419
- "mask": "url(#mask-12)",
420
- "x": "0.279",
421
- "width": "77",
422
- "height": "55"
423
- }, null)]), createVNode("g", {
424
- "id": "el_ZOjjrPTvyrv"
425
- }, [createVNode("mask", {
426
- "id": "mask-14",
427
- "fill": "#fff"
428
- }, [createVNode("use", {
429
- "xlink:href": "#path-13"
430
- }, null)]), createVNode("path", {
431
- "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",
432
- "id": "el_FYYKCI_u24e",
433
- "fillRule": "nonzero",
434
- "mask": "url(#mask-14)"
435
- }, null), createVNode("rect", {
436
- "id": "el_XZty4MnTp5Y",
437
- "mask": "url(#mask-14)",
438
- "x": "0.279",
439
- "width": "77",
440
- "height": "40"
441
- }, null)]), createVNode("g", {
442
- "id": "el_2FATegVmf0K"
443
- }, [createVNode("mask", {
444
- "id": "mask-16",
445
- "fill": "#fff"
446
- }, [createVNode("use", {
447
- "xlink:href": "#path-15"
448
- }, null)]), createVNode("path", {
449
- "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",
450
- "id": "el_RMT1KUfbdF8",
451
- "fillRule": "nonzero",
452
- "mask": "url(#mask-16)"
453
- }, null), createVNode("rect", {
454
- "id": "el_RgLcovvFiO1",
455
- "mask": "url(#mask-16)",
456
- "x": "0.279",
457
- "width": "77",
458
- "height": "25"
459
- }, null)])])])]);
460
- }
461
- };
462
-
463
- var STATUS = {
464
- inactive: 'INACTIVE',
465
- stopped: 'STOPPED',
466
- active: 'ACTIVE',
467
- denied: 'DENIED'
468
- };
469
- var Mic = {
470
- name: 'Mic',
471
- props: {
472
- children: types.title,
473
- lang: VueTypes.string.def('en-US'),
474
- iconPosition: VueTypes.string.def('left'),
475
- handleResult: types.func,
476
- onNoMatch: types.func,
477
- onError: types.func,
478
- getInstance: types.func,
479
- render: types.func,
480
- className: types.string,
481
- applyClearStyle: VueTypes.bool,
482
- showIcon: VueTypes.bool
483
- },
484
- methods: {
485
- getComponent: function getComponent$1() {
486
- var status = this.$data.status;
487
- var data = {
488
- handleClick: this.handleClick,
489
- status: status
490
- };
491
- return getComponent(data, this);
492
- },
493
- stopMic: function stopMic() {
494
- if (this.instance) {
495
- this.status = STATUS.inactive;
496
- this.instance.stop();
497
- this.instance = null;
498
- }
499
- },
500
- handleClick: function handleClick() {
501
- var _this = this;
502
- this.results = [];
503
- if (window && window.SpeechRecognition) {
504
- var status = this.$data.status;
505
- if (status === STATUS.active) {
506
- this.status = STATUS.inactive;
507
- }
508
- var _this$$props = this.$props,
509
- handleResult = _this$$props.handleResult,
510
- onNoMatch = _this$$props.onNoMatch,
511
- onError = _this$$props.onError,
512
- lang = _this$$props.lang,
513
- getInstance = _this$$props.getInstance;
514
- var _window = window,
515
- SpeechRecognition = _window.SpeechRecognition;
516
- if (this.instance && this.status !== STATUS.denied) {
517
- this.status = STATUS.inactive;
518
- this.instance.stop();
519
- this.instance = null;
520
- return;
521
- }
522
- this.instance = new SpeechRecognition();
523
- this.instance.continuous = true;
524
- this.instance.interimResults = true;
525
- this.instance.lang = lang;
526
- if (getInstance) {
527
- getInstance(this.instance);
528
- }
529
- this.instance.start();
530
- this.instance.onstart = function () {
531
- _this.status = STATUS.active;
532
- };
533
- this.instance.onresult = function (_ref) {
534
- var results = _ref.results,
535
- timeStamp = _ref.timeStamp;
536
- _this.stopMic();
537
- if (handleResult) {
538
- handleResult({
539
- results: results,
540
- timeStamp: timeStamp
541
- });
542
- }
543
- _this.results.push({
544
- results: results,
545
- timeStamp: timeStamp
546
- });
547
- };
548
- this.instance.onnomatch = function (e) {
549
- return onNoMatch ? onNoMatch(e) : console.warn(e);
550
- };
551
- this.instance.onerror = function (e) {
552
- if (e.error === 'no-speech' || e.error === 'audio-capture') {
553
- _this.status = STATUS.inactive;
554
- } else if (e.error === 'not-allowed') {
555
- _this.status = STATUS.denied;
556
- }
557
- console.error(e);
558
- if (onError) {
559
- onError(e);
560
- }
561
- };
562
-
563
- /* Below Two methods run when Continuous is False */
564
- this.instance.onspeechend = function () {
565
- _this.status = STATUS.inactive;
566
- };
567
- this.instance.onaudioend = function () {
568
- _this.status = STATUS.inactive;
569
- };
570
- }
571
- }
572
- },
573
- computed: {
574
- hasCustomRenderer: function hasCustomRenderer$1() {
575
- return hasCustomRenderer(this);
576
- },
577
- Icon: function Icon() {
578
- var status = this.$data.status;
579
- var className = this.$props.className;
580
- switch (status) {
581
- case STATUS.active:
582
- return createVNode(ListenSvg, {
583
- "className": className,
584
- "nativeOnClick": this.handleClick
585
- }, null);
586
- case STATUS.stopped:
587
- case STATUS.denied:
588
- return createVNode(MuteSvg, {
589
- "className": className,
590
- "nativeOnClick": this.handleClick
591
- }, null);
592
- default:
593
- return createVNode(MicSvg, {
594
- "className": className,
595
- "nativeOnClick": this.handleClick
596
- }, null);
597
- }
598
- }
599
- },
600
- data: function data() {
601
- return {
602
- status: STATUS.inactive
603
- };
604
- },
605
- created: function created() {
606
- this.results = [];
607
- if (typeof window !== 'undefined') {
608
- window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition || null;
609
- if (!window.SpeechRecognition) {
610
- 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.');
611
- }
612
- }
613
- },
614
- render: function render() {
615
- var _this2 = this;
616
- if (this.hasCustomRenderer) {
617
- return this.getComponent();
618
- }
619
- return createVNode(IconWrapper, null, {
620
- "default": function _default() {
621
- return [_this2.Icon];
622
- }
623
- });
624
- }
625
- };
626
-
627
- var CustomSvg = {
628
- name: 'CustomSvg',
629
- props: {
630
- className: String,
631
- icon: Function,
632
- type: String
633
- },
634
- data: function data() {
635
- return {
636
- customIcon: this.$props.icon && typeof this.$props.icon === 'function' ? this.$props.icon() : null
637
- };
638
- },
639
- render: function render() {
640
- if (this.customIcon) {
641
- return createVNode("div", {
642
- "class": this.$props.className
643
- }, [this.customIcon]);
644
- }
645
- if (this.$props.type === 'recent-search-icon') {
646
- return createVNode("svg", {
647
- "xmlns": "http://www.w3.org/2000/svg",
648
- "alt": "Recent Search",
649
- "height": "20",
650
- "width": "20",
651
- "viewBox": "0 0 24 24",
652
- "style": {
653
- fill: '#707070'
654
- },
655
- "class": this.$props.className
656
- }, [createVNode("path", {
657
- "d": "M0 0h24v24H0z",
658
- "fill": "none"
659
- }, null), createVNode("path", {
660
- "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"
661
- }, null)]);
662
- }
663
- if (this.$props.type === 'promoted-search-icon') {
664
- return createVNode("svg", {
665
- "xmlns": "http://www.w3.org/2000/svg",
666
- "width": "20",
667
- "alt": "promoted search",
668
- "height": "20",
669
- "viewBox": "0 0 24 24",
670
- "class": this.$props.className,
671
- "style": {
672
- fill: '#707070'
673
- }
674
- }, [createVNode("path", {
675
- "d": "M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z"
676
- }, null)]);
677
- }
678
- if (this.$props.type === 'popular-search-icon') {
679
- return createVNode("svg", {
680
- "xmlns": "http://www.w3.org/2000/svg",
681
- "alt": "Popular Search",
682
- "height": "20",
683
- "width": "20",
684
- "viewBox": "0 0 24 24",
685
- "style": {
686
- fill: '#707070'
687
- },
688
- "class": this.$props.className
689
- }, [createVNode("path", {
690
- "d": "M0 0h24v24H0z",
691
- "fill": "none"
692
- }, null), createVNode("path", {
693
- "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"
694
- }, null)]);
695
- }
696
- return createVNode(SearchSvg, {
697
- "styles": {
698
- position: 'relative',
699
- fill: '#707070',
700
- left: '3px',
701
- marginRight: '8px'
702
- }
703
- }, null);
704
- }
705
- };
706
-
707
- var _templateObject$6;
708
- var AutofillSvgIcon = styled('button')(_templateObject$6 || (_templateObject$6 = _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"])));
709
- var AutoFillSvg = {
710
- name: 'AutoFillSvg',
711
- render: function render() {
712
- return createVNode(AutofillSvgIcon, {
713
- "onClick": this.$attrs.click
714
- }, {
715
- "default": function _default() {
716
- return [createVNode("svg", {
717
- "viewBox": "0 0 24 24"
718
- }, [createVNode("path", {
719
- "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"
720
- }, null)])];
721
- }
722
- });
723
- },
724
- methods: {
725
- clicked: function clicked(e) {
726
- e.stopPropagation();
727
- window.console.log('hey', e);
728
- }
729
- }
730
- };
731
-
732
- var _templateObject$7, _templateObject2;
733
- var TagsContainer = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tmargin-top: 10px;\n\twidth: 100%;\n"])));
734
- var TagItem = styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\tcursor: default;\n\tbox-sizing: border-box;\n\tmargin: 0 4px 4px 0;\n\tcolor: #000000d9;\n\tfont-size: 14px;\n\tfont-variant: tabular-nums;\n\tline-height: 1.5715;\n\tlist-style: none;\n\tfont-feature-settings: 'tnum';\n\tdisplay: inline-block;\n\theight: auto;\n\tpadding: 0 2px 0 7px;\n\tfont-size: 12px;\n\tline-height: 22px;\n\twhite-space: nowrap;\n\tbackground: #fafafa;\n\tborder: 1px solid #d9d9d9;\n\tborder-radius: 2px;\n\topacity: 1;\n\ttransition: all 0.3s;\n\n\tspan.close-icon {\n\t\tsvg {\n\t\t\tcursor: pointer;\n\t\t\theight: 15px;\n\t\t\tposition: relative;\n\t\t\ttop: 4px;\n\t\t\tfill: #262626;\n\t\t}\n\t}\n"])));
735
-
736
- function _isSlot(s) {
737
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
738
- }
739
- var updateQuery = Actions.updateQuery,
740
- setCustomQuery = Actions.setCustomQuery,
741
- setDefaultQuery = Actions.setDefaultQuery,
742
- recordSuggestionClick = Actions.recordSuggestionClick;
743
- var _debounce = helper.debounce,
744
- checkValueChange = helper.checkValueChange,
745
- getClassName$1 = helper.getClassName,
746
- isEqual = helper.isEqual,
747
- getCompositeAggsQuery = helper.getCompositeAggsQuery,
748
- withClickIds = helper.withClickIds,
749
- getResultStats = helper.getResultStats;
750
- var SearchBox = defineComponent({
751
- name: 'SearchBox',
752
- isTagsMode: false,
753
- data: function data() {
754
- var props = this.$props;
755
- this.__state = {
756
- currentValue: '',
757
- selectedTags: [],
758
- isOpen: false,
759
- normalizedSuggestions: []
760
- };
761
- this.internalComponent = props.componentId + "__internal";
762
- return this.__state;
763
- },
764
- inject: {
765
- theme: {
766
- from: 'theme_reactivesearch'
767
- }
768
- },
769
- created: function created() {
770
- var mode = this.$props.mode;
771
- if (mode === SEARCH_COMPONENTS_MODES.TAG) {
772
- this.$options.isTagsMode = true;
773
- }
774
- if (this.$options.isTagsMode) {
775
- console.warn('Warning(ReactiveSearch): The `categoryField` prop is not supported when `mode` prop is set to `tag`');
776
- }
777
- this.currentValue = decodeHtml(this.selectedValue || this.value || this.defaultValue || '');
778
- if (this.$options.isTagsMode) {
779
- this.currentValue = '';
780
- }
781
- this.handleTextChange = _debounce(this.handleText, this.$props.debounce);
782
-
783
- // Set custom and default queries in store
784
- this.triggerCustomQuery(this.currentValue, this.selectedCategory);
785
- this.triggerDefaultQuery(this.currentValue);
786
- if (this.selectedValue) {
787
- this.setValue(this.selectedValue, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
788
- } else if (this.$props.value) {
789
- this.setValue(this.$props.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
790
- } else if (this.$props.defaultValue) {
791
- this.setValue(this.$props.defaultValue, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
792
- }
793
- },
794
- computed: {
795
- hasCustomRenderer: function hasCustomRenderer$1() {
796
- return hasCustomRenderer(this);
797
- },
798
- stats: function stats() {
799
- return getResultStats(this);
800
- }
801
- },
802
- props: {
803
- autoFocus: VueTypes.bool,
804
- autosuggest: VueTypes.bool.def(true),
805
- beforeValueChange: types.func,
806
- className: VueTypes.string.def(''),
807
- clearIcon: types.children,
808
- componentId: types.stringRequired,
809
- customHighlight: types.func,
810
- customQuery: types.func,
811
- defaultQuery: types.func,
812
- dataField: VueTypes.oneOfType([VueTypes.string, VueTypes.shape({
813
- field: VueTypes.string,
814
- weight: VueTypes.number
815
- }), VueTypes.arrayOf(VueTypes.string), VueTypes.arrayOf({
816
- field: VueTypes.string,
817
- weight: VueTypes.number
818
- })]),
819
- aggregationField: types.string,
820
- aggregationSize: VueTypes.number,
821
- size: VueTypes.number,
822
- debounce: VueTypes.number.def(0),
823
- defaultValue: types.string,
824
- excludeFields: types.excludeFields,
825
- value: VueTypes.oneOfType([VueTypes.arrayOf(VueTypes.string), types.value]),
826
- defaultSuggestions: types.suggestions,
827
- enableSynonyms: VueTypes.bool.def(true),
828
- enableQuerySuggestions: VueTypes.bool.def(false),
829
- enablePopularSuggestions: VueTypes.bool.def(false),
830
- enableRecentSuggestions: VueTypes.bool.def(false),
831
- fieldWeights: types.fieldWeights,
832
- filterLabel: types.string,
833
- fuzziness: types.fuzziness,
834
- highlight: VueTypes.bool,
835
- highlightField: types.stringOrArray,
836
- icon: types.children,
837
- iconPosition: VueTypes.oneOf(['left', 'right']).def('left'),
838
- includeFields: types.includeFields,
839
- innerClass: types.style,
840
- innerRef: VueTypes.string.def('searchInputField'),
841
- render: types.func,
842
- renderNoSuggestion: types.title,
843
- renderError: types.title,
844
- placeholder: VueTypes.string.def('Search'),
845
- queryFormat: VueTypes.oneOf(['and', 'or']).def('or'),
846
- react: types.react,
847
- showClear: VueTypes.bool.def(true),
848
- showDistinctSuggestions: VueTypes.bool.def(true),
849
- showFilter: VueTypes.bool.def(true),
850
- showIcon: VueTypes.bool.def(true),
851
- title: types.title,
852
- URLParams: VueTypes.bool.def(false),
853
- strictSelection: VueTypes.bool.def(false),
854
- nestedField: types.string,
855
- enablePredictiveSuggestions: VueTypes.bool.def(false),
856
- recentSearchesIcon: VueTypes.any,
857
- popularSearchesIcon: VueTypes.any,
858
- // mic props
859
- showVoiceSearch: VueTypes.bool.def(false),
860
- getMicInstance: types.func,
861
- renderMic: types.func,
862
- distinctField: types.string,
863
- distinctFieldConfig: types.props,
864
- //
865
- focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])).def(['/']),
866
- addonBefore: VueTypes.any,
867
- addonAfter: VueTypes.any,
868
- expandSuggestionsContainer: VueTypes.bool.def(true),
869
- index: VueTypes.string,
870
- popularSuggestionsConfig: VueTypes.object,
871
- recentSuggestionsConfig: VueTypes.object,
872
- applyStopwords: VueTypes.bool,
873
- customStopwords: types.stringArray,
874
- onData: types.func,
875
- renderItem: types.func,
876
- enterButton: VueTypes.bool.def(false),
877
- renderEnterButton: VueTypes.any,
878
- mode: VueTypes.oneOf(['select', 'tag']).def('select'),
879
- renderSelectedTags: VueTypes.any,
880
- searchboxId: VueTypes.string,
881
- endpoint: types.endpointConfig
882
- },
883
- mounted: function mounted() {
884
- this.listenForFocusShortcuts();
885
- },
886
- watch: {
887
- dataField: function dataField(newVal, oldVal) {
888
- if (!isEqual(newVal, oldVal)) {
889
- this.triggerCustomQuery(this.$data.currentValue);
890
- }
891
- },
892
- fieldWeights: function fieldWeights() {
893
- this.triggerCustomQuery(this.$data.currentValue);
894
- },
895
- fuzziness: function fuzziness() {
896
- this.triggerCustomQuery(this.$data.currentValue);
897
- },
898
- queryFormat: function queryFormat() {
899
- this.triggerCustomQuery(this.$data.currentValue);
900
- },
901
- defaultValue: function defaultValue(newVal) {
902
- this.setValue(newVal, true, this.$props);
903
- },
904
- value: function value(newVal, oldVal) {
905
- if (!isEqual(newVal, oldVal)) {
906
- this.setValue(newVal, true, this.$props, newVal === '' ? causes.CLEAR_VALUE : undefined, false);
907
- }
908
- },
909
- defaultQuery: function defaultQuery(newVal, oldVal) {
910
- if (!isQueryIdentical(newVal, oldVal, this.$data.currentValue, this.$props)) {
911
- this.triggerDefaultQuery(this.$data.currentValue);
912
- }
913
- },
914
- customQuery: function customQuery(newVal, oldVal) {
915
- if (!isQueryIdentical(newVal, oldVal, this.$data.currentValue, this.$props)) {
916
- this.triggerCustomQuery(this.$data.currentValue);
917
- }
918
- },
919
- suggestions: function suggestions(newVal) {
920
- var suggestionsList = [];
921
- if (Array.isArray(newVal) && newVal.length) {
922
- suggestionsList = [].concat(withClickIds(newVal));
923
- } else if (Array.isArray(this.$props.defaultSuggestions) && this.$props.defaultSuggestions.length) {
924
- suggestionsList = [].concat(withClickIds(this.$props.defaultSuggestions));
925
- }
926
- this.normalizedSuggestions = suggestionsList;
927
- },
928
- selectedValue: function selectedValue(newVal, oldVal) {
929
- if (!isEqual(newVal, oldVal) && (this.$options.isTagsMode ? !isEqual(this.$data.selectedTags, newVal) : this.$data.currentValue !== newVal)) {
930
- if (!newVal && this.$data.currentValue) {
931
- // selected value is cleared, call onValueSelected
932
- this.onValueSelectedHandler('', causes.CLEAR_VALUE);
933
- }
934
- if (this.$options.isTagsMode) {
935
- // handling reset of tags through SelectedFilters or URL
936
- this.selectedTags = [];
937
- }
938
- var cause = !newVal ? causes.CLEAR_VALUE : undefined;
939
- if (this.$options.isTagsMode) {
940
- cause = causes.SUGGESTION_SELECT;
941
- }
942
- this.setValue(newVal || '', true, this.$props, cause);
943
- }
944
- },
945
- focusShortcuts: function focusShortcuts() {
946
- this.listenForFocusShortcuts();
947
- },
948
- rawData: function rawData(newVal) {
949
- this.$emit('on-data', {
950
- data: this.normalizedSuggestions,
951
- rawData: newVal,
952
- aggregationData: this.aggregationData,
953
- loading: this.isLoading,
954
- error: this.isError
955
- });
956
- },
957
- aggregationData: function aggregationData(newVal) {
958
- this.$emit('on-data', {
959
- data: this.normalizedSuggestions,
960
- rawData: this.rawData,
961
- aggregationData: newVal,
962
- loading: this.isLoading,
963
- error: this.isError
964
- });
965
- },
966
- loading: function loading(newVal) {
967
- this.$emit('on-data', {
968
- data: this.normalizedSuggestions,
969
- rawData: this.rawData,
970
- aggregationData: this.aggregationData,
971
- loading: newVal,
972
- error: this.isError
973
- });
974
- },
975
- error: function error(newVal) {
976
- this.$emit('on-data', {
977
- data: this.normalizedSuggestions,
978
- rawData: this.rawData,
979
- aggregationData: this.aggregationData,
980
- loading: this.isLoading,
981
- error: newVal
982
- });
983
- },
984
- debounce: function debounce(newVal, oldVal) {
985
- if (!isEqual(newVal, oldVal)) {
986
- this.handleTextChange = _debounce(this.handleText, newVal);
987
- }
988
- }
989
- },
990
- methods: {
991
- handleText: function handleText(value, cause) {
992
- if (cause === causes.CLEAR_VALUE) {
993
- this.triggerCustomQuery(value);
994
- this.triggerDefaultQuery(value);
995
- } else if (this.$props.autosuggest) {
996
- this.triggerDefaultQuery(value);
997
- } else if (!this.$props.enterButton) {
998
- this.triggerCustomQuery(value);
999
- }
1000
- },
1001
- getComponent: function getComponent$1(downshiftProps) {
1002
- if (downshiftProps === void 0) {
1003
- downshiftProps = {};
1004
- }
1005
- var currentValue = this.$data.currentValue;
1006
- var data = {
1007
- error: this.error,
1008
- loading: this.isLoading,
1009
- downshiftProps: downshiftProps,
1010
- data: this.normalizedSuggestions,
1011
- rawData: this.rawData,
1012
- value: currentValue,
1013
- resultStats: this.stats
1014
- };
1015
- return getComponent(data, this);
1016
- },
1017
- // returns size and aggs property
1018
- getBasicQueryOptions: function getBasicQueryOptions() {
1019
- var aggregationField = this.$props.aggregationField;
1020
- var queryOptions = getQueryOptions(this.$props);
1021
- if (aggregationField) {
1022
- queryOptions.aggs = getCompositeAggsQuery({
1023
- props: this.$props,
1024
- showTopHits: true
1025
- }).aggs;
1026
- }
1027
- return queryOptions;
1028
- },
1029
- handleSearchIconClick: function handleSearchIconClick() {
1030
- var currentValue = this.currentValue;
1031
- if (currentValue.trim()) {
1032
- this.setValue(currentValue, true);
1033
- this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
1034
- }
1035
- },
1036
- setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
1037
- var _this = this;
1038
- if (isDefaultValue === void 0) {
1039
- isDefaultValue = false;
1040
- }
1041
- if (props === void 0) {
1042
- props = this.$props;
1043
- }
1044
- if (toggleIsOpen === void 0) {
1045
- toggleIsOpen = true;
1046
- }
1047
- if (categoryValue === void 0) {
1048
- categoryValue = undefined;
1049
- }
1050
- var performUpdate = function performUpdate() {
1051
- if (_this.$options.isTagsMode && isEqual(value, _this.selectedTags)) {
1052
- return;
1053
- }
1054
- if (_this.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1055
- if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
1056
- // check if value already present in selectedTags
1057
- if (typeof value === 'string' && _this.selectedTags.includes(value)) {
1058
- _this.isOpen = false;
1059
- return;
1060
- }
1061
- _this.selectedTags = [].concat(_this.selectedTags);
1062
- if (typeof value === 'string' && !!value) {
1063
- _this.selectedTags.push(value);
1064
- } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
1065
- _this.selectedTags = value;
1066
- }
1067
- } else if (value) {
1068
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
1069
- }
1070
- _this.currentValue = '';
1071
- } else {
1072
- _this.currentValue = decodeHtml(value);
1073
- }
1074
- var queryHandlerValue = value;
1075
- if (_this.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1076
- queryHandlerValue = Array.isArray(_this.selectedTags) && _this.selectedTags.length ? _this.selectedTags : undefined;
1077
- }
1078
- if (isDefaultValue) {
1079
- if (_this.$props.autosuggest) {
1080
- if (toggleIsOpen) {
1081
- _this.isOpen = false;
1082
- }
1083
- if (typeof _this.currentValue === 'string') _this.triggerDefaultQuery(_this.currentValue);
1084
- } // in case of strict selection only SUGGESTION_SELECT should be able
1085
- // to set the query otherwise the value should reset
1086
- if (props.strictSelection) {
1087
- if (cause === causes.SUGGESTION_SELECT || (_this.$options.isTagsMode ? _this.selectedTags.length === 0 : value === '')) {
1088
- _this.triggerCustomQuery(queryHandlerValue, _this.$options.isTagsMode ? undefined : categoryValue);
1089
- } else {
1090
- _this.setValue('', true);
1091
- }
1092
- } else if (props.value === undefined || cause === causes.SUGGESTION_SELECT || cause === causes.CLEAR_VALUE) {
1093
- _this.triggerCustomQuery(queryHandlerValue, _this.$options.isTagsMode ? undefined : categoryValue);
1094
- }
1095
- } else {
1096
- // debounce for handling text while typing
1097
- _this.handleTextChange(value, cause);
1098
- }
1099
- _this.$emit('valueChange', value);
1100
- _this.$emit('value-change', value);
1101
- };
1102
- checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1103
- },
1104
- triggerDefaultQuery: function triggerDefaultQuery(paramValue) {
1105
- if (!this.$props.autosuggest) {
1106
- return;
1107
- }
1108
- var value = typeof paramValue !== 'string' ? this.currentValue : paramValue;
1109
- var query = SearchBox.defaultQuery(value, this.$props);
1110
- if (this.defaultQuery) {
1111
- var defaultQueryToBeSet = this.defaultQuery(value, this.$props) || {};
1112
- if (defaultQueryToBeSet.query) {
1113
- query = defaultQueryToBeSet.query;
1114
- }
1115
-
1116
- // Update calculated default query in store
1117
- updateDefaultQuery(this.$props.componentId, this.setDefaultQuery, this.$props, value);
1118
- }
1119
- this.updateQuery({
1120
- componentId: this.internalComponent,
1121
- query: query,
1122
- value: value,
1123
- componentType: componentTypes.searchBox
1124
- });
1125
- },
1126
- triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
1127
- if (categoryValue === void 0) {
1128
- categoryValue = undefined;
1129
- }
1130
- var _this$$props = this.$props,
1131
- customQuery = _this$$props.customQuery,
1132
- filterLabel = _this$$props.filterLabel,
1133
- showFilter = _this$$props.showFilter,
1134
- URLParams = _this$$props.URLParams;
1135
- var value = typeof paramValue !== 'string' ? this.$data.currentValue : paramValue;
1136
- if (this.$options.isTagsMode) {
1137
- value = paramValue;
1138
- }
1139
- var defaultQueryTobeSet = SearchBox.defaultQuery("" + value + (categoryValue ? " in " + categoryValue : ''), this.$props);
1140
- var query = defaultQueryTobeSet;
1141
- if (customQuery) {
1142
- var customQueryTobeSet = customQuery(value, this.$props);
1143
- var queryTobeSet = customQueryTobeSet.query;
1144
- if (queryTobeSet) {
1145
- query = queryTobeSet;
1146
- }
1147
- updateCustomQuery(this.$props.componentId, this.setCustomQuery, this.$props, value);
1148
- }
1149
- this.updateQuery({
1150
- componentId: this.$props.componentId,
1151
- query: query,
1152
- value: value,
1153
- label: filterLabel,
1154
- showFilter: showFilter,
1155
- URLParams: URLParams,
1156
- componentType: componentTypes.searchBox,
1157
- category: categoryValue
1158
- });
1159
- },
1160
- handleFocus: function handleFocus(event) {
1161
- if (this.$props.autosuggest) {
1162
- this.isOpen = true;
1163
- }
1164
- this.$emit('focus', event);
1165
- },
1166
- handleVoiceResults: function handleVoiceResults(_ref) {
1167
- var results = _ref.results;
1168
- if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
1169
- this.setValue(results[0][0].transcript.trim(), true);
1170
- }
1171
- },
1172
- triggerQuery: function triggerQuery(_ref2) {
1173
- var _ref2$isOpen = _ref2.isOpen,
1174
- isOpen = _ref2$isOpen === void 0 ? undefined : _ref2$isOpen,
1175
- _ref2$customQuery = _ref2.customQuery,
1176
- customQuery = _ref2$customQuery === void 0 ? true : _ref2$customQuery,
1177
- _ref2$defaultQuery = _ref2.defaultQuery,
1178
- defaultQuery = _ref2$defaultQuery === void 0 ? true : _ref2$defaultQuery,
1179
- _ref2$value = _ref2.value,
1180
- value = _ref2$value === void 0 ? undefined : _ref2$value,
1181
- _ref2$categoryValue = _ref2.categoryValue,
1182
- categoryValue = _ref2$categoryValue === void 0 ? undefined : _ref2$categoryValue;
1183
- if (typeof isOpen === 'boolean') {
1184
- this.isOpen = isOpen;
1185
- }
1186
- if (customQuery) {
1187
- this.triggerCustomQuery(value, categoryValue);
1188
- }
1189
- if (defaultQuery) {
1190
- this.triggerDefaultQuery(value);
1191
- }
1192
- },
1193
- triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
1194
- // click analytics would only work client side and after javascript loads
1195
- var docId = documentId;
1196
- if (!docId) {
1197
- var hitData = this.normalizedSuggestions.find(function (hit) {
1198
- return hit._click_id === searchPosition;
1199
- });
1200
- if (hitData && hitData.source && hitData.source._id) {
1201
- docId = hitData.source._id;
1202
- }
1203
- }
1204
- this.recordSuggestionClick(searchPosition, docId);
1205
- },
1206
- clearValue: function clearValue() {
1207
- this.setValue('', false, this.$props, causes.CLEAR_VALUE, false);
1208
- this.onValueSelectedHandler('', causes.CLEAR_VALUE);
1209
- },
1210
- handleKeyDown: function handleKeyDown(event, highlightedIndex) {
1211
- if (highlightedIndex === void 0) {
1212
- highlightedIndex = null;
1213
- }
1214
- // if a suggestion was selected, delegate the handling to suggestion handler
1215
- if (event.key === 'Enter') {
1216
- if (this.$props.autosuggest === false) {
1217
- this.enterButtonOnClick();
1218
- } else if (highlightedIndex === null) {
1219
- this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined // to handle tags
1220
- );
1221
-
1222
- this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
1223
- }
1224
- }
1225
-
1226
- // Need to review
1227
- this.$emit('keyDown', event, this.triggerQuery);
1228
- this.$emit('key-down', event, this.triggerQuery);
1229
- },
1230
- onInputChange: function onInputChange(e) {
1231
- var _this2 = this;
1232
- var inputValue = e.target.value;
1233
- if (!this.$data.isOpen && this.$props.autosuggest) {
1234
- this.isOpen = true;
1235
- }
1236
- var value = this.$props.value;
1237
- if (value === undefined) {
1238
- this.setValue(inputValue, false, this.$props, inputValue === '' ? causes.CLEAR_VALUE : undefined);
1239
- } else {
1240
- this.$emit('change', inputValue, function (_ref3) {
1241
- var isOpen = _ref3.isOpen;
1242
- return _this2.triggerQuery({
1243
- defaultQuery: true,
1244
- customQuery: true,
1245
- value: inputValue,
1246
- isOpen: isOpen
1247
- });
1248
- }, e);
1249
- }
1250
- },
1251
- onSuggestionSelected: function onSuggestionSelected(suggestion) {
1252
- var _this3 = this;
1253
- this.isOpen = false;
1254
- var value = this.$props.value;
1255
- // Record analytics for selected suggestions
1256
- this.triggerClickAnalytics(suggestion._click_id);
1257
- if (value === undefined) {
1258
- this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT, false, suggestion._category);
1259
- } else {
1260
- var emitValue = suggestion.value;
1261
- if (this.$options.isTagsMode) {
1262
- emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
1263
- if (this.selectedTags.includes(suggestion.value)) {
1264
- // avoid duplicates in tags array
1265
- this.isOpen = false;
1266
- return;
1267
- }
1268
- emitValue.push(suggestion.value);
1269
- }
1270
- this.setValue(emitValue, true, this.$props, causes.SUGGESTION_SELECT, false, suggestion._category);
1271
- this.$emit('change', emitValue, function (_ref4) {
1272
- var isOpen = _ref4.isOpen;
1273
- return _this3.triggerQuery(_extends({
1274
- isOpen: isOpen,
1275
- value: emitValue
1276
- }, !_this3.$options.isTagsMode && {
1277
- categoryValue: suggestion._category
1278
- }));
1279
- });
1280
- }
1281
- this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
1282
- },
1283
- onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
1284
- if (currentValue === void 0) {
1285
- currentValue = this.$data.currentValue;
1286
- }
1287
- for (var _len = arguments.length, cause = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1288
- cause[_key - 1] = arguments[_key];
1289
- }
1290
- this.$emit.apply(this, ['valueSelected', currentValue].concat(cause));
1291
- this.$emit.apply(this, ['value-selected', currentValue].concat(cause));
1292
- },
1293
- handleStateChange: function handleStateChange(changes) {
1294
- var isOpen = changes.isOpen;
1295
- this.isOpen = isOpen;
1296
- },
1297
- getBackgroundColor: function getBackgroundColor(highlightedIndex, index) {
1298
- var isDark = this.themePreset === 'dark';
1299
- if (isDark) {
1300
- return highlightedIndex === index ? '#555' : '#424242';
1301
- }
1302
- return highlightedIndex === index ? '#eee' : '#fff';
1303
- },
1304
- renderIcon: function renderIcon() {
1305
- if (this.$props.showIcon) {
1306
- return this.$props.icon || createVNode(SearchSvg, null, null);
1307
- }
1308
- return null;
1309
- },
1310
- renderErrorComponent: function renderErrorComponent() {
1311
- var _this4 = this;
1312
- var renderError = this.$slots.renderError || this.$props.renderError;
1313
- if (this.error && renderError && this.$data.currentValue && !this.isLoading) {
1314
- return createVNode(SuggestionWrapper, {
1315
- "innerClass": this.$props.innerClass,
1316
- "innerClassName": "error",
1317
- "theme": this.theme,
1318
- "themePreset": this.themePreset
1319
- }, {
1320
- "default": function _default() {
1321
- return [isFunction(renderError) ? renderError(_this4.error) : renderError];
1322
- }
1323
- });
1324
- }
1325
- return null;
1326
- },
1327
- renderCancelIcon: function renderCancelIcon() {
1328
- if (this.$props.showClear) {
1329
- return this.$props.clearIcon || createVNode(CancelSvg, null, null);
1330
- }
1331
- return null;
1332
- },
1333
- renderNoSuggestions: function renderNoSuggestions(finalSuggestionsList) {
1334
- if (finalSuggestionsList === void 0) {
1335
- finalSuggestionsList = [];
1336
- }
1337
- var innerClass = this.$props.innerClass;
1338
- var renderNoSuggestion = this.$slots.renderNoSuggestion || this.$props.renderNoSuggestion;
1339
- var renderError = this.$slots.renderError || this.$props.renderError;
1340
- var _this$$data = this.$data,
1341
- isOpen = _this$$data.isOpen,
1342
- currentValue = _this$$data.currentValue;
1343
- if (renderNoSuggestion && isOpen && !finalSuggestionsList.length && !this.isLoading && currentValue && !(renderError && this.error)) {
1344
- return createVNode(SuggestionWrapper, {
1345
- "innerClass": innerClass,
1346
- "themePreset": this.themePreset,
1347
- "theme": this.theme,
1348
- "innerClassName": "noSuggestion"
1349
- }, {
1350
- "default": function _default() {
1351
- return typeof renderNoSuggestion === 'function' ? renderNoSuggestion(currentValue) : renderNoSuggestion;
1352
- }
1353
- });
1354
- }
1355
- return null;
1356
- },
1357
- renderInputAddonBefore: function renderInputAddonBefore() {
1358
- var addonBefore = this.$slots.addonBefore;
1359
- if (addonBefore) {
1360
- var _slot;
1361
- return createVNode(InputAddon, {
1362
- "class": "addon-before"
1363
- }, _isSlot(_slot = addonBefore()) ? _slot : {
1364
- "default": function _default() {
1365
- return [_slot];
1366
- }
1367
- });
1368
- }
1369
- return null;
1370
- },
1371
- renderInputAddonAfter: function renderInputAddonAfter() {
1372
- var addonAfter = this.$slots.addonAfter;
1373
- if (addonAfter) {
1374
- var _slot2;
1375
- return createVNode(InputAddon, {
1376
- "class": "addon-after"
1377
- }, _isSlot(_slot2 = addonAfter()) ? _slot2 : {
1378
- "default": function _default() {
1379
- return [_slot2];
1380
- }
1381
- });
1382
- }
1383
- return null;
1384
- },
1385
- enterButtonOnClick: function enterButtonOnClick() {
1386
- this.triggerQuery({
1387
- isOpen: false,
1388
- value: this.currentValue,
1389
- customQuery: true
1390
- });
1391
- },
1392
- renderEnterButtonElement: function renderEnterButtonElement() {
1393
- var _this5 = this;
1394
- var _this$$props2 = this.$props,
1395
- enterButton = _this$$props2.enterButton,
1396
- innerClass = _this$$props2.innerClass;
1397
- var renderEnterButton = this.$slots.renderEnterButton;
1398
- if (enterButton) {
1399
- var getEnterButtonMarkup = function getEnterButtonMarkup() {
1400
- if (renderEnterButton) {
1401
- return renderEnterButton(_this5.enterButtonOnClick);
1402
- }
1403
- return createVNode(Button, {
1404
- "class": "enter-btn " + getClassName$1(innerClass, 'enter-button'),
1405
- "primary": true,
1406
- "onClick": _this5.enterButtonOnClick
1407
- }, {
1408
- "default": function _default() {
1409
- return [createTextVNode("Search")];
1410
- }
1411
- });
1412
- };
1413
- return createVNode("div", {
1414
- "class": "enter-button-wrapper"
1415
- }, [getEnterButtonMarkup()]);
1416
- }
1417
- return null;
1418
- },
1419
- renderIcons: function renderIcons() {
1420
- var _this6 = this;
1421
- var _slot3, _slot4, _slot5;
1422
- var _this$$props3 = this.$props,
1423
- iconPosition = _this$$props3.iconPosition,
1424
- showClear = _this$$props3.showClear,
1425
- innerClass = _this$$props3.innerClass,
1426
- getMicInstance = _this$$props3.getMicInstance,
1427
- showVoiceSearch = _this$$props3.showVoiceSearch,
1428
- showIcon = _this$$props3.showIcon;
1429
- var renderMic = this.$slots.renderMic || this.$props.renderMic;
1430
- var currentValue = this.$data.currentValue;
1431
- return createVNode("div", null, [createVNode(IconGroup, {
1432
- "groupPosition": "right",
1433
- "positionType": "absolute"
1434
- }, {
1435
- "default": function _default() {
1436
- return [currentValue && showClear && createVNode(IconWrapper, {
1437
- "onClick": _this6.clearValue,
1438
- "showIcon": showIcon,
1439
- "isClearIcon": true
1440
- }, _isSlot(_slot3 = _this6.renderCancelIcon()) ? _slot3 : {
1441
- "default": function _default() {
1442
- return [_slot3];
1443
- }
1444
- }), showVoiceSearch && createVNode(Mic, {
1445
- "getInstance": getMicInstance,
1446
- "render": renderMic,
1447
- "handleResult": _this6.handleVoiceResults,
1448
- "className": getClassName$1(innerClass, 'mic') || null
1449
- }, null), iconPosition === 'right' && showIcon && createVNode(IconWrapper, {
1450
- "onClick": _this6.handleSearchIconClick
1451
- }, _isSlot(_slot4 = _this6.renderIcon()) ? _slot4 : {
1452
- "default": function _default() {
1453
- return [_slot4];
1454
- }
1455
- })];
1456
- }
1457
- }), createVNode(IconGroup, {
1458
- "groupPosition": "left",
1459
- "positionType": "absolute"
1460
- }, {
1461
- "default": function _default() {
1462
- return [iconPosition === 'left' && showIcon && createVNode(IconWrapper, {
1463
- "onClick": _this6.handleSearchIconClick
1464
- }, _isSlot(_slot5 = _this6.renderIcon()) ? _slot5 : {
1465
- "default": function _default() {
1466
- return [_slot5];
1467
- }
1468
- })];
1469
- }
1470
- })]);
1471
- },
1472
- focusSearchBox: function focusSearchBox(event) {
1473
- var _this$$refs, _this$$refs$this$$pro;
1474
- var elt = event.target || event.srcElement;
1475
- var tagName = elt.tagName;
1476
- if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
1477
- // already in an input
1478
- return;
1479
- }
1480
- (_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
1481
- },
1482
- listenForFocusShortcuts: function listenForFocusShortcuts() {
1483
- var _this7 = this;
1484
- var _this$$props$focusSho = this.$props.focusShortcuts,
1485
- focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
1486
- if (isEmpty(focusShortcuts)) {
1487
- return;
1488
- }
1489
- var shortcutsString = parseFocusShortcuts(focusShortcuts).join(',');
1490
-
1491
- // handler for alphabets and other key combinations
1492
- hotkeys(shortcutsString,
1493
- // eslint-disable-next-line no-unused-vars
1494
- /* eslint-disable no-shadow */
1495
- function (event, handler) {
1496
- // Prevent the default refresh event under WINDOWS system
1497
- event.preventDefault();
1498
- _this7.focusSearchBox(event);
1499
- });
1500
-
1501
- // if one of modifier keys are used, they are handled below
1502
- hotkeys('*', function (event) {
1503
- var modifierKeys = extractModifierKeysFromFocusShortcuts(focusShortcuts);
1504
- if (modifierKeys.length === 0) return;
1505
- for (var index = 0; index < modifierKeys.length; index += 1) {
1506
- var element = modifierKeys[index];
1507
- if (hotkeys[element]) {
1508
- _this7.focusSearchBox(event);
1509
- break;
1510
- }
1511
- }
1512
- });
1513
- },
1514
- onAutofillClick: function onAutofillClick(suggestion) {
1515
- var value = suggestion.value;
1516
- this.isOpen = true;
1517
- this.currentValue = decodeHtml(value);
1518
- this.triggerDefaultQuery(value);
1519
- },
1520
- renderAutoFill: function renderAutoFill(suggestion) {
1521
- var _this8 = this;
1522
- var handleAutoFillClick = function handleAutoFillClick(e) {
1523
- e.stopPropagation();
1524
- _this8.onAutofillClick(suggestion);
1525
- };
1526
- /* 👇 avoid showing autofill for category suggestions👇 */
1527
- return suggestion._category ? null : createVNode(AutoFillSvg, {
1528
- "onClick": handleAutoFillClick
1529
- }, null);
1530
- },
1531
- renderTag: function renderTag(item) {
1532
- var _this9 = this;
1533
- var innerClass = this.$props.innerClass;
1534
- return createVNode(TagItem, {
1535
- "class": getClassName$1(innerClass, 'selected-tag') || ''
1536
- }, {
1537
- "default": function _default() {
1538
- return [createVNode("span", null, [item]), createVNode("span", {
1539
- "role": "img",
1540
- "aria-label": "delete-tag",
1541
- "class": "close-icon",
1542
- "onClick": function onClick() {
1543
- return _this9.clearTag(item);
1544
- }
1545
- }, [createVNode(CancelSvg, null, null)])];
1546
- }
1547
- });
1548
- },
1549
- clearAllTags: function clearAllTags() {
1550
- this.selectedTags = [];
1551
- this.setValue('', true, this.$props, causes.SUGGESTION_SELECT);
1552
- if (this.$props.value !== undefined) {
1553
- this.$emit('change', this.selectedTags, this.triggerQuery);
1554
- }
1555
- },
1556
- clearTag: function clearTag(tagValue) {
1557
- this.selectedTags = [].concat(this.selectedTags.filter(function (tag) {
1558
- return tag !== tagValue;
1559
- }));
1560
- this.setValue('', true, this.$props, causes.SUGGESTION_SELECT);
1561
- if (this.$props.value !== undefined) {
1562
- this.$emit('change', this.selectedTags, this.triggerQuery);
1563
- }
1564
- },
1565
- renderTags: function renderTags() {
1566
- var _this10 = this;
1567
- if (!Array.isArray(this.selectedTags)) {
1568
- return null;
1569
- }
1570
- var tagsList = [].concat(this.selectedTags);
1571
- var shouldRenderClearAllTag = tagsList.length > 1;
1572
- var renderSelectedTags = this.$slots.renderSelectedTags || this.$props.renderSelectedTags;
1573
- return renderSelectedTags ? renderSelectedTags({
1574
- values: this.selectedTags,
1575
- handleClear: this.clearTag,
1576
- handleClearAll: this.clearAllTags
1577
- }) : createVNode(TagsContainer, null, {
1578
- "default": function _default() {
1579
- return [tagsList.map(function (item) {
1580
- return _this10.renderTag(item);
1581
- }), shouldRenderClearAllTag && createVNode(TagItem, {
1582
- "class": getClassName$1(_this10.$props.innerClass, 'selected-tag') || ''
1583
- }, {
1584
- "default": function _default() {
1585
- return [createVNode("span", null, [createTextVNode("Clear All")]), createVNode("span", {
1586
- "role": "img",
1587
- "aria-label": "delete-tag",
1588
- "class": "close-icon",
1589
- "onClick": _this10.clearAllTags
1590
- }, [createVNode(CancelSvg, null, null)])];
1591
- }
1592
- })];
1593
- }
1594
- });
1595
- }
1596
- },
1597
- render: function render() {
1598
- var _this11 = this;
1599
- var expandSuggestionsContainer = this.$props.expandSuggestionsContainer;
1600
- var _this$$slots = this.$slots,
1601
- recentSearchesIcon = _this$$slots.recentSearchesIcon,
1602
- popularSearchesIcon = _this$$slots.popularSearchesIcon;
1603
- var hasSuggestions = Array.isArray(this.normalizedSuggestions) && this.normalizedSuggestions.length;
1604
- var renderItem = this.$slots.renderItem || this.$props.renderItem;
1605
- return createVNode(Container, {
1606
- "class": this.$props.className
1607
- }, {
1608
- "default": function _default() {
1609
- return [_this11.$props.title && createVNode(Title, {
1610
- "class": getClassName$1(_this11.$props.innerClass, 'title') || ''
1611
- }, {
1612
- "default": function _default() {
1613
- return [_this11.$props.title];
1614
- }
1615
- }), _this11.$props.autosuggest ? createVNode(Downshift, {
1616
- "id": _this11.$props.componentId + "-downshift",
1617
- "handleChange": _this11.onSuggestionSelected,
1618
- "handleMouseup": _this11.handleStateChange,
1619
- "isOpen": _this11.$data.isOpen
1620
- }, {
1621
- "default": function _default(_ref5) {
1622
- var getInputEvents = _ref5.getInputEvents,
1623
- getInputProps = _ref5.getInputProps,
1624
- getItemProps = _ref5.getItemProps,
1625
- getItemEvents = _ref5.getItemEvents,
1626
- isOpen = _ref5.isOpen,
1627
- highlightedIndex = _ref5.highlightedIndex,
1628
- setHighlightedIndex = _ref5.setHighlightedIndex;
1629
- var renderSuggestionsDropdown = function renderSuggestionsDropdown() {
1630
- var getIcon = function getIcon(iconType) {
1631
- switch (iconType) {
1632
- case suggestionTypes.Recent:
1633
- return recentSearchesIcon;
1634
- case suggestionTypes.Popular:
1635
- return popularSearchesIcon;
1636
- default:
1637
- return null;
1638
- }
1639
- };
1640
- return createVNode("div", null, [_this11.hasCustomRenderer && _this11.getComponent({
1641
- isOpen: isOpen,
1642
- getItemProps: getItemProps,
1643
- getItemEvents: getItemEvents,
1644
- highlightedIndex: highlightedIndex
1645
- }), _this11.renderErrorComponent(), !_this11.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
1646
- "class": suggestions(_this11.themePreset, _this11.theme) + " " + getClassName$1(_this11.$props.innerClass, 'list')
1647
- }, [_this11.normalizedSuggestions.map(function (item, index) {
1648
- return renderItem ? createVNode("li", mergeProps(getItemProps({
1649
- item: item
1650
- }), getItemEvents({
1651
- item: item
1652
- }), {
1653
- "key": index + 1 + "-" + item.value,
1654
- "style": {
1655
- backgroundColor: _this11.getBackgroundColor(highlightedIndex, index),
1656
- justifyContent: 'flex-start',
1657
- alignItems: 'center'
1658
- }
1659
- }), [renderItem(item)]) : createVNode("li", mergeProps(getItemProps({
1660
- item: item
1661
- }), _transformOn(getItemEvents({
1662
- item: item
1663
- })), {
1664
- "key": index + 1 + "-" + item.value,
1665
- "style": {
1666
- backgroundColor: _this11.getBackgroundColor(highlightedIndex, index),
1667
- justifyContent: 'flex-start',
1668
- alignItems: 'center'
1669
- }
1670
- }), [createVNode("div", {
1671
- "style": {
1672
- padding: '0 10px 0 0',
1673
- display: 'flex'
1674
- }
1675
- }, [createVNode(CustomSvg, {
1676
- "className": getClassName$1(_this11.$props.innerClass, item._suggestion_type + "-search-icon") || null,
1677
- "icon": getIcon(item._suggestion_type),
1678
- "type": item._suggestion_type + "-search-icon"
1679
- }, null)]), createVNode(SuggestionItem, {
1680
- "currentValue": _this11.currentValue,
1681
- "suggestion": item
1682
- }, null), _this11.renderAutoFill(item)]);
1683
- })]) : _this11.renderNoSuggestions(_this11.normalizedSuggestions)]);
1684
- };
1685
- return createVNode("div", {
1686
- "class": suggestionsContainer
1687
- }, [createVNode(InputGroup, null, {
1688
- "default": function _default() {
1689
- return [_this11.renderInputAddonBefore(), createVNode(InputWrapper, null, {
1690
- "default": function _default() {
1691
- return [createVNode(Input, mergeProps(_transformOn(getInputEvents({
1692
- onInput: _this11.onInputChange,
1693
- onBlur: function onBlur(e) {
1694
- _this11.$emit('blur', e, _this11.triggerQuery);
1695
- },
1696
- onFocus: _this11.handleFocus,
1697
- onKeyPress: function onKeyPress(e) {
1698
- _this11.$emit('keyPress', e, _this11.triggerQuery);
1699
- _this11.$emit('key-press', e, _this11.triggerQuery);
1700
- },
1701
- onKeyDown: function onKeyDown(e) {
1702
- return _this11.handleKeyDown(e, highlightedIndex);
1703
- },
1704
- onKeyUp: function onKeyUp(e) {
1705
- _this11.$emit('keyUp', e, _this11.triggerQuery);
1706
- _this11.$emit('key-up', e, _this11.triggerQuery);
1707
- },
1708
- onClick: function onClick() {
1709
- setHighlightedIndex(null);
1710
- }
1711
- })), {
1712
- "id": _this11.$props.componentId + "-input",
1713
- "showIcon": _this11.$props.showIcon,
1714
- "showClear": _this11.$props.showClear,
1715
- "iconPosition": _this11.$props.iconPosition,
1716
- "ref": _this11.$props.innerRef,
1717
- "class": getClassName$1(_this11.$props.innerClass, 'input'),
1718
- "placeholder": _this11.$props.placeholder,
1719
- "autoFocus": _this11.$props.autoFocus
1720
- }, getInputProps({
1721
- value: _this11.$data.currentValue === null ? '' : _this11.$data.currentValue
1722
- }), {
1723
- "themePreset": _this11.themePreset,
1724
- "autocomplete": "off"
1725
- }), null), _this11.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()];
1726
- }
1727
- }), _this11.renderInputAddonAfter(), _this11.renderEnterButtonElement()];
1728
- }
1729
- }), expandSuggestionsContainer && renderSuggestionsDropdown(), _this11.renderTags()]);
1730
- }
1731
- }) : createVNode("div", {
1732
- "class": suggestionsContainer
1733
- }, [createVNode(InputGroup, null, {
1734
- "default": function _default() {
1735
- return [_this11.renderInputAddonBefore(), createVNode(InputWrapper, null, {
1736
- "default": function _default() {
1737
- return [createVNode(Input, mergeProps(_transformOn({
1738
- blur: function blur(e) {
1739
- _this11.$emit('blur', e, _this11.triggerQuery);
1740
- },
1741
- keypress: function keypress(e) {
1742
- _this11.$emit('keyPress', e, _this11.triggerQuery);
1743
- _this11.$emit('key-press', e, _this11.triggerQuery);
1744
- },
1745
- input: _this11.onInputChange,
1746
- focus: function focus(e) {
1747
- _this11.$emit('focus', e, _this11.triggerQuery);
1748
- },
1749
- keydown: _this11.handleKeyDown,
1750
- keyup: function keyup(e) {
1751
- _this11.$emit('keyUp', e, _this11.triggerQuery);
1752
- _this11.$emit('key-up', e, _this11.triggerQuery);
1753
- }
1754
- }), {
1755
- "class": getClassName$1(_this11.$props.innerClass, 'input') || '',
1756
- "placeholder": _this11.$props.placeholder,
1757
- "autofocus": _this11.$props.autoFocus,
1758
- "value": _this11.$data.currentValue ? _this11.$data.currentValue : '',
1759
- "iconPosition": _this11.$props.iconPosition,
1760
- "showIcon": _this11.$props.showIcon,
1761
- "showClear": _this11.$props.showClear,
1762
- "ref": _this11.$props.innerRef,
1763
- "themePreset": _this11.themePreset
1764
- }), null), _this11.renderIcons()];
1765
- }
1766
- }), _this11.renderInputAddonAfter(), _this11.renderEnterButtonElement()];
1767
- }
1768
- })])];
1769
- }
1770
- });
1771
- },
1772
- destroyed: function destroyed() {
1773
- document.removeEventListener('keydown', this.onKeyDown);
1774
- }
1775
- });
1776
- SearchBox.hasInternalComponent = function () {
1777
- return true;
1778
- };
1779
- SearchBox.defaultQuery = function (value, props) {
1780
- var finalQuery = null;
1781
- finalQuery = {
1782
- bool: {
1783
- should: SearchBox.shouldQuery(value, props),
1784
- minimum_should_match: '1'
1785
- }
1786
- };
1787
- if (finalQuery && props.nestedField) {
1788
- return {
1789
- query: {
1790
- nested: {
1791
- path: props.nestedField,
1792
- query: finalQuery
1793
- }
1794
- }
1795
- };
1796
- }
1797
- return finalQuery;
1798
- };
1799
- SearchBox.shouldQuery = function (value, props) {
1800
- return {
1801
- query: {
1802
- queryFormat: props.queryFormat,
1803
- dataField: props.dataField,
1804
- value: value,
1805
- nestedField: props.nestedField,
1806
- queryString: props.queryString,
1807
- searchOperators: props.searchOperators
1808
- }
1809
- };
1810
- };
1811
- var mapStateToProps = function mapStateToProps(state, props) {
1812
- return {
1813
- selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
1814
- selectedCategory: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].category || null,
1815
- suggestions: state.hits[props.componentId] && state.hits[props.componentId].hits,
1816
- rawData: state.rawData[props.componentId],
1817
- aggregationData: state.compositeAggregations[props.componentId] || [],
1818
- themePreset: state.config.themePreset,
1819
- isLoading: !!state.isLoading[props.componentId + "_active"],
1820
- error: state.error[props.componentId],
1821
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
1822
- total: state.hits[props.componentId] && state.hits[props.componentId].total,
1823
- hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden
1824
- };
1825
- };
1826
- var mapDispatchToProps = {
1827
- updateQuery: updateQuery,
1828
- setCustomQuery: setCustomQuery,
1829
- setDefaultQuery: setDefaultQuery,
1830
- recordSuggestionClick: recordSuggestionClick
1831
- };
1832
- var SBConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(SearchBox), {
1833
- componentType: componentTypes.searchBox,
1834
- internalComponent: true
1835
- }));
1836
- SBConnected.name = SearchBox.name;
1837
- SBConnected.defaultQuery = SearchBox.defaultQuery;
1838
- SBConnected.shouldQuery = SearchBox.shouldQuery;
1839
- SBConnected.hasInternalComponent = SearchBox.hasInternalComponent;
1840
- SBConnected.install = function (Vue) {
1841
- Vue.component(SBConnected.name, SBConnected);
1842
- };
1843
- // Add componentType for SSR
1844
- SBConnected.componentType = componentTypes.searchBox;
1845
-
1846
- export default SBConnected;
1847
- export { SBConnected };