@appbaseio/reactivesearch-vue 1.33.9 → 1.33.11

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