@appbaseio/reactivesearch-vue 3.0.0-rc.5.alpha.1 → 3.0.0-rc.5.alpha.3
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 +36340 -33139
- 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/{DropDown-b16418e9.js → CancelSvg-ab0f8b23.js} +0 -290
- package/dist/cjs/DropDown-e7125b72.js +299 -0
- package/dist/cjs/MultiDropdownList.js +2 -1
- package/dist/cjs/{install-7cdf6798.js → SearchBox.js} +21 -867
- package/dist/cjs/SingleDropdownList.js +2 -1
- package/dist/cjs/index.js +7 -5
- package/dist/cjs/install-3c4520bf.js +874 -0
- package/dist/cjs/install.js +4 -2
- package/dist/cjs/version.js +1 -1
- package/dist/es/CancelSvg-e7ae49e9.js +401 -0
- package/dist/es/DropDown-13afb4d2.js +295 -0
- package/dist/es/MultiDropdownList.js +2 -1
- package/dist/es/{install-0c7962bc.js → SearchBox.js} +10 -855
- package/dist/es/SingleDropdownList.js +2 -1
- package/dist/es/index.js +5 -3
- package/dist/es/install-ff8b0750.js +868 -0
- package/dist/es/install.js +4 -2
- package/dist/es/version.js +1 -1
- package/package.json +3 -3
- package/dist/es/DropDown-fc1fef02.js +0 -690
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { helper } from '@appbaseio/reactivecore';
|
|
2
|
+
import _transformOn from '@vue/babel-helper-vue-transform-on';
|
|
3
|
+
import { _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-ded08042.js';
|
|
4
|
+
import { createVNode, mergeProps, createTextVNode } from 'vue';
|
|
5
|
+
import VueTypes from 'vue-types';
|
|
6
|
+
import { styled } from '@appbaseio/vue-emotion';
|
|
7
|
+
import { t as types } from './vueTypes-f1923c72.js';
|
|
8
|
+
import { a as isFunction } from './index-882489e1.js';
|
|
9
|
+
import { D as Downshift, b as InputWrapper, a as IconGroup, I as IconWrapper, C as CancelSvg } from './CancelSvg-e7ae49e9.js';
|
|
10
|
+
import { s as suggestionsContainer, a as suggestions, I as Input } from './Input-f7499ef8.js';
|
|
11
|
+
import { replaceDiacritics } from '@appbaseio/reactivecore/lib/utils/suggestions';
|
|
12
|
+
|
|
13
|
+
var _templateObject, _templateObject2;
|
|
14
|
+
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";
|
|
15
|
+
var dark = function dark(_ref) {
|
|
16
|
+
var theme = _ref.theme;
|
|
17
|
+
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";
|
|
18
|
+
};
|
|
19
|
+
var Select = styled('button')(_templateObject || (_templateObject = _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) {
|
|
20
|
+
return props.small ? small : null;
|
|
21
|
+
}, function (_ref2) {
|
|
22
|
+
var themePreset = _ref2.themePreset;
|
|
23
|
+
return themePreset === 'dark' && dark;
|
|
24
|
+
});
|
|
25
|
+
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) {
|
|
26
|
+
var theme = _ref3.theme;
|
|
27
|
+
return theme.colors.primaryColor;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
var _templateObject$1;
|
|
31
|
+
var open = "\n\ttop: 0.55em;\n\ttransform: rotate(-45deg);\n";
|
|
32
|
+
var Chevron = styled('span')(_templateObject$1 || (_templateObject$1 = _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) {
|
|
33
|
+
return props.open ? open : null;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
var getClassName = helper.getClassName;
|
|
37
|
+
var Dropdown = {
|
|
38
|
+
data: function data() {
|
|
39
|
+
this.__state = {
|
|
40
|
+
isOpen: false,
|
|
41
|
+
searchTerm: ''
|
|
42
|
+
};
|
|
43
|
+
return this.__state;
|
|
44
|
+
},
|
|
45
|
+
inject: {
|
|
46
|
+
theme: {
|
|
47
|
+
from: 'theme_reactivesearch'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
props: {
|
|
51
|
+
innerClass: types.style,
|
|
52
|
+
items: types.data,
|
|
53
|
+
keyField: VueTypes.string.def('key'),
|
|
54
|
+
labelField: VueTypes.string.def('label'),
|
|
55
|
+
multi: VueTypes.bool,
|
|
56
|
+
// change event
|
|
57
|
+
placeholder: types.string,
|
|
58
|
+
returnsObject: VueTypes.bool,
|
|
59
|
+
customLabelRenderer: types.func,
|
|
60
|
+
hasCustomRenderer: VueTypes.bool,
|
|
61
|
+
customRenderer: types.func,
|
|
62
|
+
renderItem: types.func,
|
|
63
|
+
renderNoResults: VueTypes.any,
|
|
64
|
+
handleChange: types.func,
|
|
65
|
+
transformData: types.func,
|
|
66
|
+
selectedItem: types.selectedValue,
|
|
67
|
+
showCount: VueTypes.bool,
|
|
68
|
+
single: VueTypes.bool,
|
|
69
|
+
small: VueTypes.bool.def(false),
|
|
70
|
+
themePreset: types.themePreset,
|
|
71
|
+
showSearch: VueTypes.bool,
|
|
72
|
+
showClear: VueTypes.bool,
|
|
73
|
+
searchPlaceholder: VueTypes.string.def('Type here to search...')
|
|
74
|
+
},
|
|
75
|
+
render: function render() {
|
|
76
|
+
var _this = this;
|
|
77
|
+
var _this$$props = this.$props,
|
|
78
|
+
items = _this$$props.items,
|
|
79
|
+
selectedItem = _this$$props.selectedItem,
|
|
80
|
+
placeholder = _this$$props.placeholder,
|
|
81
|
+
labelField = _this$$props.labelField,
|
|
82
|
+
keyField = _this$$props.keyField,
|
|
83
|
+
themePreset = _this$$props.themePreset,
|
|
84
|
+
renderItem = _this$$props.renderItem,
|
|
85
|
+
transformData = _this$$props.transformData,
|
|
86
|
+
footer = _this$$props.footer,
|
|
87
|
+
customLabelRenderer = _this$$props.customLabelRenderer,
|
|
88
|
+
hasCustomRenderer = _this$$props.hasCustomRenderer,
|
|
89
|
+
customRenderer = _this$$props.customRenderer;
|
|
90
|
+
var itemsToRender = items;
|
|
91
|
+
if (transformData) {
|
|
92
|
+
itemsToRender = transformData(itemsToRender);
|
|
93
|
+
}
|
|
94
|
+
var filteredItemsToRender = itemsToRender.filter(function (item) {
|
|
95
|
+
if (String(item[labelField]).length) {
|
|
96
|
+
if (_this.$props.showSearch && _this.$data.searchTerm) {
|
|
97
|
+
return replaceDiacritics(String(item[labelField])).toLowerCase().includes(replaceDiacritics(_this.$data.searchTerm.toLowerCase()));
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
});
|
|
103
|
+
return createVNode(Downshift, {
|
|
104
|
+
"isOpen": this.$data.isOpen,
|
|
105
|
+
"selectedItem": selectedItem,
|
|
106
|
+
"handleChange": this.onChange,
|
|
107
|
+
"handleMouseup": this.handleStateChange
|
|
108
|
+
}, {
|
|
109
|
+
"default": function _default(_ref) {
|
|
110
|
+
var getItemProps = _ref.getItemProps,
|
|
111
|
+
isOpen = _ref.isOpen,
|
|
112
|
+
highlightedIndex = _ref.highlightedIndex,
|
|
113
|
+
getButtonProps = _ref.getButtonProps,
|
|
114
|
+
getItemEvents = _ref.getItemEvents,
|
|
115
|
+
getInputEvents = _ref.getInputEvents;
|
|
116
|
+
return createVNode("div", {
|
|
117
|
+
"class": suggestionsContainer
|
|
118
|
+
}, [createVNode(Select, mergeProps(_transformOn(getButtonProps({
|
|
119
|
+
onClick: _this.toggle
|
|
120
|
+
})), {
|
|
121
|
+
"class": getClassName(_this.$props.innerClass, 'select') || '',
|
|
122
|
+
"title": selectedItem ? _this.renderToString(selectedItem) : placeholder,
|
|
123
|
+
"small": _this.$props.small,
|
|
124
|
+
"themePreset": _this.$props.themePreset
|
|
125
|
+
}), {
|
|
126
|
+
"default": function _default() {
|
|
127
|
+
return [customLabelRenderer ? customLabelRenderer(selectedItem) : createVNode("div", null, [selectedItem ? _this.renderToString(selectedItem) : placeholder]), createVNode(Chevron, {
|
|
128
|
+
"open": isOpen
|
|
129
|
+
}, null)];
|
|
130
|
+
}
|
|
131
|
+
}), hasCustomRenderer ? customRenderer(itemsToRender, {
|
|
132
|
+
getItemProps: getItemProps,
|
|
133
|
+
isOpen: isOpen,
|
|
134
|
+
highlightedIndex: highlightedIndex,
|
|
135
|
+
getButtonProps: getButtonProps,
|
|
136
|
+
getItemEvents: getItemEvents
|
|
137
|
+
}) : isOpen && itemsToRender.length ? createVNode("ul", {
|
|
138
|
+
"class": suggestions(themePreset, _this.theme) + " " + (_this.$props.small ? 'small' : '') + " " + getClassName(_this.$props.innerClass, 'list')
|
|
139
|
+
}, [_this.$props.showSearch ? _this.renderSearchbox({
|
|
140
|
+
on: {
|
|
141
|
+
input: getInputEvents({
|
|
142
|
+
onInput: _this.handleInputChange
|
|
143
|
+
}).input
|
|
144
|
+
}
|
|
145
|
+
}) : null, !hasCustomRenderer && filteredItemsToRender.length === 0 ? _this.renderNoResult() : filteredItemsToRender.map(function (item, index) {
|
|
146
|
+
var selected = _this.$props.multi // MultiDropdownList
|
|
147
|
+
&& (selectedItem && !!selectedItem[item[keyField]] // MultiDropdownRange
|
|
148
|
+
|| Array.isArray(selectedItem) && selectedItem.find(function (value) {
|
|
149
|
+
return value[labelField] === item[labelField];
|
|
150
|
+
}));
|
|
151
|
+
if (!_this.$props.multi) selected = item.key === selectedItem;
|
|
152
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
153
|
+
item: item
|
|
154
|
+
}), _transformOn(getItemEvents({
|
|
155
|
+
item: item
|
|
156
|
+
})), {
|
|
157
|
+
"key": item[keyField],
|
|
158
|
+
"class": "" + (selected ? 'active' : ''),
|
|
159
|
+
"style": {
|
|
160
|
+
backgroundColor: _this.getBackgroundColor(highlightedIndex === index, selected)
|
|
161
|
+
}
|
|
162
|
+
}), [renderItem ? renderItem({
|
|
163
|
+
label: item[labelField],
|
|
164
|
+
count: item.doc_count,
|
|
165
|
+
isChecked: selected && _this.$props.multi
|
|
166
|
+
}) : createVNode("div", null, [typeof item[labelField] === 'string' ? createVNode("span", {
|
|
167
|
+
"innerHTML": item[labelField]
|
|
168
|
+
}, null) : item[labelField], _this.$props.showCount && item.doc_count && createVNode("span", {
|
|
169
|
+
"class": getClassName(_this.$props.innerClass, 'count') || ''
|
|
170
|
+
}, [createTextVNode("\xA0("), item.doc_count, createTextVNode(")")])]), selected && _this.$props.multi ? createVNode(Tick, {
|
|
171
|
+
"class": getClassName(_this.$props.innerClass, 'icon') || ''
|
|
172
|
+
}, null) : null]);
|
|
173
|
+
}), footer]) : null]);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
methods: {
|
|
178
|
+
toggle: function toggle() {
|
|
179
|
+
this.isOpen = !this.$data.isOpen;
|
|
180
|
+
},
|
|
181
|
+
close: function close() {
|
|
182
|
+
this.isOpen = false;
|
|
183
|
+
},
|
|
184
|
+
onChange: function onChange(item) {
|
|
185
|
+
if (this.$props.returnsObject) {
|
|
186
|
+
this.$props.handleChange(item);
|
|
187
|
+
} else {
|
|
188
|
+
this.$props.handleChange(item[this.$props.keyField]);
|
|
189
|
+
}
|
|
190
|
+
if (!this.$props.multi) {
|
|
191
|
+
this.isOpen = false;
|
|
192
|
+
this.searchTerm = '';
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
handleStateChange: function handleStateChange(_ref2) {
|
|
196
|
+
var isOpen = _ref2.isOpen;
|
|
197
|
+
this.isOpen = isOpen;
|
|
198
|
+
},
|
|
199
|
+
getBackgroundColor: function getBackgroundColor(highlighted, selected) {
|
|
200
|
+
var isDark = this.$props.themePreset === 'dark';
|
|
201
|
+
if (highlighted) {
|
|
202
|
+
return isDark ? '#555' : '#eee';
|
|
203
|
+
}
|
|
204
|
+
if (selected) {
|
|
205
|
+
return isDark ? '#686868' : '#fafafa';
|
|
206
|
+
}
|
|
207
|
+
return isDark ? '#424242' : '#fff';
|
|
208
|
+
},
|
|
209
|
+
handleInputChange: function handleInputChange(e) {
|
|
210
|
+
var value = e.target.value;
|
|
211
|
+
this.searchTerm = value;
|
|
212
|
+
},
|
|
213
|
+
clearSearchTerm: function clearSearchTerm() {
|
|
214
|
+
this.searchTerm = '';
|
|
215
|
+
},
|
|
216
|
+
renderToString: function renderToString(value) {
|
|
217
|
+
var _this2 = this;
|
|
218
|
+
var customLabelRenderer = this.$props.customLabelRenderer;
|
|
219
|
+
if (customLabelRenderer) {
|
|
220
|
+
var customLabel = customLabelRenderer(value);
|
|
221
|
+
if (typeof customLabel === 'string') {
|
|
222
|
+
return customLabel;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (Array.isArray(value) && value.length) {
|
|
226
|
+
var arrayToRender = value.map(function (item) {
|
|
227
|
+
return _this2.renderToString(item);
|
|
228
|
+
});
|
|
229
|
+
return arrayToRender.join(', ');
|
|
230
|
+
}
|
|
231
|
+
if (value && typeof value === 'object') {
|
|
232
|
+
if (value[this.$props.labelField]) {
|
|
233
|
+
return value[this.$props.labelField];
|
|
234
|
+
}
|
|
235
|
+
if (Object.keys(value).length) {
|
|
236
|
+
return this.renderToString(Object.keys(value));
|
|
237
|
+
}
|
|
238
|
+
return this.$props.placeholder;
|
|
239
|
+
}
|
|
240
|
+
return value;
|
|
241
|
+
},
|
|
242
|
+
renderNoResult: function renderNoResult() {
|
|
243
|
+
var renderNoResults = this.$slots.renderNoResults || this.$props.renderNoResults;
|
|
244
|
+
return createVNode("p", {
|
|
245
|
+
"class": getClassName(this.$props.innerClass, 'noResults') || null
|
|
246
|
+
}, [isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
|
|
247
|
+
},
|
|
248
|
+
renderSearchbox: function renderSearchbox(eventObject) {
|
|
249
|
+
var _this3 = this;
|
|
250
|
+
var _this$$props2 = this.$props,
|
|
251
|
+
componentId = _this$$props2.componentId,
|
|
252
|
+
searchPlaceholder = _this$$props2.searchPlaceholder,
|
|
253
|
+
showClear = _this$$props2.showClear,
|
|
254
|
+
themePreset = _this$$props2.themePreset,
|
|
255
|
+
innerClass = _this$$props2.innerClass;
|
|
256
|
+
var InputComponent = createVNode(Input, mergeProps({
|
|
257
|
+
"id": componentId + "-input",
|
|
258
|
+
"style": {
|
|
259
|
+
border: 0,
|
|
260
|
+
borderBottom: '1px solid #ddd'
|
|
261
|
+
},
|
|
262
|
+
"showIcon": false,
|
|
263
|
+
"showClear": showClear,
|
|
264
|
+
"class": getClassName(innerClass, 'input'),
|
|
265
|
+
"placeholder": searchPlaceholder,
|
|
266
|
+
"value": this.$data.searchTerm,
|
|
267
|
+
"themePreset": themePreset
|
|
268
|
+
}, eventObject), null);
|
|
269
|
+
if (showClear) {
|
|
270
|
+
return createVNode(InputWrapper, null, {
|
|
271
|
+
"default": function _default() {
|
|
272
|
+
return [InputComponent, _this3.searchTerm && createVNode(IconGroup, {
|
|
273
|
+
"groupPosition": "right",
|
|
274
|
+
"positionType": "absolute"
|
|
275
|
+
}, {
|
|
276
|
+
"default": function _default() {
|
|
277
|
+
return [createVNode(IconWrapper, {
|
|
278
|
+
"onClick": _this3.clearSearchTerm,
|
|
279
|
+
"isClearIcon": true
|
|
280
|
+
}, {
|
|
281
|
+
"default": function _default() {
|
|
282
|
+
return [createVNode(CancelSvg, null, null)];
|
|
283
|
+
}
|
|
284
|
+
})];
|
|
285
|
+
}
|
|
286
|
+
})];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
return InputComponent;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export { Dropdown as D };
|
|
@@ -15,12 +15,13 @@ import { j as updateCustomQuery, u as updateDefaultQuery, i as isQueryIdentical,
|
|
|
15
15
|
import { C as ComponentWrapper } from './ComponentWrapper-8a3c388d.js';
|
|
16
16
|
import { P as PreferencesConsumer } from './PreferencesConsumer-b058d14e.js';
|
|
17
17
|
import { T as Title } from './Title-863dfa42.js';
|
|
18
|
-
import
|
|
18
|
+
import './CancelSvg-e7ae49e9.js';
|
|
19
19
|
import './Input-f7499ef8.js';
|
|
20
20
|
import 'compute-scroll-into-view';
|
|
21
21
|
import { C as Container } from './Container-d00219f7.js';
|
|
22
22
|
import '@appbaseio/reactivecore/lib/utils/suggestions';
|
|
23
23
|
import { g as getAggsQuery } from './utils-d7dd4f4e.js';
|
|
24
|
+
import { D as Dropdown } from './DropDown-13afb4d2.js';
|
|
24
25
|
|
|
25
26
|
function _isSlot(s) {
|
|
26
27
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|