@appbaseio/reactivesearch-vue 1.36.0 → 1.36.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 +35040 -26307
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +42 -42
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/DataSearch.js +95 -66
- package/dist/cjs/{ReactiveComponentPrivate-04f3bf64.js → ReactiveComponentPrivate-3a197e2c.js} +103 -66
- package/dist/cjs/ReactiveComponentPrivate.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/install.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/es/DataSearch.js +95 -66
- package/dist/es/{ReactiveComponentPrivate-a774148b.js → ReactiveComponentPrivate-ebe9a60a.js} +103 -66
- package/dist/es/ReactiveComponentPrivate.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/install.js +1 -1
- package/dist/es/version.js +1 -1
- package/package.json +1 -1
package/dist/es/DataSearch.js
CHANGED
|
@@ -53,7 +53,8 @@ var DataSearch = {
|
|
|
53
53
|
selectedTags: [],
|
|
54
54
|
isOpen: false,
|
|
55
55
|
normalizedSuggestions: [],
|
|
56
|
-
isPending: false
|
|
56
|
+
isPending: false,
|
|
57
|
+
isSuggestionSelected: false
|
|
57
58
|
};
|
|
58
59
|
this.internalComponent = props.componentId + "__internal";
|
|
59
60
|
return this.__state;
|
|
@@ -447,6 +448,7 @@ var DataSearch = {
|
|
|
447
448
|
_this.getRecentSearches();
|
|
448
449
|
}
|
|
449
450
|
if (isTagsMode) {
|
|
451
|
+
var isTagAdded = false;
|
|
450
452
|
if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
|
|
451
453
|
// check if value already present in selectedTags
|
|
452
454
|
if (typeof value === 'string' && _this.selectedTags.includes(value)) {
|
|
@@ -455,14 +457,36 @@ var DataSearch = {
|
|
|
455
457
|
}
|
|
456
458
|
_this.selectedTags = [].concat(_this.selectedTags);
|
|
457
459
|
if (typeof value === 'string' && !!value) {
|
|
458
|
-
|
|
460
|
+
if (props.strictSelection && cause === causes.SUGGESTION_SELECT) {
|
|
461
|
+
_this.selectedTags.push(value);
|
|
462
|
+
isTagAdded = true;
|
|
463
|
+
} else if (!props.strictSelection) {
|
|
464
|
+
_this.selectedTags.push(value);
|
|
465
|
+
isTagAdded = true;
|
|
466
|
+
}
|
|
459
467
|
} else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
|
|
460
|
-
|
|
468
|
+
if (props.strictSelection && cause === causes.SUGGESTION_SELECT) {
|
|
469
|
+
_this.selectedTags = value;
|
|
470
|
+
isTagAdded = true;
|
|
471
|
+
} else if (!props.strictSelection) {
|
|
472
|
+
_this.selectedTags.push(value);
|
|
473
|
+
isTagAdded = true;
|
|
474
|
+
}
|
|
461
475
|
}
|
|
462
476
|
} else if (value) {
|
|
463
|
-
|
|
477
|
+
if (props.strictSelection && cause === causes.SUGGESTION_SELECT) {
|
|
478
|
+
_this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
|
|
479
|
+
isTagAdded = true;
|
|
480
|
+
} else if (!props.strictSelection) {
|
|
481
|
+
_this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
|
|
482
|
+
isTagAdded = true;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (props.strictSelection && !isTagAdded) {
|
|
486
|
+
_this.currentValue = value;
|
|
487
|
+
} else {
|
|
488
|
+
_this.currentValue = '';
|
|
464
489
|
}
|
|
465
|
-
_this.currentValue = '';
|
|
466
490
|
} else {
|
|
467
491
|
_this.currentValue = value;
|
|
468
492
|
}
|
|
@@ -482,7 +506,7 @@ var DataSearch = {
|
|
|
482
506
|
if (props.strictSelection && props.autosuggest) {
|
|
483
507
|
if (cause === causes.SUGGESTION_SELECT || props.value !== undefined) {
|
|
484
508
|
_this.updateQueryHandler(props.componentId, queryHandlerValue, props);
|
|
485
|
-
} else if (_this.currentValue !== '') {
|
|
509
|
+
} else if (_this.currentValue !== '' && !props.strictSelection) {
|
|
486
510
|
_this.setValue('', true);
|
|
487
511
|
}
|
|
488
512
|
} else {
|
|
@@ -496,7 +520,7 @@ var DataSearch = {
|
|
|
496
520
|
_this.$emit('value-change', value);
|
|
497
521
|
// Set the already fetched suggestions if query is same as used last to fetch the hits
|
|
498
522
|
if (value === _this.lastUsedQuery) {
|
|
499
|
-
_this.
|
|
523
|
+
_this.normalizedSuggestions = _this.onSuggestions(_this.suggestions);
|
|
500
524
|
// invoke on suggestions
|
|
501
525
|
_this.$emit('suggestions', _this.suggestions);
|
|
502
526
|
} else if (!value) {
|
|
@@ -606,17 +630,17 @@ var DataSearch = {
|
|
|
606
630
|
var targetValue = event.target.value;
|
|
607
631
|
var _this$$props2 = this.$props,
|
|
608
632
|
value = _this$$props2.value,
|
|
609
|
-
|
|
610
|
-
size = _this$$props2.size,
|
|
611
|
-
autosuggest = _this$$props2.autosuggest;
|
|
633
|
+
size = _this$$props2.size;
|
|
612
634
|
if (value !== undefined) {
|
|
613
635
|
this.isPending = true;
|
|
614
636
|
}
|
|
615
637
|
// if a suggestion was selected, delegate the handling to suggestion handler
|
|
616
638
|
if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
|
|
617
639
|
this.isPending = false;
|
|
618
|
-
|
|
619
|
-
|
|
640
|
+
if (!this.isSuggestionSelected) {
|
|
641
|
+
this.setValue(targetValue, true, this.$props, undefined, false);
|
|
642
|
+
this.onValueSelectedHandler(targetValue, causes.ENTER_PRESS);
|
|
643
|
+
}
|
|
620
644
|
}
|
|
621
645
|
// Need to review
|
|
622
646
|
this.$emit('keyDown', event, this.triggerQuery);
|
|
@@ -652,11 +676,16 @@ var DataSearch = {
|
|
|
652
676
|
}
|
|
653
677
|
},
|
|
654
678
|
onSuggestionSelected: function onSuggestionSelected(suggestion) {
|
|
679
|
+
var _this3 = this;
|
|
655
680
|
var value = this.$props.value;
|
|
656
681
|
// Record analytics for selected suggestions
|
|
657
682
|
this.triggerClickAnalytics(suggestion._click_id);
|
|
658
683
|
if (value === undefined) {
|
|
659
684
|
this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT);
|
|
685
|
+
this.isSuggestionSelected = true;
|
|
686
|
+
setTimeout(function () {
|
|
687
|
+
_this3.isSuggestionSelected = false;
|
|
688
|
+
}, 50);
|
|
660
689
|
} else if (this.$options.isTagsMode) {
|
|
661
690
|
var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
|
|
662
691
|
if (this.selectedTags.includes(suggestion.value)) {
|
|
@@ -762,7 +791,7 @@ var DataSearch = {
|
|
|
762
791
|
return null;
|
|
763
792
|
},
|
|
764
793
|
renderTag: function renderTag(item) {
|
|
765
|
-
var
|
|
794
|
+
var _this4 = this;
|
|
766
795
|
var h = this.$createElement;
|
|
767
796
|
var innerClass = this.$props.innerClass;
|
|
768
797
|
return h(TagItem, {
|
|
@@ -775,7 +804,7 @@ var DataSearch = {
|
|
|
775
804
|
"class": "close-icon",
|
|
776
805
|
"on": {
|
|
777
806
|
"click": function click() {
|
|
778
|
-
return
|
|
807
|
+
return _this4.clearTag(item);
|
|
779
808
|
}
|
|
780
809
|
}
|
|
781
810
|
}, [h(CancelSvg)])]);
|
|
@@ -797,7 +826,7 @@ var DataSearch = {
|
|
|
797
826
|
}
|
|
798
827
|
},
|
|
799
828
|
renderTags: function renderTags() {
|
|
800
|
-
var
|
|
829
|
+
var _this5 = this;
|
|
801
830
|
var h = this.$createElement;
|
|
802
831
|
if (!Array.isArray(this.selectedTags)) {
|
|
803
832
|
return null;
|
|
@@ -810,7 +839,7 @@ var DataSearch = {
|
|
|
810
839
|
handleClear: this.clearTag,
|
|
811
840
|
handleClearAll: this.clearAllTags
|
|
812
841
|
}) : h(TagsContainer, [tagsList.map(function (item) {
|
|
813
|
-
return
|
|
842
|
+
return _this5.renderTag(item);
|
|
814
843
|
}), shouldRenderClearAllTag && h(TagItem, {
|
|
815
844
|
"class": getClassName(this.$props.innerClass, 'selected-tag') || ''
|
|
816
845
|
}, [h("span", ["Clear All"]), h("span", {
|
|
@@ -889,7 +918,7 @@ var DataSearch = {
|
|
|
889
918
|
(_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
|
|
890
919
|
},
|
|
891
920
|
listenForFocusShortcuts: function listenForFocusShortcuts() {
|
|
892
|
-
var
|
|
921
|
+
var _this6 = this;
|
|
893
922
|
var _this$$props$focusSho = this.$props.focusShortcuts,
|
|
894
923
|
focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
|
|
895
924
|
if (isEmpty(focusShortcuts)) {
|
|
@@ -904,7 +933,7 @@ var DataSearch = {
|
|
|
904
933
|
function (event, handler) {
|
|
905
934
|
// Prevent the default refresh event under WINDOWS system
|
|
906
935
|
event.preventDefault();
|
|
907
|
-
|
|
936
|
+
_this6.focusSearchBox(event);
|
|
908
937
|
});
|
|
909
938
|
|
|
910
939
|
// if one of modifier keys are used, they are handled below
|
|
@@ -914,7 +943,7 @@ var DataSearch = {
|
|
|
914
943
|
for (var index = 0; index < modifierKeys.length; index += 1) {
|
|
915
944
|
var element = modifierKeys[index];
|
|
916
945
|
if (hotkeys[element]) {
|
|
917
|
-
|
|
946
|
+
_this6.focusSearchBox(event);
|
|
918
947
|
break;
|
|
919
948
|
}
|
|
920
949
|
}
|
|
@@ -922,7 +951,7 @@ var DataSearch = {
|
|
|
922
951
|
}
|
|
923
952
|
},
|
|
924
953
|
render: function render() {
|
|
925
|
-
var
|
|
954
|
+
var _this7 = this;
|
|
926
955
|
var h = arguments[0];
|
|
927
956
|
var _this$$props6 = this.$props,
|
|
928
957
|
theme = _this$$props6.theme,
|
|
@@ -957,14 +986,14 @@ var DataSearch = {
|
|
|
957
986
|
highlightedIndex = _ref4.highlightedIndex,
|
|
958
987
|
setHighlightedIndex = _ref4.setHighlightedIndex;
|
|
959
988
|
var renderSuggestionsContainer = function renderSuggestionsContainer() {
|
|
960
|
-
return h("div", [
|
|
989
|
+
return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
|
|
961
990
|
isOpen: isOpen,
|
|
962
991
|
getItemProps: getItemProps,
|
|
963
992
|
getItemEvents: getItemEvents,
|
|
964
993
|
highlightedIndex: highlightedIndex
|
|
965
|
-
}),
|
|
966
|
-
"class": suggestions(
|
|
967
|
-
}, [
|
|
994
|
+
}), _this7.renderErrorComponent(), !_this7.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
|
|
995
|
+
"class": suggestions(_this7.themePreset, theme) + " " + getClassName(_this7.$props.innerClass, 'list')
|
|
996
|
+
}, [_this7.suggestionsList.slice(0, size || 10).map(function (item, index) {
|
|
968
997
|
return h("li", {
|
|
969
998
|
"domProps": _extends({}, getItemProps({
|
|
970
999
|
item: item
|
|
@@ -974,15 +1003,15 @@ var DataSearch = {
|
|
|
974
1003
|
})),
|
|
975
1004
|
"key": index + 1 + "-" + item.value,
|
|
976
1005
|
"style": {
|
|
977
|
-
backgroundColor:
|
|
1006
|
+
backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
|
|
978
1007
|
}
|
|
979
1008
|
}, [h(SuggestionItem, {
|
|
980
1009
|
"attrs": {
|
|
981
|
-
"currentValue":
|
|
1010
|
+
"currentValue": _this7.currentValue,
|
|
982
1011
|
"suggestion": item
|
|
983
1012
|
}
|
|
984
1013
|
})]);
|
|
985
|
-
}),
|
|
1014
|
+
}), _this7.defaultSearchSuggestions.map(function (sugg, index) {
|
|
986
1015
|
return h("li", {
|
|
987
1016
|
"domProps": _extends({}, getItemProps({
|
|
988
1017
|
item: sugg
|
|
@@ -990,9 +1019,9 @@ var DataSearch = {
|
|
|
990
1019
|
"on": _extends({}, getItemEvents({
|
|
991
1020
|
item: sugg
|
|
992
1021
|
})),
|
|
993
|
-
"key":
|
|
1022
|
+
"key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
|
|
994
1023
|
"style": {
|
|
995
|
-
backgroundColor:
|
|
1024
|
+
backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
|
|
996
1025
|
justifyContent: 'flex-start'
|
|
997
1026
|
}
|
|
998
1027
|
}, [h("div", {
|
|
@@ -1001,28 +1030,28 @@ var DataSearch = {
|
|
|
1001
1030
|
}
|
|
1002
1031
|
}, [sugg.source && sugg.source._recent_search && h(CustomSvg, {
|
|
1003
1032
|
"attrs": {
|
|
1004
|
-
"className": getClassName(
|
|
1033
|
+
"className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
|
|
1005
1034
|
"icon": recentSearchesIcon,
|
|
1006
1035
|
"type": "recent-search-icon"
|
|
1007
1036
|
}
|
|
1008
1037
|
}), sugg.source && sugg.source._popular_suggestion && h(CustomSvg, {
|
|
1009
1038
|
"attrs": {
|
|
1010
|
-
"className": getClassName(
|
|
1039
|
+
"className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
|
|
1011
1040
|
"icon": popularSearchesIcon,
|
|
1012
1041
|
"type": "popular-search-icon"
|
|
1013
1042
|
}
|
|
1014
1043
|
})]), h(SuggestionItem, {
|
|
1015
1044
|
"attrs": {
|
|
1016
|
-
"currentValue":
|
|
1045
|
+
"currentValue": _this7.currentValue,
|
|
1017
1046
|
"suggestion": sugg
|
|
1018
1047
|
}
|
|
1019
1048
|
})]);
|
|
1020
|
-
}), hasQuerySuggestionsRenderer(
|
|
1049
|
+
}), hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
|
|
1021
1050
|
isOpen: isOpen,
|
|
1022
1051
|
getItemProps: getItemProps,
|
|
1023
1052
|
getItemEvents: getItemEvents,
|
|
1024
1053
|
highlightedIndex: highlightedIndex
|
|
1025
|
-
}, true) :
|
|
1054
|
+
}, true) : _this7.topSuggestions.map(function (sugg, index) {
|
|
1026
1055
|
return h("li", {
|
|
1027
1056
|
"domProps": _extends({}, getItemProps({
|
|
1028
1057
|
item: sugg
|
|
@@ -1030,9 +1059,9 @@ var DataSearch = {
|
|
|
1030
1059
|
"on": _extends({}, getItemEvents({
|
|
1031
1060
|
item: sugg
|
|
1032
1061
|
})),
|
|
1033
|
-
"key":
|
|
1062
|
+
"key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
|
|
1034
1063
|
"style": {
|
|
1035
|
-
backgroundColor:
|
|
1064
|
+
backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
|
|
1036
1065
|
justifyContent: 'flex-start'
|
|
1037
1066
|
}
|
|
1038
1067
|
}, [h("div", {
|
|
@@ -1041,58 +1070,58 @@ var DataSearch = {
|
|
|
1041
1070
|
}
|
|
1042
1071
|
}, [h(CustomSvg, {
|
|
1043
1072
|
"attrs": {
|
|
1044
|
-
"className": getClassName(
|
|
1073
|
+
"className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
|
|
1045
1074
|
"icon": popularSearchesIcon,
|
|
1046
1075
|
"type": "popular-search-icon"
|
|
1047
1076
|
}
|
|
1048
1077
|
})]), h(SuggestionItem, {
|
|
1049
1078
|
"attrs": {
|
|
1050
|
-
"currentValue":
|
|
1079
|
+
"currentValue": _this7.currentValue,
|
|
1051
1080
|
"suggestion": sugg
|
|
1052
1081
|
}
|
|
1053
1082
|
})]);
|
|
1054
|
-
})]) :
|
|
1083
|
+
})]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
|
|
1055
1084
|
};
|
|
1056
1085
|
return h("div", {
|
|
1057
1086
|
"class": suggestionsContainer
|
|
1058
|
-
}, [h(InputGroup, [
|
|
1087
|
+
}, [h(InputGroup, [_this7.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
|
|
1059
1088
|
"attrs": {
|
|
1060
|
-
"id":
|
|
1061
|
-
"showIcon":
|
|
1062
|
-
"showClear":
|
|
1063
|
-
"iconPosition":
|
|
1064
|
-
"placeholder":
|
|
1065
|
-
"autoFocus":
|
|
1066
|
-
"themePreset":
|
|
1089
|
+
"id": _this7.$props.componentId + "-input",
|
|
1090
|
+
"showIcon": _this7.$props.showIcon,
|
|
1091
|
+
"showClear": _this7.$props.showClear,
|
|
1092
|
+
"iconPosition": _this7.$props.iconPosition,
|
|
1093
|
+
"placeholder": _this7.$props.placeholder,
|
|
1094
|
+
"autoFocus": _this7.$props.autoFocus,
|
|
1095
|
+
"themePreset": _this7.themePreset,
|
|
1067
1096
|
"autocomplete": "off"
|
|
1068
1097
|
},
|
|
1069
|
-
"ref":
|
|
1070
|
-
"class": getClassName(
|
|
1098
|
+
"ref": _this7.$props.innerRef,
|
|
1099
|
+
"class": getClassName(_this7.$props.innerClass, 'input'),
|
|
1071
1100
|
"on": _extends({}, getInputEvents({
|
|
1072
|
-
onInput:
|
|
1101
|
+
onInput: _this7.onInputChange,
|
|
1073
1102
|
onBlur: function onBlur(e) {
|
|
1074
|
-
|
|
1103
|
+
_this7.$emit('blur', e, _this7.triggerQuery);
|
|
1075
1104
|
},
|
|
1076
|
-
onFocus:
|
|
1105
|
+
onFocus: _this7.handleFocus,
|
|
1077
1106
|
onKeyPress: function onKeyPress(e) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1107
|
+
_this7.$emit('keyPress', e, _this7.triggerQuery);
|
|
1108
|
+
_this7.$emit('key-press', e, _this7.triggerQuery);
|
|
1080
1109
|
},
|
|
1081
1110
|
onKeyDown: function onKeyDown(e) {
|
|
1082
|
-
return
|
|
1111
|
+
return _this7.handleKeyDown(e, highlightedIndex);
|
|
1083
1112
|
},
|
|
1084
1113
|
onKeyUp: function onKeyUp(e) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1114
|
+
_this7.$emit('keyUp', e, _this7.triggerQuery);
|
|
1115
|
+
_this7.$emit('key-up', e, _this7.triggerQuery);
|
|
1087
1116
|
},
|
|
1088
1117
|
onClick: function onClick() {
|
|
1089
1118
|
setHighlightedIndex(null);
|
|
1090
1119
|
}
|
|
1091
1120
|
})),
|
|
1092
1121
|
"domProps": _extends({}, getInputProps({
|
|
1093
|
-
value:
|
|
1122
|
+
value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
|
|
1094
1123
|
}))
|
|
1095
|
-
}),
|
|
1124
|
+
}), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
|
|
1096
1125
|
}
|
|
1097
1126
|
}
|
|
1098
1127
|
}) : h("div", {
|
|
@@ -1108,22 +1137,22 @@ var DataSearch = {
|
|
|
1108
1137
|
},
|
|
1109
1138
|
"on": _extends({}, {
|
|
1110
1139
|
blur: function blur(e) {
|
|
1111
|
-
|
|
1140
|
+
_this7.$emit('blur', e, _this7.triggerQuery);
|
|
1112
1141
|
},
|
|
1113
1142
|
keypress: function keypress(e) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1143
|
+
_this7.$emit('keyPress', e, _this7.triggerQuery);
|
|
1144
|
+
_this7.$emit('key-press', e, _this7.triggerQuery);
|
|
1116
1145
|
},
|
|
1117
1146
|
input: this.onInputChange,
|
|
1118
1147
|
focus: function focus(e) {
|
|
1119
|
-
|
|
1148
|
+
_this7.$emit('focus', e, _this7.triggerQuery);
|
|
1120
1149
|
},
|
|
1121
1150
|
keydown: function keydown(e) {
|
|
1122
|
-
|
|
1151
|
+
_this7.handleKeyDown(e, null);
|
|
1123
1152
|
},
|
|
1124
1153
|
keyup: function keyup(e) {
|
|
1125
|
-
|
|
1126
|
-
|
|
1154
|
+
_this7.$emit('keyUp', e, _this7.triggerQuery);
|
|
1155
|
+
_this7.$emit('key-up', e, _this7.triggerQuery);
|
|
1127
1156
|
}
|
|
1128
1157
|
}),
|
|
1129
1158
|
"domProps": _extends({}, {
|