@appbaseio/reactivesearch-vue 1.35.3 → 1.35.4

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.
@@ -53,8 +53,7 @@ var DataSearch = {
53
53
  selectedTags: [],
54
54
  isOpen: false,
55
55
  normalizedSuggestions: [],
56
- isPending: false,
57
- isSuggestionSelected: false
56
+ isPending: false
58
57
  };
59
58
  this.internalComponent = props.componentId + "__internal";
60
59
  return this.__state;
@@ -294,12 +293,23 @@ var DataSearch = {
294
293
  this.updateQueryHandler(this.componentId, this.$data.currentValue, this.$props);
295
294
  }
296
295
  },
296
+ isLoading: function isLoading(newVal) {
297
+ if (newVal) {
298
+ this.suggestions = [];
299
+ }
300
+ },
297
301
  suggestions: function suggestions(newVal) {
302
+ if (this.isLoading) {
303
+ this.normalizedSuggestions = [];
304
+ return;
305
+ }
298
306
  if (Array.isArray(newVal) && this.$data.currentValue.trim().length) {
299
307
  // shallow check allows us to set suggestions even if the next set
300
308
  // of suggestions are same as the current one
301
309
  this.$emit('suggestions', newVal);
302
- this.normalizedSuggestions = this.onSuggestions(newVal);
310
+ if (!isEqual(this.normalizedSuggestions, newVal)) {
311
+ this.normalizedSuggestions = this.onSuggestions(newVal);
312
+ }
303
313
  }
304
314
  },
305
315
  selectedValue: function selectedValue(newVal, oldVal) {
@@ -433,13 +443,10 @@ var DataSearch = {
433
443
  return;
434
444
  }
435
445
  // Refresh recent searches when value becomes empty
436
- if (!value && props.enableDefaultSuggestions === false) {
437
- _this.resetStoreForComponent(props.componentId);
438
- } else if (!value && _this.currentValue && _this.enableRecentSearches) {
446
+ if (props.enableDefaultSuggestions && !value && _this.currentValue && _this.enableRecentSearches) {
439
447
  _this.getRecentSearches();
440
448
  }
441
449
  if (isTagsMode) {
442
- var isTagAdded = false;
443
450
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
444
451
  // check if value already present in selectedTags
445
452
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -448,36 +455,14 @@ var DataSearch = {
448
455
  }
449
456
  _this.selectedTags = [].concat(_this.selectedTags);
450
457
  if (typeof value === 'string' && !!value) {
451
- if (props.strictSelection && cause === causes.SUGGESTION_SELECT) {
452
- _this.selectedTags.push(value);
453
- isTagAdded = true;
454
- } else if (!props.strictSelection) {
455
- _this.selectedTags.push(value);
456
- isTagAdded = true;
457
- }
458
+ _this.selectedTags.push(value);
458
459
  } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
459
- if (props.strictSelection && cause === causes.SUGGESTION_SELECT) {
460
- _this.selectedTags = value;
461
- isTagAdded = true;
462
- } else if (!props.strictSelection) {
463
- _this.selectedTags.push(value);
464
- isTagAdded = true;
465
- }
460
+ _this.selectedTags = value;
466
461
  }
467
462
  } else if (value) {
468
- if (props.strictSelection && cause === causes.SUGGESTION_SELECT) {
469
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
470
- isTagAdded = true;
471
- } else if (!props.strictSelection) {
472
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
473
- isTagAdded = true;
474
- }
475
- }
476
- if (props.strictSelection && !isTagAdded) {
477
- _this.currentValue = value;
478
- } else {
479
- _this.currentValue = '';
463
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
480
464
  }
465
+ _this.currentValue = '';
481
466
  } else {
482
467
  _this.currentValue = value;
483
468
  }
@@ -497,7 +482,7 @@ var DataSearch = {
497
482
  if (props.strictSelection && props.autosuggest) {
498
483
  if (cause === causes.SUGGESTION_SELECT || props.value !== undefined) {
499
484
  _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
500
- } else if (_this.currentValue !== '' && !props.strictSelection) {
485
+ } else if (_this.currentValue !== '') {
501
486
  _this.setValue('', true);
502
487
  }
503
488
  } else {
@@ -516,7 +501,7 @@ var DataSearch = {
516
501
  _this.$emit('suggestions', _this.suggestions);
517
502
  } else if (!value) {
518
503
  // reset suggestions
519
- _this.suggestions = [];
504
+ // this.suggestions = [];
520
505
  // invoke on suggestions
521
506
  _this.$emit('suggestions', _this.suggestions);
522
507
  }
@@ -527,11 +512,6 @@ var DataSearch = {
527
512
  if (props === void 0) {
528
513
  props = this.$props;
529
514
  }
530
- if (!value && props.enableDefaultSuggestions === false) {
531
- // clear Component data from store
532
- this.resetStoreForComponent(props.componentId);
533
- return;
534
- }
535
515
  var defaultQueryOptions;
536
516
  var query = DataSearch.defaultQuery(value, props);
537
517
  if (this.defaultQuery) {
@@ -626,17 +606,17 @@ var DataSearch = {
626
606
  var targetValue = event.target.value;
627
607
  var _this$$props2 = this.$props,
628
608
  value = _this$$props2.value,
629
- size = _this$$props2.size;
609
+ strictSelection = _this$$props2.strictSelection,
610
+ size = _this$$props2.size,
611
+ autosuggest = _this$$props2.autosuggest;
630
612
  if (value !== undefined) {
631
613
  this.isPending = true;
632
614
  }
633
615
  // if a suggestion was selected, delegate the handling to suggestion handler
634
616
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
635
617
  this.isPending = false;
636
- if (!this.isSuggestionSelected) {
637
- this.setValue(targetValue, true, this.$props, undefined, false);
638
- this.onValueSelectedHandler(targetValue, causes.ENTER_PRESS);
639
- }
618
+ this.setValue(this.$options.isTagsMode && autosuggest && strictSelection ? '' : targetValue, true, this.$props, undefined, false);
619
+ this.onValueSelectedHandler(targetValue, causes.ENTER_PRESS);
640
620
  }
641
621
  // Need to review
642
622
  this.$emit('keyDown', event, this.triggerQuery);
@@ -672,16 +652,11 @@ var DataSearch = {
672
652
  }
673
653
  },
674
654
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
675
- var _this3 = this;
676
655
  var value = this.$props.value;
677
656
  // Record analytics for selected suggestions
678
657
  this.triggerClickAnalytics(suggestion._click_id);
679
658
  if (value === undefined) {
680
659
  this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT);
681
- this.isSuggestionSelected = true;
682
- setTimeout(function () {
683
- _this3.isSuggestionSelected = false;
684
- }, 50);
685
660
  } else if (this.$options.isTagsMode) {
686
661
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
687
662
  if (this.selectedTags.includes(suggestion.value)) {
@@ -787,7 +762,7 @@ var DataSearch = {
787
762
  return null;
788
763
  },
789
764
  renderTag: function renderTag(item) {
790
- var _this4 = this;
765
+ var _this3 = this;
791
766
  var h = this.$createElement;
792
767
  var innerClass = this.$props.innerClass;
793
768
  return h(TagItem, {
@@ -800,7 +775,7 @@ var DataSearch = {
800
775
  "class": "close-icon",
801
776
  "on": {
802
777
  "click": function click() {
803
- return _this4.clearTag(item);
778
+ return _this3.clearTag(item);
804
779
  }
805
780
  }
806
781
  }, [h(CancelSvg)])]);
@@ -822,7 +797,7 @@ var DataSearch = {
822
797
  }
823
798
  },
824
799
  renderTags: function renderTags() {
825
- var _this5 = this;
800
+ var _this4 = this;
826
801
  var h = this.$createElement;
827
802
  if (!Array.isArray(this.selectedTags)) {
828
803
  return null;
@@ -835,7 +810,7 @@ var DataSearch = {
835
810
  handleClear: this.clearTag,
836
811
  handleClearAll: this.clearAllTags
837
812
  }) : h(TagsContainer, [tagsList.map(function (item) {
838
- return _this5.renderTag(item);
813
+ return _this4.renderTag(item);
839
814
  }), shouldRenderClearAllTag && h(TagItem, {
840
815
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
841
816
  }, [h("span", ["Clear All"]), h("span", {
@@ -914,7 +889,7 @@ var DataSearch = {
914
889
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
915
890
  },
916
891
  listenForFocusShortcuts: function listenForFocusShortcuts() {
917
- var _this6 = this;
892
+ var _this5 = this;
918
893
  var _this$$props$focusSho = this.$props.focusShortcuts,
919
894
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
920
895
  if (isEmpty(focusShortcuts)) {
@@ -929,7 +904,7 @@ var DataSearch = {
929
904
  function (event, handler) {
930
905
  // Prevent the default refresh event under WINDOWS system
931
906
  event.preventDefault();
932
- _this6.focusSearchBox(event);
907
+ _this5.focusSearchBox(event);
933
908
  });
934
909
 
935
910
  // if one of modifier keys are used, they are handled below
@@ -939,7 +914,7 @@ var DataSearch = {
939
914
  for (var index = 0; index < modifierKeys.length; index += 1) {
940
915
  var element = modifierKeys[index];
941
916
  if (hotkeys[element]) {
942
- _this6.focusSearchBox(event);
917
+ _this5.focusSearchBox(event);
943
918
  break;
944
919
  }
945
920
  }
@@ -947,7 +922,7 @@ var DataSearch = {
947
922
  }
948
923
  },
949
924
  render: function render() {
950
- var _this7 = this;
925
+ var _this6 = this;
951
926
  var h = arguments[0];
952
927
  var _this$$props6 = this.$props,
953
928
  theme = _this$$props6.theme,
@@ -982,14 +957,14 @@ var DataSearch = {
982
957
  highlightedIndex = _ref4.highlightedIndex,
983
958
  setHighlightedIndex = _ref4.setHighlightedIndex;
984
959
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
985
- return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
960
+ return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
986
961
  isOpen: isOpen,
987
962
  getItemProps: getItemProps,
988
963
  getItemEvents: getItemEvents,
989
964
  highlightedIndex: highlightedIndex
990
- }), _this7.renderErrorComponent(), !_this7.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
991
- "class": suggestions(_this7.themePreset, theme) + " " + getClassName(_this7.$props.innerClass, 'list')
992
- }, [_this7.suggestionsList.slice(0, size || 10).map(function (item, index) {
965
+ }), _this6.renderErrorComponent(), !_this6.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
966
+ "class": suggestions(_this6.themePreset, theme) + " " + getClassName(_this6.$props.innerClass, 'list')
967
+ }, [_this6.suggestionsList.slice(0, size || 10).map(function (item, index) {
993
968
  return h("li", {
994
969
  "domProps": _extends({}, getItemProps({
995
970
  item: item
@@ -999,15 +974,15 @@ var DataSearch = {
999
974
  })),
1000
975
  "key": index + 1 + "-" + item.value,
1001
976
  "style": {
1002
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
977
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1003
978
  }
1004
979
  }, [h(SuggestionItem, {
1005
980
  "attrs": {
1006
- "currentValue": _this7.currentValue,
981
+ "currentValue": _this6.currentValue,
1007
982
  "suggestion": item
1008
983
  }
1009
984
  })]);
1010
- }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
985
+ }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1011
986
  return h("li", {
1012
987
  "domProps": _extends({}, getItemProps({
1013
988
  item: sugg
@@ -1015,9 +990,9 @@ var DataSearch = {
1015
990
  "on": _extends({}, getItemEvents({
1016
991
  item: sugg
1017
992
  })),
1018
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
993
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1019
994
  "style": {
1020
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
995
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1021
996
  justifyContent: 'flex-start'
1022
997
  }
1023
998
  }, [h("div", {
@@ -1026,28 +1001,28 @@ var DataSearch = {
1026
1001
  }
1027
1002
  }, [sugg.source && sugg.source._recent_search && h(CustomSvg, {
1028
1003
  "attrs": {
1029
- "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1004
+ "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1030
1005
  "icon": recentSearchesIcon,
1031
1006
  "type": "recent-search-icon"
1032
1007
  }
1033
1008
  }), sugg.source && sugg.source._popular_suggestion && h(CustomSvg, {
1034
1009
  "attrs": {
1035
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1010
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1036
1011
  "icon": popularSearchesIcon,
1037
1012
  "type": "popular-search-icon"
1038
1013
  }
1039
1014
  })]), h(SuggestionItem, {
1040
1015
  "attrs": {
1041
- "currentValue": _this7.currentValue,
1016
+ "currentValue": _this6.currentValue,
1042
1017
  "suggestion": sugg
1043
1018
  }
1044
1019
  })]);
1045
- }), hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1020
+ }), hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1046
1021
  isOpen: isOpen,
1047
1022
  getItemProps: getItemProps,
1048
1023
  getItemEvents: getItemEvents,
1049
1024
  highlightedIndex: highlightedIndex
1050
- }, true) : _this7.topSuggestions.map(function (sugg, index) {
1025
+ }, true) : _this6.topSuggestions.map(function (sugg, index) {
1051
1026
  return h("li", {
1052
1027
  "domProps": _extends({}, getItemProps({
1053
1028
  item: sugg
@@ -1055,9 +1030,9 @@ var DataSearch = {
1055
1030
  "on": _extends({}, getItemEvents({
1056
1031
  item: sugg
1057
1032
  })),
1058
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1033
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1059
1034
  "style": {
1060
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1035
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1061
1036
  justifyContent: 'flex-start'
1062
1037
  }
1063
1038
  }, [h("div", {
@@ -1066,58 +1041,58 @@ var DataSearch = {
1066
1041
  }
1067
1042
  }, [h(CustomSvg, {
1068
1043
  "attrs": {
1069
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1044
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1070
1045
  "icon": popularSearchesIcon,
1071
1046
  "type": "popular-search-icon"
1072
1047
  }
1073
1048
  })]), h(SuggestionItem, {
1074
1049
  "attrs": {
1075
- "currentValue": _this7.currentValue,
1050
+ "currentValue": _this6.currentValue,
1076
1051
  "suggestion": sugg
1077
1052
  }
1078
1053
  })]);
1079
- })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1054
+ })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1080
1055
  };
1081
1056
  return h("div", {
1082
1057
  "class": suggestionsContainer
1083
- }, [h(InputGroup, [_this7.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1058
+ }, [h(InputGroup, [_this6.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1084
1059
  "attrs": {
1085
- "id": _this7.$props.componentId + "-input",
1086
- "showIcon": _this7.$props.showIcon,
1087
- "showClear": _this7.$props.showClear,
1088
- "iconPosition": _this7.$props.iconPosition,
1089
- "placeholder": _this7.$props.placeholder,
1090
- "autoFocus": _this7.$props.autoFocus,
1091
- "themePreset": _this7.themePreset,
1060
+ "id": _this6.$props.componentId + "-input",
1061
+ "showIcon": _this6.$props.showIcon,
1062
+ "showClear": _this6.$props.showClear,
1063
+ "iconPosition": _this6.$props.iconPosition,
1064
+ "placeholder": _this6.$props.placeholder,
1065
+ "autoFocus": _this6.$props.autoFocus,
1066
+ "themePreset": _this6.themePreset,
1092
1067
  "autocomplete": "off"
1093
1068
  },
1094
- "ref": _this7.$props.innerRef,
1095
- "class": getClassName(_this7.$props.innerClass, 'input'),
1069
+ "ref": _this6.$props.innerRef,
1070
+ "class": getClassName(_this6.$props.innerClass, 'input'),
1096
1071
  "on": _extends({}, getInputEvents({
1097
- onInput: _this7.onInputChange,
1072
+ onInput: _this6.onInputChange,
1098
1073
  onBlur: function onBlur(e) {
1099
- _this7.$emit('blur', e, _this7.triggerQuery);
1074
+ _this6.$emit('blur', e, _this6.triggerQuery);
1100
1075
  },
1101
- onFocus: _this7.handleFocus,
1076
+ onFocus: _this6.handleFocus,
1102
1077
  onKeyPress: function onKeyPress(e) {
1103
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1104
- _this7.$emit('key-press', e, _this7.triggerQuery);
1078
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1079
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1105
1080
  },
1106
1081
  onKeyDown: function onKeyDown(e) {
1107
- return _this7.handleKeyDown(e, highlightedIndex);
1082
+ return _this6.handleKeyDown(e, highlightedIndex);
1108
1083
  },
1109
1084
  onKeyUp: function onKeyUp(e) {
1110
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1111
- _this7.$emit('key-up', e, _this7.triggerQuery);
1085
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1086
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1112
1087
  },
1113
1088
  onClick: function onClick() {
1114
1089
  setHighlightedIndex(null);
1115
1090
  }
1116
1091
  })),
1117
1092
  "domProps": _extends({}, getInputProps({
1118
- value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
1093
+ value: _this6.$data.currentValue === null || typeof _this6.$data.currentValue !== 'string' ? '' : _this6.$data.currentValue
1119
1094
  }))
1120
- }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1095
+ }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1121
1096
  }
1122
1097
  }
1123
1098
  }) : h("div", {
@@ -1133,22 +1108,22 @@ var DataSearch = {
1133
1108
  },
1134
1109
  "on": _extends({}, {
1135
1110
  blur: function blur(e) {
1136
- _this7.$emit('blur', e, _this7.triggerQuery);
1111
+ _this6.$emit('blur', e, _this6.triggerQuery);
1137
1112
  },
1138
1113
  keypress: function keypress(e) {
1139
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1140
- _this7.$emit('key-press', e, _this7.triggerQuery);
1114
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1115
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1141
1116
  },
1142
1117
  input: this.onInputChange,
1143
1118
  focus: function focus(e) {
1144
- _this7.$emit('focus', e, _this7.triggerQuery);
1119
+ _this6.$emit('focus', e, _this6.triggerQuery);
1145
1120
  },
1146
1121
  keydown: function keydown(e) {
1147
- _this7.handleKeyDown(e, null);
1122
+ _this6.handleKeyDown(e, null);
1148
1123
  },
1149
1124
  keyup: function keyup(e) {
1150
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1151
- _this7.$emit('key-up', e, _this7.triggerQuery);
1125
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1126
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1152
1127
  }
1153
1128
  }),
1154
1129
  "domProps": _extends({}, {