@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
|
@@ -2,17 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
4
|
|
|
5
|
-
var reactivecore = require('@appbaseio/reactivecore');
|
|
6
|
-
var _transformOn = _interopDefault(require('@vue/babel-helper-vue-transform-on'));
|
|
7
5
|
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f8b843f8.js');
|
|
8
6
|
var vue = require('vue');
|
|
9
|
-
var VueTypes = _interopDefault(require('vue-types'));
|
|
10
7
|
var vueEmotion = require('@appbaseio/vue-emotion');
|
|
11
|
-
var vueTypes = require('./vueTypes-1bf00978.js');
|
|
12
|
-
var index = require('./index-779ed366.js');
|
|
13
|
-
var Input = require('./Input-497be42a.js');
|
|
14
8
|
var computeScrollIntoView = _interopDefault(require('compute-scroll-into-view'));
|
|
15
|
-
var suggestions = require('@appbaseio/reactivecore/lib/utils/suggestions');
|
|
16
9
|
|
|
17
10
|
var _templateObject;
|
|
18
11
|
var InputWrapper = vueEmotion.styled('span')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n flex: 1;\n position: relative;\n"])));
|
|
@@ -409,291 +402,8 @@ var CancelSvg = (function () {
|
|
|
409
402
|
}, null)]);
|
|
410
403
|
});
|
|
411
404
|
|
|
412
|
-
var _templateObject$3, _templateObject2;
|
|
413
|
-
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";
|
|
414
|
-
var dark = function dark(_ref) {
|
|
415
|
-
var theme = _ref.theme;
|
|
416
|
-
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";
|
|
417
|
-
};
|
|
418
|
-
var Select = vueEmotion.styled('button')(_templateObject$3 || (_templateObject$3 = _rollupPluginBabelHelpers._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) {
|
|
419
|
-
return props.small ? small : null;
|
|
420
|
-
}, function (_ref2) {
|
|
421
|
-
var themePreset = _ref2.themePreset;
|
|
422
|
-
return themePreset === 'dark' && dark;
|
|
423
|
-
});
|
|
424
|
-
var Tick = vueEmotion.styled('span')(_templateObject2 || (_templateObject2 = _rollupPluginBabelHelpers._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) {
|
|
425
|
-
var theme = _ref3.theme;
|
|
426
|
-
return theme.colors.primaryColor;
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
var _templateObject$4;
|
|
430
|
-
var open = "\n\ttop: 0.55em;\n\ttransform: rotate(-45deg);\n";
|
|
431
|
-
var Chevron = vueEmotion.styled('span')(_templateObject$4 || (_templateObject$4 = _rollupPluginBabelHelpers._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) {
|
|
432
|
-
return props.open ? open : null;
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
var getClassName = reactivecore.helper.getClassName;
|
|
436
|
-
var Dropdown = {
|
|
437
|
-
data: function data() {
|
|
438
|
-
this.__state = {
|
|
439
|
-
isOpen: false,
|
|
440
|
-
searchTerm: ''
|
|
441
|
-
};
|
|
442
|
-
return this.__state;
|
|
443
|
-
},
|
|
444
|
-
inject: {
|
|
445
|
-
theme: {
|
|
446
|
-
from: 'theme_reactivesearch'
|
|
447
|
-
}
|
|
448
|
-
},
|
|
449
|
-
props: {
|
|
450
|
-
innerClass: vueTypes.types.style,
|
|
451
|
-
items: vueTypes.types.data,
|
|
452
|
-
keyField: VueTypes.string.def('key'),
|
|
453
|
-
labelField: VueTypes.string.def('label'),
|
|
454
|
-
multi: VueTypes.bool,
|
|
455
|
-
// change event
|
|
456
|
-
placeholder: vueTypes.types.string,
|
|
457
|
-
returnsObject: VueTypes.bool,
|
|
458
|
-
customLabelRenderer: vueTypes.types.func,
|
|
459
|
-
hasCustomRenderer: VueTypes.bool,
|
|
460
|
-
customRenderer: vueTypes.types.func,
|
|
461
|
-
renderItem: vueTypes.types.func,
|
|
462
|
-
renderNoResults: VueTypes.any,
|
|
463
|
-
handleChange: vueTypes.types.func,
|
|
464
|
-
transformData: vueTypes.types.func,
|
|
465
|
-
selectedItem: vueTypes.types.selectedValue,
|
|
466
|
-
showCount: VueTypes.bool,
|
|
467
|
-
single: VueTypes.bool,
|
|
468
|
-
small: VueTypes.bool.def(false),
|
|
469
|
-
themePreset: vueTypes.types.themePreset,
|
|
470
|
-
showSearch: VueTypes.bool,
|
|
471
|
-
showClear: VueTypes.bool,
|
|
472
|
-
searchPlaceholder: VueTypes.string.def('Type here to search...')
|
|
473
|
-
},
|
|
474
|
-
render: function render() {
|
|
475
|
-
var _this = this;
|
|
476
|
-
var _this$$props = this.$props,
|
|
477
|
-
items = _this$$props.items,
|
|
478
|
-
selectedItem = _this$$props.selectedItem,
|
|
479
|
-
placeholder = _this$$props.placeholder,
|
|
480
|
-
labelField = _this$$props.labelField,
|
|
481
|
-
keyField = _this$$props.keyField,
|
|
482
|
-
themePreset = _this$$props.themePreset,
|
|
483
|
-
renderItem = _this$$props.renderItem,
|
|
484
|
-
transformData = _this$$props.transformData,
|
|
485
|
-
footer = _this$$props.footer,
|
|
486
|
-
customLabelRenderer = _this$$props.customLabelRenderer,
|
|
487
|
-
hasCustomRenderer = _this$$props.hasCustomRenderer,
|
|
488
|
-
customRenderer = _this$$props.customRenderer;
|
|
489
|
-
var itemsToRender = items;
|
|
490
|
-
if (transformData) {
|
|
491
|
-
itemsToRender = transformData(itemsToRender);
|
|
492
|
-
}
|
|
493
|
-
var filteredItemsToRender = itemsToRender.filter(function (item) {
|
|
494
|
-
if (String(item[labelField]).length) {
|
|
495
|
-
if (_this.$props.showSearch && _this.$data.searchTerm) {
|
|
496
|
-
return suggestions.replaceDiacritics(String(item[labelField])).toLowerCase().includes(suggestions.replaceDiacritics(_this.$data.searchTerm.toLowerCase()));
|
|
497
|
-
}
|
|
498
|
-
return true;
|
|
499
|
-
}
|
|
500
|
-
return false;
|
|
501
|
-
});
|
|
502
|
-
return vue.createVNode(Downshift, {
|
|
503
|
-
"isOpen": this.$data.isOpen,
|
|
504
|
-
"selectedItem": selectedItem,
|
|
505
|
-
"handleChange": this.onChange,
|
|
506
|
-
"handleMouseup": this.handleStateChange
|
|
507
|
-
}, {
|
|
508
|
-
"default": function _default(_ref) {
|
|
509
|
-
var getItemProps = _ref.getItemProps,
|
|
510
|
-
isOpen = _ref.isOpen,
|
|
511
|
-
highlightedIndex = _ref.highlightedIndex,
|
|
512
|
-
getButtonProps = _ref.getButtonProps,
|
|
513
|
-
getItemEvents = _ref.getItemEvents,
|
|
514
|
-
getInputEvents = _ref.getInputEvents;
|
|
515
|
-
return vue.createVNode("div", {
|
|
516
|
-
"class": Input.suggestionsContainer
|
|
517
|
-
}, [vue.createVNode(Select, vue.mergeProps(_transformOn(getButtonProps({
|
|
518
|
-
onClick: _this.toggle
|
|
519
|
-
})), {
|
|
520
|
-
"class": getClassName(_this.$props.innerClass, 'select') || '',
|
|
521
|
-
"title": selectedItem ? _this.renderToString(selectedItem) : placeholder,
|
|
522
|
-
"small": _this.$props.small,
|
|
523
|
-
"themePreset": _this.$props.themePreset
|
|
524
|
-
}), {
|
|
525
|
-
"default": function _default() {
|
|
526
|
-
return [customLabelRenderer ? customLabelRenderer(selectedItem) : vue.createVNode("div", null, [selectedItem ? _this.renderToString(selectedItem) : placeholder]), vue.createVNode(Chevron, {
|
|
527
|
-
"open": isOpen
|
|
528
|
-
}, null)];
|
|
529
|
-
}
|
|
530
|
-
}), hasCustomRenderer ? customRenderer(itemsToRender, {
|
|
531
|
-
getItemProps: getItemProps,
|
|
532
|
-
isOpen: isOpen,
|
|
533
|
-
highlightedIndex: highlightedIndex,
|
|
534
|
-
getButtonProps: getButtonProps,
|
|
535
|
-
getItemEvents: getItemEvents
|
|
536
|
-
}) : isOpen && itemsToRender.length ? vue.createVNode("ul", {
|
|
537
|
-
"class": Input.suggestions(themePreset, _this.theme) + " " + (_this.$props.small ? 'small' : '') + " " + getClassName(_this.$props.innerClass, 'list')
|
|
538
|
-
}, [_this.$props.showSearch ? _this.renderSearchbox({
|
|
539
|
-
on: {
|
|
540
|
-
input: getInputEvents({
|
|
541
|
-
onInput: _this.handleInputChange
|
|
542
|
-
}).input
|
|
543
|
-
}
|
|
544
|
-
}) : null, !hasCustomRenderer && filteredItemsToRender.length === 0 ? _this.renderNoResult() : filteredItemsToRender.map(function (item, index) {
|
|
545
|
-
var selected = _this.$props.multi // MultiDropdownList
|
|
546
|
-
&& (selectedItem && !!selectedItem[item[keyField]] // MultiDropdownRange
|
|
547
|
-
|| Array.isArray(selectedItem) && selectedItem.find(function (value) {
|
|
548
|
-
return value[labelField] === item[labelField];
|
|
549
|
-
}));
|
|
550
|
-
if (!_this.$props.multi) selected = item.key === selectedItem;
|
|
551
|
-
return vue.createVNode("li", vue.mergeProps(getItemProps({
|
|
552
|
-
item: item
|
|
553
|
-
}), _transformOn(getItemEvents({
|
|
554
|
-
item: item
|
|
555
|
-
})), {
|
|
556
|
-
"key": item[keyField],
|
|
557
|
-
"class": "" + (selected ? 'active' : ''),
|
|
558
|
-
"style": {
|
|
559
|
-
backgroundColor: _this.getBackgroundColor(highlightedIndex === index, selected)
|
|
560
|
-
}
|
|
561
|
-
}), [renderItem ? renderItem({
|
|
562
|
-
label: item[labelField],
|
|
563
|
-
count: item.doc_count,
|
|
564
|
-
isChecked: selected && _this.$props.multi
|
|
565
|
-
}) : vue.createVNode("div", null, [typeof item[labelField] === 'string' ? vue.createVNode("span", {
|
|
566
|
-
"innerHTML": item[labelField]
|
|
567
|
-
}, null) : item[labelField], _this.$props.showCount && item.doc_count && vue.createVNode("span", {
|
|
568
|
-
"class": getClassName(_this.$props.innerClass, 'count') || ''
|
|
569
|
-
}, [vue.createTextVNode("\xA0("), item.doc_count, vue.createTextVNode(")")])]), selected && _this.$props.multi ? vue.createVNode(Tick, {
|
|
570
|
-
"class": getClassName(_this.$props.innerClass, 'icon') || ''
|
|
571
|
-
}, null) : null]);
|
|
572
|
-
}), footer]) : null]);
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
},
|
|
576
|
-
methods: {
|
|
577
|
-
toggle: function toggle() {
|
|
578
|
-
this.isOpen = !this.$data.isOpen;
|
|
579
|
-
},
|
|
580
|
-
close: function close() {
|
|
581
|
-
this.isOpen = false;
|
|
582
|
-
},
|
|
583
|
-
onChange: function onChange(item) {
|
|
584
|
-
if (this.$props.returnsObject) {
|
|
585
|
-
this.$props.handleChange(item);
|
|
586
|
-
} else {
|
|
587
|
-
this.$props.handleChange(item[this.$props.keyField]);
|
|
588
|
-
}
|
|
589
|
-
if (!this.$props.multi) {
|
|
590
|
-
this.isOpen = false;
|
|
591
|
-
this.searchTerm = '';
|
|
592
|
-
}
|
|
593
|
-
},
|
|
594
|
-
handleStateChange: function handleStateChange(_ref2) {
|
|
595
|
-
var isOpen = _ref2.isOpen;
|
|
596
|
-
this.isOpen = isOpen;
|
|
597
|
-
},
|
|
598
|
-
getBackgroundColor: function getBackgroundColor(highlighted, selected) {
|
|
599
|
-
var isDark = this.$props.themePreset === 'dark';
|
|
600
|
-
if (highlighted) {
|
|
601
|
-
return isDark ? '#555' : '#eee';
|
|
602
|
-
}
|
|
603
|
-
if (selected) {
|
|
604
|
-
return isDark ? '#686868' : '#fafafa';
|
|
605
|
-
}
|
|
606
|
-
return isDark ? '#424242' : '#fff';
|
|
607
|
-
},
|
|
608
|
-
handleInputChange: function handleInputChange(e) {
|
|
609
|
-
var value = e.target.value;
|
|
610
|
-
this.searchTerm = value;
|
|
611
|
-
},
|
|
612
|
-
clearSearchTerm: function clearSearchTerm() {
|
|
613
|
-
this.searchTerm = '';
|
|
614
|
-
},
|
|
615
|
-
renderToString: function renderToString(value) {
|
|
616
|
-
var _this2 = this;
|
|
617
|
-
var customLabelRenderer = this.$props.customLabelRenderer;
|
|
618
|
-
if (customLabelRenderer) {
|
|
619
|
-
var customLabel = customLabelRenderer(value);
|
|
620
|
-
if (typeof customLabel === 'string') {
|
|
621
|
-
return customLabel;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
if (Array.isArray(value) && value.length) {
|
|
625
|
-
var arrayToRender = value.map(function (item) {
|
|
626
|
-
return _this2.renderToString(item);
|
|
627
|
-
});
|
|
628
|
-
return arrayToRender.join(', ');
|
|
629
|
-
}
|
|
630
|
-
if (value && typeof value === 'object') {
|
|
631
|
-
if (value[this.$props.labelField]) {
|
|
632
|
-
return value[this.$props.labelField];
|
|
633
|
-
}
|
|
634
|
-
if (Object.keys(value).length) {
|
|
635
|
-
return this.renderToString(Object.keys(value));
|
|
636
|
-
}
|
|
637
|
-
return this.$props.placeholder;
|
|
638
|
-
}
|
|
639
|
-
return value;
|
|
640
|
-
},
|
|
641
|
-
renderNoResult: function renderNoResult() {
|
|
642
|
-
var renderNoResults = this.$slots.renderNoResults || this.$props.renderNoResults;
|
|
643
|
-
return vue.createVNode("p", {
|
|
644
|
-
"class": getClassName(this.$props.innerClass, 'noResults') || null
|
|
645
|
-
}, [index.isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
|
|
646
|
-
},
|
|
647
|
-
renderSearchbox: function renderSearchbox(eventObject) {
|
|
648
|
-
var _this3 = this;
|
|
649
|
-
var _this$$props2 = this.$props,
|
|
650
|
-
componentId = _this$$props2.componentId,
|
|
651
|
-
searchPlaceholder = _this$$props2.searchPlaceholder,
|
|
652
|
-
showClear = _this$$props2.showClear,
|
|
653
|
-
themePreset = _this$$props2.themePreset,
|
|
654
|
-
innerClass = _this$$props2.innerClass;
|
|
655
|
-
var InputComponent = vue.createVNode(Input.Input, vue.mergeProps({
|
|
656
|
-
"id": componentId + "-input",
|
|
657
|
-
"style": {
|
|
658
|
-
border: 0,
|
|
659
|
-
borderBottom: '1px solid #ddd'
|
|
660
|
-
},
|
|
661
|
-
"showIcon": false,
|
|
662
|
-
"showClear": showClear,
|
|
663
|
-
"class": getClassName(innerClass, 'input'),
|
|
664
|
-
"placeholder": searchPlaceholder,
|
|
665
|
-
"value": this.$data.searchTerm,
|
|
666
|
-
"themePreset": themePreset
|
|
667
|
-
}, eventObject), null);
|
|
668
|
-
if (showClear) {
|
|
669
|
-
return vue.createVNode(InputWrapper, null, {
|
|
670
|
-
"default": function _default() {
|
|
671
|
-
return [InputComponent, _this3.searchTerm && vue.createVNode(IconGroup, {
|
|
672
|
-
"groupPosition": "right",
|
|
673
|
-
"positionType": "absolute"
|
|
674
|
-
}, {
|
|
675
|
-
"default": function _default() {
|
|
676
|
-
return [vue.createVNode(IconWrapper, {
|
|
677
|
-
"onClick": _this3.clearSearchTerm,
|
|
678
|
-
"isClearIcon": true
|
|
679
|
-
}, {
|
|
680
|
-
"default": function _default() {
|
|
681
|
-
return [vue.createVNode(CancelSvg, null, null)];
|
|
682
|
-
}
|
|
683
|
-
})];
|
|
684
|
-
}
|
|
685
|
-
})];
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
return InputComponent;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
|
|
694
405
|
exports.CancelSvg = CancelSvg;
|
|
695
406
|
exports.Downshift = Downshift;
|
|
696
|
-
exports.Dropdown = Dropdown;
|
|
697
407
|
exports.IconGroup = IconGroup;
|
|
698
408
|
exports.IconWrapper = IconWrapper;
|
|
699
409
|
exports.InputWrapper = InputWrapper;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
+
|
|
5
|
+
var reactivecore = require('@appbaseio/reactivecore');
|
|
6
|
+
var _transformOn = _interopDefault(require('@vue/babel-helper-vue-transform-on'));
|
|
7
|
+
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f8b843f8.js');
|
|
8
|
+
var vue = require('vue');
|
|
9
|
+
var VueTypes = _interopDefault(require('vue-types'));
|
|
10
|
+
var vueEmotion = require('@appbaseio/vue-emotion');
|
|
11
|
+
var vueTypes = require('./vueTypes-1bf00978.js');
|
|
12
|
+
var index = require('./index-779ed366.js');
|
|
13
|
+
var CancelSvg = require('./CancelSvg-ab0f8b23.js');
|
|
14
|
+
var Input = require('./Input-497be42a.js');
|
|
15
|
+
var suggestions = require('@appbaseio/reactivecore/lib/utils/suggestions');
|
|
16
|
+
|
|
17
|
+
var _templateObject, _templateObject2;
|
|
18
|
+
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";
|
|
19
|
+
var dark = function dark(_ref) {
|
|
20
|
+
var theme = _ref.theme;
|
|
21
|
+
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";
|
|
22
|
+
};
|
|
23
|
+
var Select = vueEmotion.styled('button')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._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) {
|
|
24
|
+
return props.small ? small : null;
|
|
25
|
+
}, function (_ref2) {
|
|
26
|
+
var themePreset = _ref2.themePreset;
|
|
27
|
+
return themePreset === 'dark' && dark;
|
|
28
|
+
});
|
|
29
|
+
var Tick = vueEmotion.styled('span')(_templateObject2 || (_templateObject2 = _rollupPluginBabelHelpers._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) {
|
|
30
|
+
var theme = _ref3.theme;
|
|
31
|
+
return theme.colors.primaryColor;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
var _templateObject$1;
|
|
35
|
+
var open = "\n\ttop: 0.55em;\n\ttransform: rotate(-45deg);\n";
|
|
36
|
+
var Chevron = vueEmotion.styled('span')(_templateObject$1 || (_templateObject$1 = _rollupPluginBabelHelpers._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) {
|
|
37
|
+
return props.open ? open : null;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var getClassName = reactivecore.helper.getClassName;
|
|
41
|
+
var Dropdown = {
|
|
42
|
+
data: function data() {
|
|
43
|
+
this.__state = {
|
|
44
|
+
isOpen: false,
|
|
45
|
+
searchTerm: ''
|
|
46
|
+
};
|
|
47
|
+
return this.__state;
|
|
48
|
+
},
|
|
49
|
+
inject: {
|
|
50
|
+
theme: {
|
|
51
|
+
from: 'theme_reactivesearch'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
props: {
|
|
55
|
+
innerClass: vueTypes.types.style,
|
|
56
|
+
items: vueTypes.types.data,
|
|
57
|
+
keyField: VueTypes.string.def('key'),
|
|
58
|
+
labelField: VueTypes.string.def('label'),
|
|
59
|
+
multi: VueTypes.bool,
|
|
60
|
+
// change event
|
|
61
|
+
placeholder: vueTypes.types.string,
|
|
62
|
+
returnsObject: VueTypes.bool,
|
|
63
|
+
customLabelRenderer: vueTypes.types.func,
|
|
64
|
+
hasCustomRenderer: VueTypes.bool,
|
|
65
|
+
customRenderer: vueTypes.types.func,
|
|
66
|
+
renderItem: vueTypes.types.func,
|
|
67
|
+
renderNoResults: VueTypes.any,
|
|
68
|
+
handleChange: vueTypes.types.func,
|
|
69
|
+
transformData: vueTypes.types.func,
|
|
70
|
+
selectedItem: vueTypes.types.selectedValue,
|
|
71
|
+
showCount: VueTypes.bool,
|
|
72
|
+
single: VueTypes.bool,
|
|
73
|
+
small: VueTypes.bool.def(false),
|
|
74
|
+
themePreset: vueTypes.types.themePreset,
|
|
75
|
+
showSearch: VueTypes.bool,
|
|
76
|
+
showClear: VueTypes.bool,
|
|
77
|
+
searchPlaceholder: VueTypes.string.def('Type here to search...')
|
|
78
|
+
},
|
|
79
|
+
render: function render() {
|
|
80
|
+
var _this = this;
|
|
81
|
+
var _this$$props = this.$props,
|
|
82
|
+
items = _this$$props.items,
|
|
83
|
+
selectedItem = _this$$props.selectedItem,
|
|
84
|
+
placeholder = _this$$props.placeholder,
|
|
85
|
+
labelField = _this$$props.labelField,
|
|
86
|
+
keyField = _this$$props.keyField,
|
|
87
|
+
themePreset = _this$$props.themePreset,
|
|
88
|
+
renderItem = _this$$props.renderItem,
|
|
89
|
+
transformData = _this$$props.transformData,
|
|
90
|
+
footer = _this$$props.footer,
|
|
91
|
+
customLabelRenderer = _this$$props.customLabelRenderer,
|
|
92
|
+
hasCustomRenderer = _this$$props.hasCustomRenderer,
|
|
93
|
+
customRenderer = _this$$props.customRenderer;
|
|
94
|
+
var itemsToRender = items;
|
|
95
|
+
if (transformData) {
|
|
96
|
+
itemsToRender = transformData(itemsToRender);
|
|
97
|
+
}
|
|
98
|
+
var filteredItemsToRender = itemsToRender.filter(function (item) {
|
|
99
|
+
if (String(item[labelField]).length) {
|
|
100
|
+
if (_this.$props.showSearch && _this.$data.searchTerm) {
|
|
101
|
+
return suggestions.replaceDiacritics(String(item[labelField])).toLowerCase().includes(suggestions.replaceDiacritics(_this.$data.searchTerm.toLowerCase()));
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
});
|
|
107
|
+
return vue.createVNode(CancelSvg.Downshift, {
|
|
108
|
+
"isOpen": this.$data.isOpen,
|
|
109
|
+
"selectedItem": selectedItem,
|
|
110
|
+
"handleChange": this.onChange,
|
|
111
|
+
"handleMouseup": this.handleStateChange
|
|
112
|
+
}, {
|
|
113
|
+
"default": function _default(_ref) {
|
|
114
|
+
var getItemProps = _ref.getItemProps,
|
|
115
|
+
isOpen = _ref.isOpen,
|
|
116
|
+
highlightedIndex = _ref.highlightedIndex,
|
|
117
|
+
getButtonProps = _ref.getButtonProps,
|
|
118
|
+
getItemEvents = _ref.getItemEvents,
|
|
119
|
+
getInputEvents = _ref.getInputEvents;
|
|
120
|
+
return vue.createVNode("div", {
|
|
121
|
+
"class": Input.suggestionsContainer
|
|
122
|
+
}, [vue.createVNode(Select, vue.mergeProps(_transformOn(getButtonProps({
|
|
123
|
+
onClick: _this.toggle
|
|
124
|
+
})), {
|
|
125
|
+
"class": getClassName(_this.$props.innerClass, 'select') || '',
|
|
126
|
+
"title": selectedItem ? _this.renderToString(selectedItem) : placeholder,
|
|
127
|
+
"small": _this.$props.small,
|
|
128
|
+
"themePreset": _this.$props.themePreset
|
|
129
|
+
}), {
|
|
130
|
+
"default": function _default() {
|
|
131
|
+
return [customLabelRenderer ? customLabelRenderer(selectedItem) : vue.createVNode("div", null, [selectedItem ? _this.renderToString(selectedItem) : placeholder]), vue.createVNode(Chevron, {
|
|
132
|
+
"open": isOpen
|
|
133
|
+
}, null)];
|
|
134
|
+
}
|
|
135
|
+
}), hasCustomRenderer ? customRenderer(itemsToRender, {
|
|
136
|
+
getItemProps: getItemProps,
|
|
137
|
+
isOpen: isOpen,
|
|
138
|
+
highlightedIndex: highlightedIndex,
|
|
139
|
+
getButtonProps: getButtonProps,
|
|
140
|
+
getItemEvents: getItemEvents
|
|
141
|
+
}) : isOpen && itemsToRender.length ? vue.createVNode("ul", {
|
|
142
|
+
"class": Input.suggestions(themePreset, _this.theme) + " " + (_this.$props.small ? 'small' : '') + " " + getClassName(_this.$props.innerClass, 'list')
|
|
143
|
+
}, [_this.$props.showSearch ? _this.renderSearchbox({
|
|
144
|
+
on: {
|
|
145
|
+
input: getInputEvents({
|
|
146
|
+
onInput: _this.handleInputChange
|
|
147
|
+
}).input
|
|
148
|
+
}
|
|
149
|
+
}) : null, !hasCustomRenderer && filteredItemsToRender.length === 0 ? _this.renderNoResult() : filteredItemsToRender.map(function (item, index) {
|
|
150
|
+
var selected = _this.$props.multi // MultiDropdownList
|
|
151
|
+
&& (selectedItem && !!selectedItem[item[keyField]] // MultiDropdownRange
|
|
152
|
+
|| Array.isArray(selectedItem) && selectedItem.find(function (value) {
|
|
153
|
+
return value[labelField] === item[labelField];
|
|
154
|
+
}));
|
|
155
|
+
if (!_this.$props.multi) selected = item.key === selectedItem;
|
|
156
|
+
return vue.createVNode("li", vue.mergeProps(getItemProps({
|
|
157
|
+
item: item
|
|
158
|
+
}), _transformOn(getItemEvents({
|
|
159
|
+
item: item
|
|
160
|
+
})), {
|
|
161
|
+
"key": item[keyField],
|
|
162
|
+
"class": "" + (selected ? 'active' : ''),
|
|
163
|
+
"style": {
|
|
164
|
+
backgroundColor: _this.getBackgroundColor(highlightedIndex === index, selected)
|
|
165
|
+
}
|
|
166
|
+
}), [renderItem ? renderItem({
|
|
167
|
+
label: item[labelField],
|
|
168
|
+
count: item.doc_count,
|
|
169
|
+
isChecked: selected && _this.$props.multi
|
|
170
|
+
}) : vue.createVNode("div", null, [typeof item[labelField] === 'string' ? vue.createVNode("span", {
|
|
171
|
+
"innerHTML": item[labelField]
|
|
172
|
+
}, null) : item[labelField], _this.$props.showCount && item.doc_count && vue.createVNode("span", {
|
|
173
|
+
"class": getClassName(_this.$props.innerClass, 'count') || ''
|
|
174
|
+
}, [vue.createTextVNode("\xA0("), item.doc_count, vue.createTextVNode(")")])]), selected && _this.$props.multi ? vue.createVNode(Tick, {
|
|
175
|
+
"class": getClassName(_this.$props.innerClass, 'icon') || ''
|
|
176
|
+
}, null) : null]);
|
|
177
|
+
}), footer]) : null]);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
methods: {
|
|
182
|
+
toggle: function toggle() {
|
|
183
|
+
this.isOpen = !this.$data.isOpen;
|
|
184
|
+
},
|
|
185
|
+
close: function close() {
|
|
186
|
+
this.isOpen = false;
|
|
187
|
+
},
|
|
188
|
+
onChange: function onChange(item) {
|
|
189
|
+
if (this.$props.returnsObject) {
|
|
190
|
+
this.$props.handleChange(item);
|
|
191
|
+
} else {
|
|
192
|
+
this.$props.handleChange(item[this.$props.keyField]);
|
|
193
|
+
}
|
|
194
|
+
if (!this.$props.multi) {
|
|
195
|
+
this.isOpen = false;
|
|
196
|
+
this.searchTerm = '';
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
handleStateChange: function handleStateChange(_ref2) {
|
|
200
|
+
var isOpen = _ref2.isOpen;
|
|
201
|
+
this.isOpen = isOpen;
|
|
202
|
+
},
|
|
203
|
+
getBackgroundColor: function getBackgroundColor(highlighted, selected) {
|
|
204
|
+
var isDark = this.$props.themePreset === 'dark';
|
|
205
|
+
if (highlighted) {
|
|
206
|
+
return isDark ? '#555' : '#eee';
|
|
207
|
+
}
|
|
208
|
+
if (selected) {
|
|
209
|
+
return isDark ? '#686868' : '#fafafa';
|
|
210
|
+
}
|
|
211
|
+
return isDark ? '#424242' : '#fff';
|
|
212
|
+
},
|
|
213
|
+
handleInputChange: function handleInputChange(e) {
|
|
214
|
+
var value = e.target.value;
|
|
215
|
+
this.searchTerm = value;
|
|
216
|
+
},
|
|
217
|
+
clearSearchTerm: function clearSearchTerm() {
|
|
218
|
+
this.searchTerm = '';
|
|
219
|
+
},
|
|
220
|
+
renderToString: function renderToString(value) {
|
|
221
|
+
var _this2 = this;
|
|
222
|
+
var customLabelRenderer = this.$props.customLabelRenderer;
|
|
223
|
+
if (customLabelRenderer) {
|
|
224
|
+
var customLabel = customLabelRenderer(value);
|
|
225
|
+
if (typeof customLabel === 'string') {
|
|
226
|
+
return customLabel;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (Array.isArray(value) && value.length) {
|
|
230
|
+
var arrayToRender = value.map(function (item) {
|
|
231
|
+
return _this2.renderToString(item);
|
|
232
|
+
});
|
|
233
|
+
return arrayToRender.join(', ');
|
|
234
|
+
}
|
|
235
|
+
if (value && typeof value === 'object') {
|
|
236
|
+
if (value[this.$props.labelField]) {
|
|
237
|
+
return value[this.$props.labelField];
|
|
238
|
+
}
|
|
239
|
+
if (Object.keys(value).length) {
|
|
240
|
+
return this.renderToString(Object.keys(value));
|
|
241
|
+
}
|
|
242
|
+
return this.$props.placeholder;
|
|
243
|
+
}
|
|
244
|
+
return value;
|
|
245
|
+
},
|
|
246
|
+
renderNoResult: function renderNoResult() {
|
|
247
|
+
var renderNoResults = this.$slots.renderNoResults || this.$props.renderNoResults;
|
|
248
|
+
return vue.createVNode("p", {
|
|
249
|
+
"class": getClassName(this.$props.innerClass, 'noResults') || null
|
|
250
|
+
}, [index.isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
|
|
251
|
+
},
|
|
252
|
+
renderSearchbox: function renderSearchbox(eventObject) {
|
|
253
|
+
var _this3 = this;
|
|
254
|
+
var _this$$props2 = this.$props,
|
|
255
|
+
componentId = _this$$props2.componentId,
|
|
256
|
+
searchPlaceholder = _this$$props2.searchPlaceholder,
|
|
257
|
+
showClear = _this$$props2.showClear,
|
|
258
|
+
themePreset = _this$$props2.themePreset,
|
|
259
|
+
innerClass = _this$$props2.innerClass;
|
|
260
|
+
var InputComponent = vue.createVNode(Input.Input, vue.mergeProps({
|
|
261
|
+
"id": componentId + "-input",
|
|
262
|
+
"style": {
|
|
263
|
+
border: 0,
|
|
264
|
+
borderBottom: '1px solid #ddd'
|
|
265
|
+
},
|
|
266
|
+
"showIcon": false,
|
|
267
|
+
"showClear": showClear,
|
|
268
|
+
"class": getClassName(innerClass, 'input'),
|
|
269
|
+
"placeholder": searchPlaceholder,
|
|
270
|
+
"value": this.$data.searchTerm,
|
|
271
|
+
"themePreset": themePreset
|
|
272
|
+
}, eventObject), null);
|
|
273
|
+
if (showClear) {
|
|
274
|
+
return vue.createVNode(CancelSvg.InputWrapper, null, {
|
|
275
|
+
"default": function _default() {
|
|
276
|
+
return [InputComponent, _this3.searchTerm && vue.createVNode(CancelSvg.IconGroup, {
|
|
277
|
+
"groupPosition": "right",
|
|
278
|
+
"positionType": "absolute"
|
|
279
|
+
}, {
|
|
280
|
+
"default": function _default() {
|
|
281
|
+
return [vue.createVNode(CancelSvg.IconWrapper, {
|
|
282
|
+
"onClick": _this3.clearSearchTerm,
|
|
283
|
+
"isClearIcon": true
|
|
284
|
+
}, {
|
|
285
|
+
"default": function _default() {
|
|
286
|
+
return [vue.createVNode(CancelSvg.CancelSvg, null, null)];
|
|
287
|
+
}
|
|
288
|
+
})];
|
|
289
|
+
}
|
|
290
|
+
})];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return InputComponent;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
exports.Dropdown = Dropdown;
|
|
@@ -21,12 +21,13 @@ var index = require('./index-779ed366.js');
|
|
|
21
21
|
var ComponentWrapper = require('./ComponentWrapper-9146d811.js');
|
|
22
22
|
var PreferencesConsumer = require('./PreferencesConsumer-85dee673.js');
|
|
23
23
|
var Title = require('./Title-8802a218.js');
|
|
24
|
-
|
|
24
|
+
require('./CancelSvg-ab0f8b23.js');
|
|
25
25
|
require('./Input-497be42a.js');
|
|
26
26
|
require('compute-scroll-into-view');
|
|
27
27
|
var Container = require('./Container-29f049b2.js');
|
|
28
28
|
require('@appbaseio/reactivecore/lib/utils/suggestions');
|
|
29
29
|
var utils = require('./utils-c9bd5628.js');
|
|
30
|
+
var DropDown = require('./DropDown-e7125b72.js');
|
|
30
31
|
|
|
31
32
|
function _isSlot(s) {
|
|
32
33
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
|