@appbaseio/reactivesearch-vue 1.27.0-gamma.3 → 1.29.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@appbaseio/reactivesearch-vue.umd.js +923 -1096
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/{Button-11307285.js → Button-e0b7c1f6.js} +1 -1
- package/dist/cjs/{DataSearch-0ef14926.js → DataSearch-eec21890.js} +30 -13
- package/dist/cjs/DataSearch.js +1 -1
- package/dist/cjs/DynamicRangeSlider.js +24 -16
- package/dist/cjs/MultiDropdownList.js +34 -25
- package/dist/cjs/MultiList.js +33 -23
- package/dist/cjs/MultiRange.js +2 -3
- package/dist/cjs/RangeSlider.js +2 -3
- package/dist/cjs/ReactiveComponent.js +41 -72
- package/dist/cjs/ReactiveList.js +38 -48
- package/dist/cjs/SelectedFilters.js +6 -4
- package/dist/cjs/SingleDropdownList.js +21 -18
- package/dist/cjs/SingleList.js +19 -16
- package/dist/cjs/SingleRange.js +2 -3
- package/dist/cjs/ToggleButton.js +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/initReactivesearch.js +109 -77
- package/dist/cjs/{install-311df9cc.js → install-b05fef06.js} +111 -64
- package/dist/cjs/install.js +3 -3
- package/dist/cjs/version.js +1 -1
- package/dist/es/{Button-91561391.js → Button-33de88e6.js} +1 -1
- package/dist/es/{DataSearch-be45e960.js → DataSearch-42f547cd.js} +30 -13
- package/dist/es/DataSearch.js +1 -1
- package/dist/es/DynamicRangeSlider.js +24 -16
- package/dist/es/MultiDropdownList.js +34 -25
- package/dist/es/MultiList.js +33 -23
- package/dist/es/MultiRange.js +2 -3
- package/dist/es/RangeSlider.js +2 -3
- package/dist/es/ReactiveComponent.js +41 -72
- package/dist/es/ReactiveList.js +38 -48
- package/dist/es/SelectedFilters.js +6 -4
- package/dist/es/SingleDropdownList.js +21 -18
- package/dist/es/SingleList.js +19 -16
- package/dist/es/SingleRange.js +2 -3
- package/dist/es/ToggleButton.js +1 -1
- package/dist/es/index.js +4 -4
- package/dist/es/initReactivesearch.js +111 -79
- package/dist/es/{install-af797de0.js → install-bd448c02.js} +111 -64
- package/dist/es/install.js +3 -3
- package/dist/es/version.js +1 -1
- package/package.json +2 -2
package/dist/es/ToggleButton.js
CHANGED
|
@@ -5,7 +5,7 @@ import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
|
5
5
|
import 'emotion';
|
|
6
6
|
import '@appbaseio/vue-emotion';
|
|
7
7
|
import 'polished';
|
|
8
|
-
import { B as Button, t as toggleButtons } from './Button-
|
|
8
|
+
import { B as Button, t as toggleButtons } from './Button-33de88e6.js';
|
|
9
9
|
import { t as types } from './vueTypes-687b2304.js';
|
|
10
10
|
import '@appbaseio/reactivecore/lib/utils/transform';
|
|
11
11
|
import 'redux';
|
package/dist/es/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import '@appbaseio/reactivecore/lib/utils/helper';
|
|
|
6
6
|
import 'emotion';
|
|
7
7
|
import '@appbaseio/vue-emotion';
|
|
8
8
|
import 'polished';
|
|
9
|
-
import './Button-
|
|
9
|
+
import './Button-33de88e6.js';
|
|
10
10
|
import './vueTypes-687b2304.js';
|
|
11
11
|
export { default as ReactiveList } from './ReactiveList.js';
|
|
12
12
|
import '@appbaseio/reactivecore/lib/utils/transform';
|
|
@@ -23,14 +23,14 @@ import 'appbase-js';
|
|
|
23
23
|
import 'url-search-params-polyfill';
|
|
24
24
|
export { default as ReactiveBase } from './ReactiveBase.js';
|
|
25
25
|
import 'hotkeys-js';
|
|
26
|
-
export { D as DataSearch } from './DataSearch-
|
|
26
|
+
export { D as DataSearch } from './DataSearch-42f547cd.js';
|
|
27
27
|
import './CancelSvg-c2c03a35.js';
|
|
28
28
|
import './Input-e339e63a.js';
|
|
29
29
|
import 'compute-scroll-into-view';
|
|
30
30
|
import './Container-18b03fde.js';
|
|
31
31
|
import 'vue-highlight-words';
|
|
32
|
-
import { i as install } from './install-
|
|
33
|
-
export { S as SearchBox, i as install } from './install-
|
|
32
|
+
import { i as install } from './install-bd448c02.js';
|
|
33
|
+
export { S as SearchBox, i as install } from './install-bd448c02.js';
|
|
34
34
|
import '@appbaseio/reactivecore/lib/utils/suggestions';
|
|
35
35
|
import './FormControlList-704f8dee.js';
|
|
36
36
|
import './utils-64a2e5f0.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-0f24d612.js';
|
|
2
2
|
import { validProps, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
3
|
-
import { pushToAndClause, buildQuery } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
4
|
-
import { getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
|
|
3
|
+
import { pushToAndClause, buildQuery, extractQueryFromCustomQuery, getOptionsForCustomQuery } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
4
|
+
import { isSearchComponent, getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
|
|
5
5
|
import Appbase from 'appbase-js';
|
|
6
6
|
import valueReducer from '@appbaseio/reactivecore/lib/reducers/valueReducer';
|
|
7
7
|
import queryReducer from '@appbaseio/reactivecore/lib/reducers/queryReducer';
|
|
@@ -12,10 +12,10 @@ import dependencyTreeReducer from '@appbaseio/reactivecore/lib/reducers/dependen
|
|
|
12
12
|
import fetchGraphQL from '@appbaseio/reactivecore/lib/utils/graphQL';
|
|
13
13
|
import { isPropertyDefined } from '@appbaseio/reactivecore/lib/actions/utils';
|
|
14
14
|
|
|
15
|
-
var _excluded = ["aggs", "size"]
|
|
15
|
+
var _excluded = ["aggs", "size"],
|
|
16
|
+
_excluded2 = ["query"],
|
|
17
|
+
_excluded3 = ["query"];
|
|
16
18
|
var X_SEARCH_CLIENT = 'ReactiveSearch Vue';
|
|
17
|
-
var componentsWithHighlightQuery = [componentTypes.dataSearch, componentTypes.categorySearch];
|
|
18
|
-
var componentsWithOptions = [componentTypes.reactiveList, componentTypes.reactiveMap, componentTypes.singleList, componentTypes.multiList, componentTypes.tagCloud].concat(componentsWithHighlightQuery);
|
|
19
19
|
var componentsWithoutFilters = [componentTypes.numberBox, componentTypes.ratingsFilter];
|
|
20
20
|
var resultComponents = [componentTypes.reactiveList, componentTypes.reactiveMap];
|
|
21
21
|
|
|
@@ -49,23 +49,40 @@ function parseValue(value, component) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
return value;
|
|
52
|
-
}
|
|
52
|
+
} // Returns query DSL with query property and other options
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function getDefaultQuery(component, value) {
|
|
56
|
+
// get custom or default query of sensor components
|
|
57
|
+
var currentValue = parseValue(value, component); // get default query of result components
|
|
58
|
+
|
|
59
|
+
if (component.defaultQuery) {
|
|
60
|
+
var defaultQuery = component.defaultQuery(currentValue, component);
|
|
61
|
+
return _extends({
|
|
62
|
+
query: extractQueryFromCustomQuery(defaultQuery)
|
|
63
|
+
}, getOptionsForCustomQuery(defaultQuery));
|
|
64
|
+
}
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} // get custom or default query of sensor components
|
|
66
|
+
return component.source.defaultQuery ? {
|
|
67
|
+
query: component.source.defaultQuery(currentValue, component)
|
|
68
|
+
} : {};
|
|
69
|
+
} // Only results the query part
|
|
59
70
|
|
|
60
71
|
|
|
72
|
+
function getCustomQuery(component, value) {
|
|
73
|
+
// get custom or default query of sensor components
|
|
61
74
|
var currentValue = parseValue(value, component);
|
|
62
75
|
|
|
63
76
|
if (component.customQuery) {
|
|
64
77
|
var customQuery = component.customQuery(currentValue, component);
|
|
65
|
-
return
|
|
78
|
+
return _extends({
|
|
79
|
+
query: extractQueryFromCustomQuery(customQuery)
|
|
80
|
+
}, getOptionsForCustomQuery(customQuery));
|
|
66
81
|
}
|
|
67
82
|
|
|
68
|
-
return component.source.defaultQuery ?
|
|
83
|
+
return component.source.defaultQuery ? {
|
|
84
|
+
query: component.source.defaultQuery(currentValue, component)
|
|
85
|
+
} : null;
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
function initReactivesearch(componentCollection, searchState, settings) {
|
|
@@ -120,6 +137,11 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
120
137
|
}
|
|
121
138
|
});
|
|
122
139
|
var isInternalComponentPresent = false;
|
|
140
|
+
|
|
141
|
+
if (component.source.hasInternalComponent) {
|
|
142
|
+
isInternalComponentPresent = component.source.hasInternalComponent(component);
|
|
143
|
+
}
|
|
144
|
+
|
|
123
145
|
var isResultComponent = resultComponents.includes(componentType);
|
|
124
146
|
var internalComponent = component.componentId + "__internal";
|
|
125
147
|
var label = component.filterLabel || component.componentId;
|
|
@@ -151,74 +173,66 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
151
173
|
|
|
152
174
|
if (component.defaultQuery && typeof component.defaultQuery === 'function') {
|
|
153
175
|
defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
|
|
154
|
-
}
|
|
155
|
-
|
|
176
|
+
}
|
|
156
177
|
|
|
157
|
-
|
|
158
|
-
var options = component.source.generateQueryOptions ? component.source.generateQueryOptions(component) : null;
|
|
159
|
-
var highlightQuery = {};
|
|
178
|
+
var componentQueryOptions = {}; // [2] set query options - main component query (valid for result components)
|
|
160
179
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
if (component && component.source.generateQueryOptions) {
|
|
181
|
+
componentQueryOptions = _extends({}, componentQueryOptions, component.source.generateQueryOptions(component));
|
|
182
|
+
}
|
|
164
183
|
|
|
165
|
-
|
|
166
|
-
// eslint-disable-next-line
|
|
167
|
-
var _ref = options || {},
|
|
168
|
-
aggs = _ref.aggs,
|
|
169
|
-
size = _ref.size,
|
|
170
|
-
otherQueryOptions = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
171
|
-
|
|
172
|
-
if (aggs && Object.keys(aggs).length) {
|
|
173
|
-
isInternalComponentPresent = true; // query should be applied on the internal component
|
|
174
|
-
// to enable feeding the data to parent component
|
|
175
|
-
|
|
176
|
-
queryOptions = queryOptionsReducer(queryOptions, {
|
|
177
|
-
type: 'SET_QUERY_OPTIONS',
|
|
178
|
-
component: internalComponent,
|
|
179
|
-
options: {
|
|
180
|
-
aggs: aggs,
|
|
181
|
-
size: typeof size === 'undefined' ? 100 : size
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
} // sort, highlight, size, from - query should be applied on the main component
|
|
184
|
+
var highlightQuery = {};
|
|
185
185
|
|
|
186
|
+
if (component.source.highlightQuery) {
|
|
187
|
+
highlightQuery = component.source.highlightQuery(component);
|
|
188
|
+
}
|
|
186
189
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
if (componentQueryOptions && Object.keys(componentQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
191
|
+
// eslint-disable-next-line
|
|
192
|
+
var _ref = componentQueryOptions || {},
|
|
193
|
+
aggs = _ref.aggs,
|
|
194
|
+
size = _ref.size,
|
|
195
|
+
otherQueryOptions = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
196
|
+
|
|
197
|
+
if (aggs && Object.keys(aggs).length) {
|
|
198
|
+
isInternalComponentPresent = true;
|
|
199
|
+
componentQueryOptions = _extends({}, componentQueryOptions, {
|
|
200
|
+
aggs: aggs,
|
|
201
|
+
size: typeof size === 'undefined' ? 100 : size
|
|
202
|
+
});
|
|
203
|
+
} // sort, highlight, size, from - query should be applied on the main component
|
|
190
204
|
|
|
191
|
-
var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
|
|
192
|
-
size: size
|
|
193
|
-
});
|
|
194
205
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
206
|
+
if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
207
|
+
if (!otherQueryOptions) otherQueryOptions = {};
|
|
208
|
+
if (!highlightQuery) highlightQuery = {};
|
|
198
209
|
|
|
199
|
-
|
|
200
|
-
|
|
210
|
+
var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
|
|
211
|
+
size: size
|
|
212
|
+
});
|
|
201
213
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
214
|
+
if (isInternalComponentPresent) {
|
|
215
|
+
mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery);
|
|
216
|
+
}
|
|
205
217
|
|
|
206
|
-
|
|
207
|
-
|
|
218
|
+
if (isResultComponent) {
|
|
219
|
+
var currentPage = component.currentPage ? component.currentPage - 1 : 0;
|
|
208
220
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
size: resultSize,
|
|
212
|
-
from: from
|
|
213
|
-
});
|
|
221
|
+
if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
|
|
222
|
+
currentPage = selectedValues[component.componentId].value - 1 || 0;
|
|
214
223
|
}
|
|
215
224
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
225
|
+
var resultSize = component.size || 10;
|
|
226
|
+
var from = currentPage * resultSize; // Update props for RS API
|
|
227
|
+
|
|
228
|
+
compProps.from = from;
|
|
229
|
+
mainQueryOptions = _extends({}, mainQueryOptions, highlightQuery, {
|
|
230
|
+
size: resultSize,
|
|
231
|
+
from: from
|
|
220
232
|
});
|
|
221
233
|
}
|
|
234
|
+
|
|
235
|
+
componentQueryOptions = _extends({}, componentQueryOptions, mainQueryOptions);
|
|
222
236
|
}
|
|
223
237
|
} // [3] set dependency tree
|
|
224
238
|
|
|
@@ -236,25 +250,42 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
236
250
|
react: react
|
|
237
251
|
});
|
|
238
252
|
} // [4] set query list
|
|
253
|
+
// Do not set default query for suggestions
|
|
239
254
|
|
|
240
255
|
|
|
241
|
-
if (
|
|
242
|
-
var
|
|
243
|
-
|
|
256
|
+
if (isInternalComponentPresent && !isSearchComponent(component.componentType)) {
|
|
257
|
+
var _ref2 = getDefaultQuery(component, value) || {},
|
|
258
|
+
defaultQuery = _ref2.query,
|
|
259
|
+
defaultQueryOptions = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
244
260
|
|
|
245
261
|
queryList = queryReducer(queryList, {
|
|
246
262
|
type: 'SET_QUERY',
|
|
247
263
|
component: internalComponent,
|
|
248
|
-
query:
|
|
264
|
+
query: defaultQuery
|
|
249
265
|
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
query: getQuery(component, value, componentType)
|
|
266
|
+
queryOptions = queryOptionsReducer(queryOptions, {
|
|
267
|
+
type: 'SET_QUERY_OPTIONS',
|
|
268
|
+
component: internalComponent,
|
|
269
|
+
options: _extends({}, componentQueryOptions, defaultQueryOptions)
|
|
255
270
|
});
|
|
256
|
-
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var _ref3 = getCustomQuery(component, value) || {},
|
|
274
|
+
query = _ref3.query,
|
|
275
|
+
options = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
257
276
|
|
|
277
|
+
var customQuery = query; // set custom query for main component
|
|
278
|
+
|
|
279
|
+
queryList = queryReducer(queryList, {
|
|
280
|
+
type: 'SET_QUERY',
|
|
281
|
+
component: component.componentId,
|
|
282
|
+
query: customQuery
|
|
283
|
+
});
|
|
284
|
+
queryOptions = queryOptionsReducer(queryOptions, {
|
|
285
|
+
type: 'SET_QUERY_OPTIONS',
|
|
286
|
+
component: component.componentId,
|
|
287
|
+
options: _extends({}, options)
|
|
288
|
+
}); // Set component type in component props
|
|
258
289
|
|
|
259
290
|
compProps.componentType = componentType;
|
|
260
291
|
componentProps[component.componentId] = compProps;
|
|
@@ -277,9 +308,10 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
277
308
|
queryObj = _buildQuery.queryObj,
|
|
278
309
|
options = _buildQuery.options;
|
|
279
310
|
|
|
280
|
-
var
|
|
311
|
+
var componentQueryOptions = options;
|
|
312
|
+
var validOptions = ['aggs', 'from', 'sort']; // check if query or componentQueryOptions are valid - non-empty
|
|
281
313
|
|
|
282
|
-
if (queryObj && !!Object.keys(queryObj).length ||
|
|
314
|
+
if (queryObj && !!Object.keys(queryObj).length || componentQueryOptions && Object.keys(componentQueryOptions).some(function (item) {
|
|
283
315
|
return validOptions.includes(item);
|
|
284
316
|
})) {
|
|
285
317
|
var _extends2;
|
|
@@ -294,7 +326,7 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
294
326
|
|
|
295
327
|
var currentQuery = _extends({
|
|
296
328
|
query: _extends({}, queryObj)
|
|
297
|
-
},
|
|
329
|
+
}, componentQueryOptions, queryOptions[component.componentId]);
|
|
298
330
|
|
|
299
331
|
queryLog = _extends({}, queryLog, (_extends2 = {}, _extends2[component.componentId] = currentQuery, _extends2));
|
|
300
332
|
|
|
@@ -4,6 +4,7 @@ import VueTypes from 'vue-types';
|
|
|
4
4
|
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
5
5
|
import { getQueryOptions, suggestionTypes } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
6
6
|
import styled from '@appbaseio/vue-emotion';
|
|
7
|
+
import { B as Button } from './Button-33de88e6.js';
|
|
7
8
|
import { t as types } from './vueTypes-687b2304.js';
|
|
8
9
|
import ReactiveList from './ReactiveList.js';
|
|
9
10
|
import { h as hasCustomRenderer, i as isQueryIdentical, g as getComponent, u as updateDefaultQuery, f as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-78920565.js';
|
|
@@ -11,7 +12,7 @@ import { C as ComponentWrapper } from './ComponentWrapper-0f3431d1.js';
|
|
|
11
12
|
import { T as Title } from './Title-3522ff56.js';
|
|
12
13
|
import ReactiveBase from './ReactiveBase.js';
|
|
13
14
|
import hotkeys from 'hotkeys-js';
|
|
14
|
-
import { S as SearchSvg, a as SuggestionWrapper, I as InputAddon, M as Mic, b as InputGroup, C as CustomSvg, c as SuggestionItem, D as DataSearch } from './DataSearch-
|
|
15
|
+
import { S as SearchSvg, a as SuggestionWrapper, I as InputAddon, M as Mic, b as InputGroup, C as CustomSvg, c as SuggestionItem, D as DataSearch } from './DataSearch-42f547cd.js';
|
|
15
16
|
import { C as CancelSvg, a as IconGroup, I as IconWrapper, D as Downshift, b as InputWrapper } from './CancelSvg-c2c03a35.js';
|
|
16
17
|
import { s as suggestionsContainer, I as Input, a as suggestions } from './Input-e339e63a.js';
|
|
17
18
|
import { C as Container } from './Container-18b03fde.js';
|
|
@@ -195,7 +196,9 @@ var SearchBox = {
|
|
|
195
196
|
applyStopwords: VueTypes.bool,
|
|
196
197
|
customStopwords: types.stringArray,
|
|
197
198
|
onData: types.func,
|
|
198
|
-
renderItem: types.func
|
|
199
|
+
renderItem: types.func,
|
|
200
|
+
enterButton: VueTypes.bool.def(false),
|
|
201
|
+
renderEnterButton: VueTypes.any
|
|
199
202
|
},
|
|
200
203
|
mounted: function mounted() {
|
|
201
204
|
this.listenForFocusShortcuts();
|
|
@@ -308,7 +311,7 @@ var SearchBox = {
|
|
|
308
311
|
this.triggerDefaultQuery(value);
|
|
309
312
|
} else if (this.$props.autosuggest) {
|
|
310
313
|
this.triggerDefaultQuery(value);
|
|
311
|
-
} else {
|
|
314
|
+
} else if (!this.$props.enterButton) {
|
|
312
315
|
this.triggerCustomQuery(value);
|
|
313
316
|
}
|
|
314
317
|
},
|
|
@@ -549,10 +552,18 @@ var SearchBox = {
|
|
|
549
552
|
this.onValueSelectedHandler('', causes.CLEAR_VALUE);
|
|
550
553
|
},
|
|
551
554
|
handleKeyDown: function handleKeyDown(event, highlightedIndex) {
|
|
555
|
+
if (highlightedIndex === void 0) {
|
|
556
|
+
highlightedIndex = null;
|
|
557
|
+
}
|
|
558
|
+
|
|
552
559
|
// if a suggestion was selected, delegate the handling to suggestion handler
|
|
553
|
-
if (event.key === 'Enter'
|
|
554
|
-
this.
|
|
555
|
-
|
|
560
|
+
if (event.key === 'Enter') {
|
|
561
|
+
if (this.$props.autosuggest === false) {
|
|
562
|
+
this.enterButtonOnClick();
|
|
563
|
+
} else if (highlightedIndex === null) {
|
|
564
|
+
this.setValue(event.target.value, true);
|
|
565
|
+
this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
|
|
566
|
+
}
|
|
556
567
|
} // Need to review
|
|
557
568
|
|
|
558
569
|
|
|
@@ -724,15 +735,55 @@ var SearchBox = {
|
|
|
724
735
|
|
|
725
736
|
return null;
|
|
726
737
|
},
|
|
727
|
-
|
|
738
|
+
enterButtonOnClick: function enterButtonOnClick() {
|
|
739
|
+
this.triggerQuery({
|
|
740
|
+
isOpen: false,
|
|
741
|
+
value: this.currentValue,
|
|
742
|
+
customQuery: true
|
|
743
|
+
});
|
|
744
|
+
},
|
|
745
|
+
renderEnterButtonElement: function renderEnterButtonElement() {
|
|
746
|
+
var _this4 = this;
|
|
747
|
+
|
|
728
748
|
var h = this.$createElement;
|
|
729
749
|
var _this$$props4 = this.$props,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
750
|
+
enterButton = _this$$props4.enterButton,
|
|
751
|
+
innerClass = _this$$props4.innerClass;
|
|
752
|
+
var renderEnterButton = this.$scopedSlots.renderEnterButton;
|
|
753
|
+
|
|
754
|
+
if (enterButton) {
|
|
755
|
+
var getEnterButtonMarkup = function getEnterButtonMarkup() {
|
|
756
|
+
if (renderEnterButton) {
|
|
757
|
+
return renderEnterButton(_this4.enterButtonOnClick);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
return h(Button, {
|
|
761
|
+
"class": "enter-btn " + getClassName(innerClass, 'enterButton'),
|
|
762
|
+
"attrs": {
|
|
763
|
+
"primary": true
|
|
764
|
+
},
|
|
765
|
+
"on": {
|
|
766
|
+
"click": _this4.enterButtonOnClick
|
|
767
|
+
}
|
|
768
|
+
}, ["Search"]);
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
return h("div", {
|
|
772
|
+
"class": "enter-button-wrapper"
|
|
773
|
+
}, [getEnterButtonMarkup()]);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return null;
|
|
777
|
+
},
|
|
778
|
+
renderIcons: function renderIcons() {
|
|
779
|
+
var h = this.$createElement;
|
|
780
|
+
var _this$$props5 = this.$props,
|
|
781
|
+
iconPosition = _this$$props5.iconPosition,
|
|
782
|
+
showClear = _this$$props5.showClear,
|
|
783
|
+
innerClass = _this$$props5.innerClass,
|
|
784
|
+
getMicInstance = _this$$props5.getMicInstance,
|
|
785
|
+
showVoiceSearch = _this$$props5.showVoiceSearch,
|
|
786
|
+
showIcon = _this$$props5.showIcon;
|
|
736
787
|
var renderMic = this.$scopedSlots.renderMic || this.$props.renderMic;
|
|
737
788
|
var currentValue = this.$data.currentValue;
|
|
738
789
|
return h("div", [h(IconGroup, {
|
|
@@ -784,7 +835,7 @@ var SearchBox = {
|
|
|
784
835
|
(_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
|
|
785
836
|
},
|
|
786
837
|
listenForFocusShortcuts: function listenForFocusShortcuts() {
|
|
787
|
-
var
|
|
838
|
+
var _this5 = this;
|
|
788
839
|
|
|
789
840
|
var _this$$props$focusSho = this.$props.focusShortcuts,
|
|
790
841
|
focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
|
|
@@ -802,7 +853,7 @@ var SearchBox = {
|
|
|
802
853
|
// Prevent the default refresh event under WINDOWS system
|
|
803
854
|
event.preventDefault();
|
|
804
855
|
|
|
805
|
-
|
|
856
|
+
_this5.focusSearchBox(event);
|
|
806
857
|
}); // if one of modifier keys are used, they are handled below
|
|
807
858
|
|
|
808
859
|
hotkeys('*', function (event) {
|
|
@@ -813,7 +864,7 @@ var SearchBox = {
|
|
|
813
864
|
var element = modifierKeys[index];
|
|
814
865
|
|
|
815
866
|
if (hotkeys[element]) {
|
|
816
|
-
|
|
867
|
+
_this5.focusSearchBox(event);
|
|
817
868
|
|
|
818
869
|
break;
|
|
819
870
|
}
|
|
@@ -827,14 +878,14 @@ var SearchBox = {
|
|
|
827
878
|
this.triggerDefaultQuery(value);
|
|
828
879
|
},
|
|
829
880
|
renderAutoFill: function renderAutoFill(suggestion) {
|
|
830
|
-
var
|
|
881
|
+
var _this6 = this;
|
|
831
882
|
|
|
832
883
|
var h = this.$createElement;
|
|
833
884
|
|
|
834
885
|
var handleAutoFillClick = function handleAutoFillClick(e) {
|
|
835
886
|
e.stopPropagation();
|
|
836
887
|
|
|
837
|
-
|
|
888
|
+
_this6.onAutofillClick(suggestion);
|
|
838
889
|
};
|
|
839
890
|
/* 👇 avoid showing autofill for category suggestions👇 */
|
|
840
891
|
|
|
@@ -847,12 +898,12 @@ var SearchBox = {
|
|
|
847
898
|
}
|
|
848
899
|
},
|
|
849
900
|
render: function render() {
|
|
850
|
-
var
|
|
901
|
+
var _this7 = this;
|
|
851
902
|
|
|
852
903
|
var h = arguments[0];
|
|
853
|
-
var _this$$
|
|
854
|
-
theme = _this$$
|
|
855
|
-
expandSuggestionsContainer = _this$$
|
|
904
|
+
var _this$$props6 = this.$props,
|
|
905
|
+
theme = _this$$props6.theme,
|
|
906
|
+
expandSuggestionsContainer = _this$$props6.expandSuggestionsContainer;
|
|
856
907
|
var _this$$scopedSlots = this.$scopedSlots,
|
|
857
908
|
recentSearchesIcon = _this$$scopedSlots.recentSearchesIcon,
|
|
858
909
|
popularSearchesIcon = _this$$scopedSlots.popularSearchesIcon;
|
|
@@ -893,14 +944,14 @@ var SearchBox = {
|
|
|
893
944
|
}
|
|
894
945
|
};
|
|
895
946
|
|
|
896
|
-
return h("div", [
|
|
947
|
+
return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
|
|
897
948
|
isOpen: isOpen,
|
|
898
949
|
getItemProps: getItemProps,
|
|
899
950
|
getItemEvents: getItemEvents,
|
|
900
951
|
highlightedIndex: highlightedIndex
|
|
901
|
-
}),
|
|
902
|
-
"class": suggestions(
|
|
903
|
-
}, [
|
|
952
|
+
}), _this7.renderErrorComponent(), !_this7.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
|
|
953
|
+
"class": suggestions(_this7.themePreset, theme) + " " + getClassName(_this7.$props.innerClass, 'list')
|
|
954
|
+
}, [_this7.normalizedSuggestions.map(function (item, index) {
|
|
904
955
|
return renderItem ? h("li", {
|
|
905
956
|
"domProps": _extends({}, getItemProps({
|
|
906
957
|
item: item
|
|
@@ -910,7 +961,7 @@ var SearchBox = {
|
|
|
910
961
|
})),
|
|
911
962
|
"key": index + 1 + "-" + item.value,
|
|
912
963
|
"style": {
|
|
913
|
-
backgroundColor:
|
|
964
|
+
backgroundColor: _this7.getBackgroundColor(highlightedIndex, index),
|
|
914
965
|
justifyContent: 'flex-start',
|
|
915
966
|
alignItems: 'center'
|
|
916
967
|
}
|
|
@@ -923,7 +974,7 @@ var SearchBox = {
|
|
|
923
974
|
})),
|
|
924
975
|
"key": index + 1 + "-" + item.value,
|
|
925
976
|
"style": {
|
|
926
|
-
backgroundColor:
|
|
977
|
+
backgroundColor: _this7.getBackgroundColor(highlightedIndex, index),
|
|
927
978
|
justifyContent: 'flex-start',
|
|
928
979
|
alignItems: 'center'
|
|
929
980
|
}
|
|
@@ -934,61 +985,61 @@ var SearchBox = {
|
|
|
934
985
|
}
|
|
935
986
|
}, [h(CustomSvg, {
|
|
936
987
|
"attrs": {
|
|
937
|
-
"className": getClassName(
|
|
988
|
+
"className": getClassName(_this7.$props.innerClass, item._suggestion_type + "-search-icon") || null,
|
|
938
989
|
"icon": getIcon(item._suggestion_type),
|
|
939
990
|
"type": item._suggestion_type + "-search-icon"
|
|
940
991
|
}
|
|
941
992
|
})]), h(SuggestionItem, {
|
|
942
993
|
"attrs": {
|
|
943
|
-
"currentValue":
|
|
994
|
+
"currentValue": _this7.currentValue,
|
|
944
995
|
"suggestion": item
|
|
945
996
|
}
|
|
946
|
-
}),
|
|
947
|
-
})]) :
|
|
997
|
+
}), _this7.renderAutoFill(item)]);
|
|
998
|
+
})]) : _this7.renderNoSuggestions(_this7.normalizedSuggestions)]);
|
|
948
999
|
};
|
|
949
1000
|
|
|
950
1001
|
return h("div", {
|
|
951
1002
|
"class": suggestionsContainer
|
|
952
|
-
}, [h(InputGroup, [
|
|
1003
|
+
}, [h(InputGroup, [_this7.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
|
|
953
1004
|
"attrs": {
|
|
954
|
-
"id":
|
|
955
|
-
"showIcon":
|
|
956
|
-
"showClear":
|
|
957
|
-
"iconPosition":
|
|
958
|
-
"placeholder":
|
|
959
|
-
"autoFocus":
|
|
960
|
-
"themePreset":
|
|
1005
|
+
"id": _this7.$props.componentId + "-input",
|
|
1006
|
+
"showIcon": _this7.$props.showIcon,
|
|
1007
|
+
"showClear": _this7.$props.showClear,
|
|
1008
|
+
"iconPosition": _this7.$props.iconPosition,
|
|
1009
|
+
"placeholder": _this7.$props.placeholder,
|
|
1010
|
+
"autoFocus": _this7.$props.autoFocus,
|
|
1011
|
+
"themePreset": _this7.themePreset,
|
|
961
1012
|
"autocomplete": "off"
|
|
962
1013
|
},
|
|
963
|
-
"ref":
|
|
964
|
-
"class": getClassName(
|
|
1014
|
+
"ref": _this7.$props.innerRef,
|
|
1015
|
+
"class": getClassName(_this7.$props.innerClass, 'input'),
|
|
965
1016
|
"on": _extends({}, getInputEvents({
|
|
966
|
-
onInput:
|
|
1017
|
+
onInput: _this7.onInputChange,
|
|
967
1018
|
onBlur: function onBlur(e) {
|
|
968
|
-
|
|
1019
|
+
_this7.$emit('blur', e, _this7.triggerQuery);
|
|
969
1020
|
},
|
|
970
|
-
onFocus:
|
|
1021
|
+
onFocus: _this7.handleFocus,
|
|
971
1022
|
onKeyPress: function onKeyPress(e) {
|
|
972
|
-
|
|
1023
|
+
_this7.$emit('keyPress', e, _this7.triggerQuery);
|
|
973
1024
|
|
|
974
|
-
|
|
1025
|
+
_this7.$emit('key-press', e, _this7.triggerQuery);
|
|
975
1026
|
},
|
|
976
1027
|
onKeyDown: function onKeyDown(e) {
|
|
977
|
-
return
|
|
1028
|
+
return _this7.handleKeyDown(e, highlightedIndex);
|
|
978
1029
|
},
|
|
979
1030
|
onKeyUp: function onKeyUp(e) {
|
|
980
|
-
|
|
1031
|
+
_this7.$emit('keyUp', e, _this7.triggerQuery);
|
|
981
1032
|
|
|
982
|
-
|
|
1033
|
+
_this7.$emit('key-up', e, _this7.triggerQuery);
|
|
983
1034
|
},
|
|
984
1035
|
onClick: function onClick() {
|
|
985
1036
|
setHighlightedIndex(null);
|
|
986
1037
|
}
|
|
987
1038
|
})),
|
|
988
1039
|
"domProps": _extends({}, getInputProps({
|
|
989
|
-
value:
|
|
1040
|
+
value: _this7.$data.currentValue === null ? '' : _this7.$data.currentValue
|
|
990
1041
|
}))
|
|
991
|
-
}),
|
|
1042
|
+
}), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()]), _this7.renderInputAddonAfter(), _this7.renderEnterButtonElement()]), expandSuggestionsContainer && renderSuggestionsDropdown()]);
|
|
992
1043
|
}
|
|
993
1044
|
}
|
|
994
1045
|
}) : h("div", {
|
|
@@ -1004,26 +1055,22 @@ var SearchBox = {
|
|
|
1004
1055
|
},
|
|
1005
1056
|
"on": _extends({}, {
|
|
1006
1057
|
blur: function blur(e) {
|
|
1007
|
-
|
|
1058
|
+
_this7.$emit('blur', e, _this7.triggerQuery);
|
|
1008
1059
|
},
|
|
1009
1060
|
keypress: function keypress(e) {
|
|
1010
|
-
|
|
1061
|
+
_this7.$emit('keyPress', e, _this7.triggerQuery);
|
|
1011
1062
|
|
|
1012
|
-
|
|
1063
|
+
_this7.$emit('key-press', e, _this7.triggerQuery);
|
|
1013
1064
|
},
|
|
1014
1065
|
input: this.onInputChange,
|
|
1015
1066
|
focus: function focus(e) {
|
|
1016
|
-
|
|
1017
|
-
},
|
|
1018
|
-
keydown: function keydown(e) {
|
|
1019
|
-
_this6.$emit('keyDown', e, _this6.triggerQuery);
|
|
1020
|
-
|
|
1021
|
-
_this6.$emit('key-down', e, _this6.triggerQuery);
|
|
1067
|
+
_this7.$emit('focus', e, _this7.triggerQuery);
|
|
1022
1068
|
},
|
|
1069
|
+
keydown: this.handleKeyDown,
|
|
1023
1070
|
keyup: function keyup(e) {
|
|
1024
|
-
|
|
1071
|
+
_this7.$emit('keyUp', e, _this7.triggerQuery);
|
|
1025
1072
|
|
|
1026
|
-
|
|
1073
|
+
_this7.$emit('key-up', e, _this7.triggerQuery);
|
|
1027
1074
|
}
|
|
1028
1075
|
}),
|
|
1029
1076
|
"domProps": _extends({}, {
|
|
@@ -1031,7 +1078,7 @@ var SearchBox = {
|
|
|
1031
1078
|
value: this.$data.currentValue ? this.$data.currentValue : ''
|
|
1032
1079
|
}),
|
|
1033
1080
|
"ref": this.$props.innerRef
|
|
1034
|
-
}), this.renderIcons()]), this.renderInputAddonAfter()])])]);
|
|
1081
|
+
}), this.renderIcons()]), this.renderInputAddonAfter(), this.renderEnterButtonElement()])])]);
|
|
1035
1082
|
},
|
|
1036
1083
|
destroyed: function destroyed() {
|
|
1037
1084
|
document.removeEventListener('keydown', this.onKeyDown);
|