@appbaseio/reactivesearch-vue 3.0.0-rc.5.alpha.4 → 3.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@appbaseio/reactivesearch-vue.umd.js +39803 -35283
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +32 -32
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/{Button-d4da7470.js → Button-9e179864.js} +13 -6
- package/dist/cjs/{ComponentWrapper-9146d811.js → ComponentWrapper-0b9ffb1a.js} +3 -0
- package/dist/cjs/DropDown-aef75c14.js +702 -0
- package/dist/cjs/DynamicRangeSlider.js +1 -1
- package/dist/cjs/{Input-497be42a.js → Input-56eba499.js} +71 -1
- package/dist/cjs/MultiDropdownList.js +6 -6
- package/dist/cjs/MultiList.js +3 -3
- package/dist/cjs/MultiRange.js +2 -2
- package/dist/cjs/{Pagination-b953a80a.js → Pagination-58a0cf3f.js} +2 -2
- package/dist/cjs/RangeInput.js +3 -3
- package/dist/cjs/RangeSlider.js +2 -2
- package/dist/cjs/ReactiveBase.js +4 -4
- package/dist/cjs/ReactiveComponent.js +2 -2
- package/dist/cjs/ReactiveGoogleMap.js +6 -5
- package/dist/cjs/ReactiveList.js +4 -4
- package/dist/cjs/ResultCard.js +1 -1
- package/dist/cjs/ResultList.js +1 -1
- package/dist/cjs/SelectedFilters.js +3 -2
- package/dist/cjs/SingleDropdownList.js +6 -6
- package/dist/cjs/SingleList.js +3 -3
- package/dist/cjs/SingleRange.js +2 -2
- package/dist/cjs/ToggleButton.js +4 -3
- package/dist/cjs/index.js +14 -13
- package/dist/cjs/install-70991c13.js +3820 -0
- package/dist/cjs/install.js +9 -9
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/{vueTypes-1bf00978.js → vueTypes-a5f1745e.js} +18 -0
- package/dist/es/{Button-fd869491.js → Button-c2ff5178.js} +13 -6
- package/dist/es/{ComponentWrapper-8a3c388d.js → ComponentWrapper-a2635cfc.js} +3 -0
- package/dist/es/DropDown-39fedff8.js +693 -0
- package/dist/es/DynamicRangeSlider.js +1 -1
- package/dist/es/{Input-f7499ef8.js → Input-11d211d2.js} +71 -2
- package/dist/es/MultiDropdownList.js +6 -6
- package/dist/es/MultiList.js +3 -3
- package/dist/es/MultiRange.js +2 -2
- package/dist/es/{Pagination-c2745bec.js → Pagination-ae401c33.js} +2 -2
- package/dist/es/RangeInput.js +3 -3
- package/dist/es/RangeSlider.js +2 -2
- package/dist/es/ReactiveBase.js +4 -4
- package/dist/es/ReactiveComponent.js +2 -2
- package/dist/es/ReactiveGoogleMap.js +6 -5
- package/dist/es/ReactiveList.js +4 -4
- package/dist/es/ResultCard.js +1 -1
- package/dist/es/ResultList.js +1 -1
- package/dist/es/SelectedFilters.js +3 -2
- package/dist/es/SingleDropdownList.js +6 -6
- package/dist/es/SingleList.js +3 -3
- package/dist/es/SingleRange.js +2 -2
- package/dist/es/ToggleButton.js +4 -3
- package/dist/es/index.js +11 -11
- package/dist/es/install-8296e8da.js +3812 -0
- package/dist/es/install.js +9 -9
- package/dist/es/version.js +1 -1
- package/dist/es/{vueTypes-f1923c72.js → vueTypes-09cab4d3.js} +18 -0
- package/package.json +7 -5
- package/dist/cjs/CancelSvg-ab0f8b23.js +0 -409
- package/dist/cjs/DropDown-e7125b72.js +0 -299
- package/dist/cjs/SearchBox.js +0 -1853
- package/dist/cjs/install-3c4520bf.js +0 -874
- package/dist/es/CancelSvg-e7ae49e9.js +0 -401
- package/dist/es/DropDown-13afb4d2.js +0 -295
- package/dist/es/SearchBox.js +0 -1847
- package/dist/es/install-ff8b0750.js +0 -868
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
import { helper } from '@appbaseio/reactivecore';
|
|
2
|
+
import _transformOn from '@vue/babel-helper-vue-transform-on';
|
|
3
|
+
import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
|
|
4
|
+
import { createVNode, createTextVNode, mergeProps } from 'vue';
|
|
5
|
+
import VueTypes from 'vue-types';
|
|
6
|
+
import { styled } from '@appbaseio/vue-emotion';
|
|
7
|
+
import { t as types } from './vueTypes-09cab4d3.js';
|
|
8
|
+
import { a as isFunction } from './index-882489e1.js';
|
|
9
|
+
import { s as suggestionsContainer, a as suggestions, I as Input } from './Input-11d211d2.js';
|
|
10
|
+
import computeScrollIntoView from 'compute-scroll-into-view';
|
|
11
|
+
import { replaceDiacritics } from '@appbaseio/reactivecore/lib/utils/suggestions';
|
|
12
|
+
|
|
13
|
+
var _templateObject;
|
|
14
|
+
var InputWrapper = styled('span')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\tflex: 1;\n\tposition: relative;\n\theight: 42px;\n"])));
|
|
15
|
+
|
|
16
|
+
var _templateObject$1;
|
|
17
|
+
var IconGroup = styled('div')(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tgrid-gap: 6px;\n\tmargin: 0 10px;\n\theight: 100%;\n\n\t", ";\n\n\t", ";\n\n\t", ";\n"])), function (_ref) {
|
|
18
|
+
var positionType = _ref.positionType;
|
|
19
|
+
if (positionType === 'absolute') {
|
|
20
|
+
return "\n\t\t\t\tposition: absolute;\n\t\t\t\ttop: 50%;\n\t\t\t\ttransform: translateY(-50%);\n\t\t\t";
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}, function (_ref2) {
|
|
24
|
+
var groupPosition = _ref2.groupPosition;
|
|
25
|
+
return groupPosition === 'right' ? "\n\t\t\t\t\tright: 0;\n\t\t\t " : "\n\t\t\t\t\tleft: 0;\n\t\t\t ";
|
|
26
|
+
}, function (_ref3) {
|
|
27
|
+
var enableAI = _ref3.enableAI;
|
|
28
|
+
return enableAI ? "\n\t\ttop: 0%;\n\t transform: translateY(0);\n \theight: 42px;\n\t" : '';
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
var _templateObject$2;
|
|
32
|
+
var IconWrapper = styled('div')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmax-width: 23px;\n\twidth: max-content;\n\tcursor: pointer;\n\theight: 100%;\n\tmin-width: 20px;\n\n\tsvg.search-icon {\n\t\tfill: ", ";\n\t\ttransform: scale(1.5);\n\t}\n\n\tsvg.cancel-icon {\n\t\tfill: ", ";\n\t}\n"])), function (_ref) {
|
|
33
|
+
var _ref$theme = _ref.theme,
|
|
34
|
+
theme = _ref$theme === void 0 ? {} : _ref$theme;
|
|
35
|
+
return theme.colors ? theme.colors.primaryColor : 'unset';
|
|
36
|
+
}, function (_ref2) {
|
|
37
|
+
var _ref2$theme = _ref2.theme,
|
|
38
|
+
theme = _ref2$theme === void 0 ? {} : _ref2$theme;
|
|
39
|
+
return theme.colors ? theme.colors.borderColor : '#000';
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Scroll node into view if necessary
|
|
44
|
+
* @param {HTMLElement} node the element that should scroll into view
|
|
45
|
+
* @param {HTMLElement} rootNode the root element of the component
|
|
46
|
+
*/
|
|
47
|
+
// eslint-disable-next-line
|
|
48
|
+
var scrollIntoView = function scrollIntoView(node, rootNode) {
|
|
49
|
+
if (node === null) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
var actions = computeScrollIntoView(node, {
|
|
53
|
+
boundary: rootNode,
|
|
54
|
+
block: 'nearest',
|
|
55
|
+
scrollMode: 'if-needed'
|
|
56
|
+
});
|
|
57
|
+
actions.forEach(function (_ref) {
|
|
58
|
+
var el = _ref.el,
|
|
59
|
+
top = _ref.top,
|
|
60
|
+
left = _ref.left;
|
|
61
|
+
el.scrollTop = top;
|
|
62
|
+
el.scrollLeft = left;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var Downshift = {
|
|
67
|
+
// eslint-disable-next-line
|
|
68
|
+
props: ['isOpen', 'inputValue', 'selectedItem', 'highlightedIndex', 'handleChange',
|
|
69
|
+
// 'itemToString',
|
|
70
|
+
'handleMouseup'],
|
|
71
|
+
data: function data() {
|
|
72
|
+
return {
|
|
73
|
+
isMouseDown: false,
|
|
74
|
+
internal_isOpen: false,
|
|
75
|
+
internal_inputValue: '',
|
|
76
|
+
internal_selectedItem: null,
|
|
77
|
+
internal_highlightedIndex: null
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
computed: {
|
|
81
|
+
mergedState: function mergedState() {
|
|
82
|
+
var _this = this;
|
|
83
|
+
return Object.keys(this.$props).reduce(function (state, key) {
|
|
84
|
+
var _extends2;
|
|
85
|
+
return _extends({}, state, (_extends2 = {}, _extends2[key] = _this.isControlledProp(key) ? _this.$props[key] : _this["internal_" + key], _extends2));
|
|
86
|
+
}, {});
|
|
87
|
+
},
|
|
88
|
+
internalItemCount: function internalItemCount() {
|
|
89
|
+
return this.items.length;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
mounted: function mounted() {
|
|
93
|
+
window.addEventListener('mousedown', this.handleWindowMousedown);
|
|
94
|
+
window.addEventListener('mouseup', this.handleWindowMouseup);
|
|
95
|
+
},
|
|
96
|
+
beforeUnmount: function beforeUnmount() {
|
|
97
|
+
window.removeEventListener('mousedown', this.handleWindowMousedown);
|
|
98
|
+
window.removeEventListener('mouseup', this.handleWindowMouseup);
|
|
99
|
+
},
|
|
100
|
+
methods: {
|
|
101
|
+
handleWindowMousedown: function handleWindowMousedown() {
|
|
102
|
+
this.isMouseDown = true;
|
|
103
|
+
},
|
|
104
|
+
handleWindowMouseup: function handleWindowMouseup(event) {
|
|
105
|
+
this.isMouseDown = false;
|
|
106
|
+
if ((event.target === this.$refs.rootNode || !this.$refs.rootNode.contains(event.target)) && this.mergedState.isOpen) {
|
|
107
|
+
// TODO: handle on outer click here
|
|
108
|
+
if (!this.isMouseDown) {
|
|
109
|
+
this.reset();
|
|
110
|
+
if (this.$props.handleMouseup) {
|
|
111
|
+
this.$props.handleMouseup({
|
|
112
|
+
isOpen: false
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
keyDownArrowDown: function keyDownArrowDown(event) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
var amount = event.shiftKey ? 5 : 1;
|
|
121
|
+
if (this.mergedState.isOpen) {
|
|
122
|
+
this.changeHighlightedIndex(amount);
|
|
123
|
+
} else {
|
|
124
|
+
this.setState({
|
|
125
|
+
isOpen: true
|
|
126
|
+
});
|
|
127
|
+
this.setHighlightedIndex();
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
keyDownArrowUp: function keyDownArrowUp(event) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
var amount = event.shiftKey ? -5 : -1;
|
|
133
|
+
if (this.mergedState.isOpen) {
|
|
134
|
+
this.changeHighlightedIndex(amount);
|
|
135
|
+
} else {
|
|
136
|
+
this.setState({
|
|
137
|
+
isOpen: true
|
|
138
|
+
});
|
|
139
|
+
this.setHighlightedIndex();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
keyDownEnter: function keyDownEnter(event) {
|
|
143
|
+
if (this.mergedState.isOpen) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
this.selectHighlightedItem();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
keyDownEscape: function keyDownEscape(event) {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
this.reset();
|
|
151
|
+
},
|
|
152
|
+
selectHighlightedItem: function selectHighlightedItem() {
|
|
153
|
+
return this.selectItemAtIndex(this.mergedState.highlightedIndex);
|
|
154
|
+
},
|
|
155
|
+
selectItemAtIndex: function selectItemAtIndex(itemIndex) {
|
|
156
|
+
var item = this.items[itemIndex];
|
|
157
|
+
if (item == null) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.selectItem(item);
|
|
161
|
+
},
|
|
162
|
+
selectItem: function selectItem(item) {
|
|
163
|
+
if (this.$props.handleChange) {
|
|
164
|
+
this.$props.handleChange(item);
|
|
165
|
+
}
|
|
166
|
+
function getInputValue() {
|
|
167
|
+
if (this.isControlledProp('selectedItem')) {
|
|
168
|
+
return '';
|
|
169
|
+
}
|
|
170
|
+
return typeof item === 'object' ? item.label || '' : item;
|
|
171
|
+
}
|
|
172
|
+
this.setState({
|
|
173
|
+
isOpen: false,
|
|
174
|
+
highlightedIndex: null,
|
|
175
|
+
selectedItem: item,
|
|
176
|
+
inputValue: getInputValue.call(this)
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
changeHighlightedIndex: function changeHighlightedIndex(moveAmount) {
|
|
180
|
+
if (this.internalItemCount < 0) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
var highlightedIndex = this.mergedState.highlightedIndex;
|
|
184
|
+
var baseIndex = highlightedIndex;
|
|
185
|
+
if (baseIndex === null) {
|
|
186
|
+
baseIndex = moveAmount > 0 ? -1 : this.internalItemCount + 1;
|
|
187
|
+
}
|
|
188
|
+
var newIndex = baseIndex + moveAmount;
|
|
189
|
+
if (newIndex < 0) {
|
|
190
|
+
newIndex = this.internalItemCount;
|
|
191
|
+
} else if (newIndex > this.internalItemCount) {
|
|
192
|
+
newIndex = 0;
|
|
193
|
+
}
|
|
194
|
+
this.setHighlightedIndex(newIndex);
|
|
195
|
+
},
|
|
196
|
+
setHighlightedIndex: function setHighlightedIndex(highlightedIndex) {
|
|
197
|
+
if (highlightedIndex === void 0) {
|
|
198
|
+
highlightedIndex = null;
|
|
199
|
+
}
|
|
200
|
+
this.setState({
|
|
201
|
+
highlightedIndex: highlightedIndex
|
|
202
|
+
});
|
|
203
|
+
var element = document.getElementById("Downshift" + highlightedIndex);
|
|
204
|
+
scrollIntoView(element, this.rootNode);
|
|
205
|
+
// Implement scrollIntroView thingy
|
|
206
|
+
},
|
|
207
|
+
reset: function reset() {
|
|
208
|
+
var selectedItem = this.mergedState.selectedItem;
|
|
209
|
+
this.setState({
|
|
210
|
+
isOpen: false,
|
|
211
|
+
highlightedIndex: null,
|
|
212
|
+
inputValue: selectedItem
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
getItemProps: function getItemProps(_ref) {
|
|
216
|
+
var index = _ref.index,
|
|
217
|
+
item = _ref.item;
|
|
218
|
+
var newIndex = index;
|
|
219
|
+
if (index === undefined) {
|
|
220
|
+
if (this.$props.itemToString) {
|
|
221
|
+
this.items.push(this.$props.itemToString(item));
|
|
222
|
+
} else {
|
|
223
|
+
this.items.push(item);
|
|
224
|
+
}
|
|
225
|
+
newIndex = this.items.indexOf(item);
|
|
226
|
+
} else {
|
|
227
|
+
this.items[newIndex] = item;
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
id: "Downshift" + newIndex
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
getItemEvents: function getItemEvents(_ref2) {
|
|
234
|
+
var index = _ref2.index,
|
|
235
|
+
item = _ref2.item;
|
|
236
|
+
var newIndex = index;
|
|
237
|
+
if (index === undefined) {
|
|
238
|
+
newIndex = this.items.indexOf(item);
|
|
239
|
+
}
|
|
240
|
+
var vm = this;
|
|
241
|
+
return {
|
|
242
|
+
mouseenter: function mouseenter() {
|
|
243
|
+
vm.setHighlightedIndex(newIndex);
|
|
244
|
+
},
|
|
245
|
+
click: function click(event) {
|
|
246
|
+
event.stopPropagation();
|
|
247
|
+
vm.selectItemAtIndex(newIndex);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
},
|
|
251
|
+
getInputProps: function getInputProps(_ref3) {
|
|
252
|
+
var value = _ref3.value;
|
|
253
|
+
var inputValue = this.mergedState.inputValue;
|
|
254
|
+
if (value !== inputValue) {
|
|
255
|
+
this.setState({
|
|
256
|
+
inputValue: value
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
value: inputValue
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
getButtonProps: function getButtonProps(_ref4) {
|
|
264
|
+
var _this2 = this;
|
|
265
|
+
var onClick = _ref4.onClick,
|
|
266
|
+
onKeyDown = _ref4.onKeyDown,
|
|
267
|
+
onKeyUp = _ref4.onKeyUp,
|
|
268
|
+
onBlur = _ref4.onBlur;
|
|
269
|
+
return {
|
|
270
|
+
click: function click(event) {
|
|
271
|
+
_this2.setState({
|
|
272
|
+
isOpen: true,
|
|
273
|
+
inputValue: event.target.value
|
|
274
|
+
});
|
|
275
|
+
if (onClick) {
|
|
276
|
+
onClick(event);
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
keydown: function keydown(event) {
|
|
280
|
+
if (event.key && _this2["keyDown" + event.key]) {
|
|
281
|
+
_this2["keyDown" + event.key].call(_this2, event);
|
|
282
|
+
}
|
|
283
|
+
if (onKeyDown) {
|
|
284
|
+
onKeyDown(event);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
keyup: function keyup(event) {
|
|
288
|
+
if (onKeyUp) {
|
|
289
|
+
onKeyUp(event);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
blur: function blur(event) {
|
|
293
|
+
if (onBlur) {
|
|
294
|
+
onBlur(event);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
},
|
|
299
|
+
getInputEvents: function getInputEvents(_ref5) {
|
|
300
|
+
var _this3 = this;
|
|
301
|
+
var onInput = _ref5.onInput,
|
|
302
|
+
onBlur = _ref5.onBlur,
|
|
303
|
+
onFocus = _ref5.onFocus,
|
|
304
|
+
onKeyPress = _ref5.onKeyPress,
|
|
305
|
+
onKeyDown = _ref5.onKeyDown,
|
|
306
|
+
onKeyUp = _ref5.onKeyUp,
|
|
307
|
+
onClick = _ref5.onClick;
|
|
308
|
+
return {
|
|
309
|
+
input: function input(event) {
|
|
310
|
+
_this3.setState({
|
|
311
|
+
isOpen: true,
|
|
312
|
+
inputValue: event.target.value
|
|
313
|
+
});
|
|
314
|
+
if (onInput) {
|
|
315
|
+
onInput(event);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
focus: function focus(event) {
|
|
319
|
+
if (onFocus) {
|
|
320
|
+
onFocus(event);
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
keydown: function keydown(event) {
|
|
324
|
+
if (event.key && _this3["keyDown" + event.key]) {
|
|
325
|
+
_this3["keyDown" + event.key].call(_this3, event);
|
|
326
|
+
}
|
|
327
|
+
if (onKeyDown) {
|
|
328
|
+
onKeyDown(event);
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
keypress: function keypress(event) {
|
|
332
|
+
if (onKeyPress) {
|
|
333
|
+
onKeyPress(event);
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
keyup: function keyup(event) {
|
|
337
|
+
if (onKeyUp) {
|
|
338
|
+
onKeyUp(event);
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
blur: function blur(event) {
|
|
342
|
+
if (onBlur) {
|
|
343
|
+
onBlur(event);
|
|
344
|
+
}
|
|
345
|
+
// TODO: implement isMouseDown
|
|
346
|
+
// this.reset()
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
click: onClick
|
|
350
|
+
};
|
|
351
|
+
},
|
|
352
|
+
getHelpersAndState: function getHelpersAndState() {
|
|
353
|
+
var getItemProps = this.getItemProps,
|
|
354
|
+
getItemEvents = this.getItemEvents,
|
|
355
|
+
getInputProps = this.getInputProps,
|
|
356
|
+
getInputEvents = this.getInputEvents,
|
|
357
|
+
getButtonProps = this.getButtonProps,
|
|
358
|
+
setHighlightedIndex = this.setHighlightedIndex;
|
|
359
|
+
return _extends({
|
|
360
|
+
getItemProps: getItemProps,
|
|
361
|
+
getItemEvents: getItemEvents,
|
|
362
|
+
getInputProps: getInputProps,
|
|
363
|
+
getInputEvents: getInputEvents,
|
|
364
|
+
getButtonProps: getButtonProps,
|
|
365
|
+
setHighlightedIndex: setHighlightedIndex
|
|
366
|
+
}, this.mergedState);
|
|
367
|
+
},
|
|
368
|
+
isControlledProp: function isControlledProp(prop) {
|
|
369
|
+
return this.$props[prop] !== undefined;
|
|
370
|
+
},
|
|
371
|
+
setState: function setState(stateToSet) {
|
|
372
|
+
var _this4 = this;
|
|
373
|
+
// eslint-disable-next-line
|
|
374
|
+
Object.keys(stateToSet).forEach(function (key) {
|
|
375
|
+
// eslint-disable-next-line
|
|
376
|
+
if (_this4.isControlledProp(key)) {
|
|
377
|
+
_this4.$emit(key + "Change", stateToSet[key]);
|
|
378
|
+
_this4.$emit(key + "-change", stateToSet[key]);
|
|
379
|
+
} else {
|
|
380
|
+
_this4["internal_" + key] = stateToSet[key];
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
this.$emit('stateChange', this.mergedState);
|
|
384
|
+
this.$emit('state-change', this.mergedState);
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
render: function render() {
|
|
388
|
+
this.items = [];
|
|
389
|
+
return createVNode("div", {
|
|
390
|
+
"ref": "rootNode"
|
|
391
|
+
}, [this.$slots["default"] && this.$slots["default"](_extends({}, this.getHelpersAndState()))]);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
var CancelSvg = (function () {
|
|
396
|
+
return createVNode("svg", {
|
|
397
|
+
"alt": "Clear",
|
|
398
|
+
"class": "cancel-icon",
|
|
399
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
400
|
+
"height": "20px",
|
|
401
|
+
"viewBox": "0 0 24 24",
|
|
402
|
+
"width": "20px"
|
|
403
|
+
}, [createVNode("title", null, [createTextVNode("Clear")]), createVNode("path", {
|
|
404
|
+
"d": "M0 0h24v24H0V0z",
|
|
405
|
+
"fill": "none"
|
|
406
|
+
}, null), createVNode("path", {
|
|
407
|
+
"d": "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
408
|
+
}, null)]);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
var _templateObject$3, _templateObject2;
|
|
412
|
+
var small = "\n\tmin-height: 0;\n\theight: 30px;\n\tborder: 0;\n\tbox-shadow: rgba(0, 0, 0, 0.3) 0px 1px 4px -1px;\n\tborder-radius: 2px;\n";
|
|
413
|
+
var dark = function dark(_ref) {
|
|
414
|
+
var theme = _ref.theme;
|
|
415
|
+
return "\n\tbackground-color: " + (theme.colors ? theme.colors.backgroundColor : '') + ";\n\tborder-color: " + (theme.colors ? theme.colors.borderColor : '') + ";\n\tcolor: " + (theme.colors ? theme.colors.textColor : '') + ";\n\n\t&:hover,\n\t&:focus {\n\t\tbackground-color: " + (theme.colors ? theme.colors.backgroundColor : '') + ";\n\t}\n";
|
|
416
|
+
};
|
|
417
|
+
var Select = styled('button')(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tmin-height: 42px;\n\tborder-radius: 0;\n\toutline: none;\n\tpadding: 5px 12px;\n\tfont-size: 0.9rem;\n\tline-height: 1.2rem;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n\tcolor: #424242;\n\tcursor: pointer;\n\tuser-select: none;\n\ttransition: all 0.3s ease;\n\n\t", ";\n\n\t& > div {\n\t\twidth: calc(100% - 24px);\n\t\twhite-space: nowrap;\n\t\toverflow: hidden;\n\t\ttext-overflow: ellipsis;\n\t\ttext-align: left;\n\t}\n\n\t&:hover,\n\t&:focus {\n\t\tbackground-color: #fcfcfc;\n\t}\n\n\t", ";\n"])), function (props) {
|
|
418
|
+
return props.small ? small : null;
|
|
419
|
+
}, function (_ref2) {
|
|
420
|
+
var themePreset = _ref2.themePreset;
|
|
421
|
+
return themePreset === 'dark' && dark;
|
|
422
|
+
});
|
|
423
|
+
var Tick = styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\twidth: 16px;\n\theight: 16px;\n\tdisplay: inline-block;\n\tposition: relative;\n\tuser-select: none;\n\talign-items: center;\n\n\t&::after {\n\t\tbox-sizing: content-box;\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tbackground-color: transparent;\n\t\ttop: 50%;\n\t\tleft: 0;\n\t\twidth: 8px;\n\t\theight: 4px;\n\t\tmargin-top: -4px;\n\t\tborder-style: solid;\n\t\tborder-color: ", ";\n\t\tborder-width: 0 0 2px 2px;\n\t\tborder-radius: 0;\n\t\tborder-image: none;\n\t\ttransform: rotate(-45deg) scale(1);\n\t\ttransition: all 200ms ease-out;\n\t}\n"])), function (_ref3) {
|
|
424
|
+
var theme = _ref3.theme;
|
|
425
|
+
return theme.colors.primaryColor;
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
var _templateObject$4;
|
|
429
|
+
var open = "\n\ttop: 0.55em;\n\ttransform: rotate(-45deg);\n";
|
|
430
|
+
var Chevron = styled('span')(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n\t&::before {\n\t\tcontent: '';\n\t\tborder-style: solid;\n\t\tborder-width: 0.15em 0.15em 0 0;\n\t\tdisplay: inline-block;\n\t\theight: 0.45em;\n\t\tposition: relative;\n\t\ttop: 0.35em;\n\t\tleft: 0;\n\t\ttransform: rotate(135deg);\n\t\tvertical-align: top;\n\t\twidth: 0.45em;\n\n\t\t", ";\n\t}\n"])), function (props) {
|
|
431
|
+
return props.open ? open : null;
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
var getClassName = helper.getClassName;
|
|
435
|
+
var Dropdown = {
|
|
436
|
+
data: function data() {
|
|
437
|
+
this.__state = {
|
|
438
|
+
isOpen: false,
|
|
439
|
+
searchTerm: ''
|
|
440
|
+
};
|
|
441
|
+
return this.__state;
|
|
442
|
+
},
|
|
443
|
+
inject: {
|
|
444
|
+
theme: {
|
|
445
|
+
from: 'theme_reactivesearch'
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
props: {
|
|
449
|
+
innerClass: types.style,
|
|
450
|
+
items: types.data,
|
|
451
|
+
keyField: VueTypes.string.def('key'),
|
|
452
|
+
labelField: VueTypes.string.def('label'),
|
|
453
|
+
multi: VueTypes.bool,
|
|
454
|
+
// change event
|
|
455
|
+
placeholder: types.string,
|
|
456
|
+
returnsObject: VueTypes.bool,
|
|
457
|
+
customLabelRenderer: types.func,
|
|
458
|
+
hasCustomRenderer: VueTypes.bool,
|
|
459
|
+
customRenderer: types.func,
|
|
460
|
+
renderItem: types.func,
|
|
461
|
+
renderNoResults: VueTypes.any,
|
|
462
|
+
handleChange: types.func,
|
|
463
|
+
transformData: types.func,
|
|
464
|
+
selectedItem: types.selectedValue,
|
|
465
|
+
showCount: VueTypes.bool,
|
|
466
|
+
single: VueTypes.bool,
|
|
467
|
+
small: VueTypes.bool.def(false),
|
|
468
|
+
themePreset: types.themePreset,
|
|
469
|
+
showSearch: VueTypes.bool,
|
|
470
|
+
showClear: VueTypes.bool,
|
|
471
|
+
searchPlaceholder: VueTypes.string.def('Type here to search...')
|
|
472
|
+
},
|
|
473
|
+
render: function render() {
|
|
474
|
+
var _this = this;
|
|
475
|
+
var _this$$props = this.$props,
|
|
476
|
+
items = _this$$props.items,
|
|
477
|
+
selectedItem = _this$$props.selectedItem,
|
|
478
|
+
placeholder = _this$$props.placeholder,
|
|
479
|
+
labelField = _this$$props.labelField,
|
|
480
|
+
keyField = _this$$props.keyField,
|
|
481
|
+
themePreset = _this$$props.themePreset,
|
|
482
|
+
renderItem = _this$$props.renderItem,
|
|
483
|
+
transformData = _this$$props.transformData,
|
|
484
|
+
footer = _this$$props.footer,
|
|
485
|
+
customLabelRenderer = _this$$props.customLabelRenderer,
|
|
486
|
+
hasCustomRenderer = _this$$props.hasCustomRenderer,
|
|
487
|
+
customRenderer = _this$$props.customRenderer;
|
|
488
|
+
var itemsToRender = items;
|
|
489
|
+
if (transformData) {
|
|
490
|
+
itemsToRender = transformData(itemsToRender);
|
|
491
|
+
}
|
|
492
|
+
var filteredItemsToRender = itemsToRender.filter(function (item) {
|
|
493
|
+
if (String(item[labelField]).length) {
|
|
494
|
+
if (_this.$props.showSearch && _this.$data.searchTerm) {
|
|
495
|
+
return replaceDiacritics(String(item[labelField])).toLowerCase().includes(replaceDiacritics(_this.$data.searchTerm.toLowerCase()));
|
|
496
|
+
}
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
return false;
|
|
500
|
+
});
|
|
501
|
+
return createVNode(Downshift, {
|
|
502
|
+
"isOpen": this.$data.isOpen,
|
|
503
|
+
"selectedItem": selectedItem,
|
|
504
|
+
"handleChange": this.onChange,
|
|
505
|
+
"handleMouseup": this.handleStateChange
|
|
506
|
+
}, {
|
|
507
|
+
"default": function _default(_ref) {
|
|
508
|
+
var getItemProps = _ref.getItemProps,
|
|
509
|
+
isOpen = _ref.isOpen,
|
|
510
|
+
highlightedIndex = _ref.highlightedIndex,
|
|
511
|
+
getButtonProps = _ref.getButtonProps,
|
|
512
|
+
getItemEvents = _ref.getItemEvents,
|
|
513
|
+
getInputEvents = _ref.getInputEvents;
|
|
514
|
+
return createVNode("div", {
|
|
515
|
+
"class": suggestionsContainer
|
|
516
|
+
}, [createVNode(Select, mergeProps(_transformOn(getButtonProps({
|
|
517
|
+
onClick: _this.toggle
|
|
518
|
+
})), {
|
|
519
|
+
"class": getClassName(_this.$props.innerClass, 'select') || '',
|
|
520
|
+
"title": selectedItem ? _this.renderToString(selectedItem) : placeholder,
|
|
521
|
+
"small": _this.$props.small,
|
|
522
|
+
"themePreset": _this.$props.themePreset
|
|
523
|
+
}), {
|
|
524
|
+
"default": function _default() {
|
|
525
|
+
return [customLabelRenderer ? customLabelRenderer(selectedItem) : createVNode("div", null, [selectedItem ? _this.renderToString(selectedItem) : placeholder]), createVNode(Chevron, {
|
|
526
|
+
"open": isOpen
|
|
527
|
+
}, null)];
|
|
528
|
+
}
|
|
529
|
+
}), hasCustomRenderer ? customRenderer(itemsToRender, {
|
|
530
|
+
getItemProps: getItemProps,
|
|
531
|
+
isOpen: isOpen,
|
|
532
|
+
highlightedIndex: highlightedIndex,
|
|
533
|
+
getButtonProps: getButtonProps,
|
|
534
|
+
getItemEvents: getItemEvents
|
|
535
|
+
}) : isOpen && itemsToRender.length ? createVNode("ul", {
|
|
536
|
+
"class": suggestions(themePreset, _this.theme) + " " + (_this.$props.small ? 'small' : '') + " " + getClassName(_this.$props.innerClass, 'list')
|
|
537
|
+
}, [_this.$props.showSearch ? _this.renderSearchbox({
|
|
538
|
+
on: {
|
|
539
|
+
input: getInputEvents({
|
|
540
|
+
onInput: _this.handleInputChange
|
|
541
|
+
}).input
|
|
542
|
+
}
|
|
543
|
+
}) : null, !hasCustomRenderer && filteredItemsToRender.length === 0 ? _this.renderNoResult() : filteredItemsToRender.map(function (item, index) {
|
|
544
|
+
var selected = _this.$props.multi // MultiDropdownList
|
|
545
|
+
&& (selectedItem && !!selectedItem[item[keyField]] // MultiDropdownRange
|
|
546
|
+
|| Array.isArray(selectedItem) && selectedItem.find(function (value) {
|
|
547
|
+
return value[labelField] === item[labelField];
|
|
548
|
+
}));
|
|
549
|
+
if (!_this.$props.multi) selected = item.key === selectedItem;
|
|
550
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
551
|
+
item: item
|
|
552
|
+
}), _transformOn(getItemEvents({
|
|
553
|
+
item: item
|
|
554
|
+
})), {
|
|
555
|
+
"key": item[keyField],
|
|
556
|
+
"class": "" + (selected ? 'active' : ''),
|
|
557
|
+
"style": {
|
|
558
|
+
backgroundColor: _this.getBackgroundColor(highlightedIndex === index, selected)
|
|
559
|
+
}
|
|
560
|
+
}), [renderItem ? renderItem({
|
|
561
|
+
label: item[labelField],
|
|
562
|
+
count: item.doc_count,
|
|
563
|
+
isChecked: selected && _this.$props.multi
|
|
564
|
+
}) : createVNode("div", null, [typeof item[labelField] === 'string' ? createVNode("span", {
|
|
565
|
+
"innerHTML": item[labelField]
|
|
566
|
+
}, null) : item[labelField], _this.$props.showCount && item.doc_count && createVNode("span", {
|
|
567
|
+
"class": getClassName(_this.$props.innerClass, 'count') || ''
|
|
568
|
+
}, [createTextVNode("\xA0("), item.doc_count, createTextVNode(")")])]), selected && _this.$props.multi ? createVNode(Tick, {
|
|
569
|
+
"class": getClassName(_this.$props.innerClass, 'icon') || ''
|
|
570
|
+
}, null) : null]);
|
|
571
|
+
}), footer]) : null]);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
},
|
|
575
|
+
methods: {
|
|
576
|
+
toggle: function toggle() {
|
|
577
|
+
this.isOpen = !this.$data.isOpen;
|
|
578
|
+
},
|
|
579
|
+
close: function close() {
|
|
580
|
+
this.isOpen = false;
|
|
581
|
+
},
|
|
582
|
+
onChange: function onChange(item) {
|
|
583
|
+
if (this.$props.returnsObject) {
|
|
584
|
+
this.$props.handleChange(item);
|
|
585
|
+
} else {
|
|
586
|
+
this.$props.handleChange(item[this.$props.keyField]);
|
|
587
|
+
}
|
|
588
|
+
if (!this.$props.multi) {
|
|
589
|
+
this.isOpen = false;
|
|
590
|
+
this.searchTerm = '';
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
handleStateChange: function handleStateChange(_ref2) {
|
|
594
|
+
var isOpen = _ref2.isOpen;
|
|
595
|
+
this.isOpen = isOpen;
|
|
596
|
+
},
|
|
597
|
+
getBackgroundColor: function getBackgroundColor(highlighted, selected) {
|
|
598
|
+
var isDark = this.$props.themePreset === 'dark';
|
|
599
|
+
if (highlighted) {
|
|
600
|
+
return isDark ? '#555' : '#eee';
|
|
601
|
+
}
|
|
602
|
+
if (selected) {
|
|
603
|
+
return isDark ? '#686868' : '#fafafa';
|
|
604
|
+
}
|
|
605
|
+
return isDark ? '#424242' : '#fff';
|
|
606
|
+
},
|
|
607
|
+
handleInputChange: function handleInputChange(e) {
|
|
608
|
+
var value = e.target.value;
|
|
609
|
+
this.searchTerm = value;
|
|
610
|
+
},
|
|
611
|
+
clearSearchTerm: function clearSearchTerm() {
|
|
612
|
+
this.searchTerm = '';
|
|
613
|
+
},
|
|
614
|
+
renderToString: function renderToString(value) {
|
|
615
|
+
var _this2 = this;
|
|
616
|
+
var customLabelRenderer = this.$props.customLabelRenderer;
|
|
617
|
+
if (customLabelRenderer) {
|
|
618
|
+
var customLabel = customLabelRenderer(value);
|
|
619
|
+
if (typeof customLabel === 'string') {
|
|
620
|
+
return customLabel;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (Array.isArray(value) && value.length) {
|
|
624
|
+
var arrayToRender = value.map(function (item) {
|
|
625
|
+
return _this2.renderToString(item);
|
|
626
|
+
});
|
|
627
|
+
return arrayToRender.join(', ');
|
|
628
|
+
}
|
|
629
|
+
if (value && typeof value === 'object') {
|
|
630
|
+
if (value[this.$props.labelField]) {
|
|
631
|
+
return value[this.$props.labelField];
|
|
632
|
+
}
|
|
633
|
+
if (Object.keys(value).length) {
|
|
634
|
+
return this.renderToString(Object.keys(value));
|
|
635
|
+
}
|
|
636
|
+
return this.$props.placeholder;
|
|
637
|
+
}
|
|
638
|
+
return value;
|
|
639
|
+
},
|
|
640
|
+
renderNoResult: function renderNoResult() {
|
|
641
|
+
var renderNoResults = this.$slots.renderNoResults || this.$props.renderNoResults;
|
|
642
|
+
return createVNode("p", {
|
|
643
|
+
"class": getClassName(this.$props.innerClass, 'noResults') || null
|
|
644
|
+
}, [isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
|
|
645
|
+
},
|
|
646
|
+
renderSearchbox: function renderSearchbox(eventObject) {
|
|
647
|
+
var _this3 = this;
|
|
648
|
+
var _this$$props2 = this.$props,
|
|
649
|
+
componentId = _this$$props2.componentId,
|
|
650
|
+
searchPlaceholder = _this$$props2.searchPlaceholder,
|
|
651
|
+
showClear = _this$$props2.showClear,
|
|
652
|
+
themePreset = _this$$props2.themePreset,
|
|
653
|
+
innerClass = _this$$props2.innerClass;
|
|
654
|
+
var InputComponent = createVNode(Input, mergeProps({
|
|
655
|
+
"id": componentId + "-input",
|
|
656
|
+
"style": {
|
|
657
|
+
border: 0,
|
|
658
|
+
borderBottom: '1px solid #ddd'
|
|
659
|
+
},
|
|
660
|
+
"showIcon": false,
|
|
661
|
+
"showClear": showClear,
|
|
662
|
+
"class": getClassName(innerClass, 'input'),
|
|
663
|
+
"placeholder": searchPlaceholder,
|
|
664
|
+
"value": this.$data.searchTerm,
|
|
665
|
+
"themePreset": themePreset
|
|
666
|
+
}, eventObject), null);
|
|
667
|
+
if (showClear) {
|
|
668
|
+
return createVNode(InputWrapper, null, {
|
|
669
|
+
"default": function _default() {
|
|
670
|
+
return [InputComponent, _this3.searchTerm && createVNode(IconGroup, {
|
|
671
|
+
"groupPosition": "right",
|
|
672
|
+
"positionType": "absolute"
|
|
673
|
+
}, {
|
|
674
|
+
"default": function _default() {
|
|
675
|
+
return [createVNode(IconWrapper, {
|
|
676
|
+
"onClick": _this3.clearSearchTerm,
|
|
677
|
+
"isClearIcon": true
|
|
678
|
+
}, {
|
|
679
|
+
"default": function _default() {
|
|
680
|
+
return [createVNode(CancelSvg, null, null)];
|
|
681
|
+
}
|
|
682
|
+
})];
|
|
683
|
+
}
|
|
684
|
+
})];
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
return InputComponent;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
export { CancelSvg as C, Downshift as D, IconWrapper as I, IconGroup as a, InputWrapper as b, Dropdown as c };
|
|
@@ -4,7 +4,7 @@ import './_rollupPluginBabelHelpers-ded08042.js';
|
|
|
4
4
|
import { createVNode, resolveComponent, mergeProps } from 'vue';
|
|
5
5
|
import VueTypes from 'vue-types';
|
|
6
6
|
import '@appbaseio/vue-emotion';
|
|
7
|
-
import { t as types } from './vueTypes-
|
|
7
|
+
import { t as types } from './vueTypes-09cab4d3.js';
|
|
8
8
|
import 'redux';
|
|
9
9
|
import { j as updateCustomQuery, d as getValidPropsKeys, i as isQueryIdentical, c as connect } from './index-882489e1.js';
|
|
10
10
|
import { P as PreferencesConsumer } from './PreferencesConsumer-b058d14e.js';
|