@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.
@@ -60,8 +60,7 @@ var DataSearch = {
60
60
  selectedTags: [],
61
61
  isOpen: false,
62
62
  normalizedSuggestions: [],
63
- isPending: false,
64
- isSuggestionSelected: false
63
+ isPending: false
65
64
  };
66
65
  this.internalComponent = props.componentId + "__internal";
67
66
  return this.__state;
@@ -301,12 +300,23 @@ var DataSearch = {
301
300
  this.updateQueryHandler(this.componentId, this.$data.currentValue, this.$props);
302
301
  }
303
302
  },
303
+ isLoading: function isLoading(newVal) {
304
+ if (newVal) {
305
+ this.suggestions = [];
306
+ }
307
+ },
304
308
  suggestions: function suggestions(newVal) {
309
+ if (this.isLoading) {
310
+ this.normalizedSuggestions = [];
311
+ return;
312
+ }
305
313
  if (Array.isArray(newVal) && this.$data.currentValue.trim().length) {
306
314
  // shallow check allows us to set suggestions even if the next set
307
315
  // of suggestions are same as the current one
308
316
  this.$emit('suggestions', newVal);
309
- this.normalizedSuggestions = this.onSuggestions(newVal);
317
+ if (!isEqual(this.normalizedSuggestions, newVal)) {
318
+ this.normalizedSuggestions = this.onSuggestions(newVal);
319
+ }
310
320
  }
311
321
  },
312
322
  selectedValue: function selectedValue(newVal, oldVal) {
@@ -440,13 +450,10 @@ var DataSearch = {
440
450
  return;
441
451
  }
442
452
  // Refresh recent searches when value becomes empty
443
- if (!value && props.enableDefaultSuggestions === false) {
444
- _this.resetStoreForComponent(props.componentId);
445
- } else if (!value && _this.currentValue && _this.enableRecentSearches) {
453
+ if (props.enableDefaultSuggestions && !value && _this.currentValue && _this.enableRecentSearches) {
446
454
  _this.getRecentSearches();
447
455
  }
448
456
  if (isTagsMode) {
449
- var isTagAdded = false;
450
457
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
451
458
  // check if value already present in selectedTags
452
459
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -455,36 +462,14 @@ var DataSearch = {
455
462
  }
456
463
  _this.selectedTags = [].concat(_this.selectedTags);
457
464
  if (typeof value === 'string' && !!value) {
458
- if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
459
- _this.selectedTags.push(value);
460
- isTagAdded = true;
461
- } else if (!props.strictSelection) {
462
- _this.selectedTags.push(value);
463
- isTagAdded = true;
464
- }
465
+ _this.selectedTags.push(value);
465
466
  } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
466
- if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
467
- _this.selectedTags = value;
468
- isTagAdded = true;
469
- } else if (!props.strictSelection) {
470
- _this.selectedTags.push(value);
471
- isTagAdded = true;
472
- }
467
+ _this.selectedTags = value;
473
468
  }
474
469
  } else if (value) {
475
- if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
476
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
477
- isTagAdded = true;
478
- } else if (!props.strictSelection) {
479
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
480
- isTagAdded = true;
481
- }
482
- }
483
- if (props.strictSelection && !isTagAdded) {
484
- _this.currentValue = value;
485
- } else {
486
- _this.currentValue = '';
470
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
487
471
  }
472
+ _this.currentValue = '';
488
473
  } else {
489
474
  _this.currentValue = value;
490
475
  }
@@ -504,7 +489,7 @@ var DataSearch = {
504
489
  if (props.strictSelection && props.autosuggest) {
505
490
  if (cause === configureStore.causes.SUGGESTION_SELECT || props.value !== undefined) {
506
491
  _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
507
- } else if (_this.currentValue !== '' && !props.strictSelection) {
492
+ } else if (_this.currentValue !== '') {
508
493
  _this.setValue('', true);
509
494
  }
510
495
  } else {
@@ -523,7 +508,7 @@ var DataSearch = {
523
508
  _this.$emit('suggestions', _this.suggestions);
524
509
  } else if (!value) {
525
510
  // reset suggestions
526
- _this.suggestions = [];
511
+ // this.suggestions = [];
527
512
  // invoke on suggestions
528
513
  _this.$emit('suggestions', _this.suggestions);
529
514
  }
@@ -534,11 +519,6 @@ var DataSearch = {
534
519
  if (props === void 0) {
535
520
  props = this.$props;
536
521
  }
537
- if (!value && props.enableDefaultSuggestions === false) {
538
- // clear Component data from store
539
- this.resetStoreForComponent(props.componentId);
540
- return;
541
- }
542
522
  var defaultQueryOptions;
543
523
  var query = DataSearch.defaultQuery(value, props);
544
524
  if (this.defaultQuery) {
@@ -633,17 +613,17 @@ var DataSearch = {
633
613
  var targetValue = event.target.value;
634
614
  var _this$$props2 = this.$props,
635
615
  value = _this$$props2.value,
636
- size = _this$$props2.size;
616
+ strictSelection = _this$$props2.strictSelection,
617
+ size = _this$$props2.size,
618
+ autosuggest = _this$$props2.autosuggest;
637
619
  if (value !== undefined) {
638
620
  this.isPending = true;
639
621
  }
640
622
  // if a suggestion was selected, delegate the handling to suggestion handler
641
623
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
642
624
  this.isPending = false;
643
- if (!this.isSuggestionSelected) {
644
- this.setValue(targetValue, true, this.$props, undefined, false);
645
- this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
646
- }
625
+ this.setValue(this.$options.isTagsMode && autosuggest && strictSelection ? '' : targetValue, true, this.$props, undefined, false);
626
+ this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
647
627
  }
648
628
  // Need to review
649
629
  this.$emit('keyDown', event, this.triggerQuery);
@@ -679,16 +659,11 @@ var DataSearch = {
679
659
  }
680
660
  },
681
661
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
682
- var _this3 = this;
683
662
  var value = this.$props.value;
684
663
  // Record analytics for selected suggestions
685
664
  this.triggerClickAnalytics(suggestion._click_id);
686
665
  if (value === undefined) {
687
666
  this.setValue(suggestion.value, true, this.$props, configureStore.causes.SUGGESTION_SELECT);
688
- this.isSuggestionSelected = true;
689
- setTimeout(function () {
690
- _this3.isSuggestionSelected = false;
691
- }, 50);
692
667
  } else if (this.$options.isTagsMode) {
693
668
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
694
669
  if (this.selectedTags.includes(suggestion.value)) {
@@ -794,7 +769,7 @@ var DataSearch = {
794
769
  return null;
795
770
  },
796
771
  renderTag: function renderTag(item) {
797
- var _this4 = this;
772
+ var _this3 = this;
798
773
  var h = this.$createElement;
799
774
  var innerClass = this.$props.innerClass;
800
775
  return h(Tags.TagItem, {
@@ -807,7 +782,7 @@ var DataSearch = {
807
782
  "class": "close-icon",
808
783
  "on": {
809
784
  "click": function click() {
810
- return _this4.clearTag(item);
785
+ return _this3.clearTag(item);
811
786
  }
812
787
  }
813
788
  }, [h(CancelSvg.CancelSvg)])]);
@@ -829,7 +804,7 @@ var DataSearch = {
829
804
  }
830
805
  },
831
806
  renderTags: function renderTags() {
832
- var _this5 = this;
807
+ var _this4 = this;
833
808
  var h = this.$createElement;
834
809
  if (!Array.isArray(this.selectedTags)) {
835
810
  return null;
@@ -842,7 +817,7 @@ var DataSearch = {
842
817
  handleClear: this.clearTag,
843
818
  handleClearAll: this.clearAllTags
844
819
  }) : h(Tags.TagsContainer, [tagsList.map(function (item) {
845
- return _this5.renderTag(item);
820
+ return _this4.renderTag(item);
846
821
  }), shouldRenderClearAllTag && h(Tags.TagItem, {
847
822
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
848
823
  }, [h("span", ["Clear All"]), h("span", {
@@ -921,7 +896,7 @@ var DataSearch = {
921
896
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
922
897
  },
923
898
  listenForFocusShortcuts: function listenForFocusShortcuts() {
924
- var _this6 = this;
899
+ var _this5 = this;
925
900
  var _this$$props$focusSho = this.$props.focusShortcuts,
926
901
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
927
902
  if (index.isEmpty(focusShortcuts)) {
@@ -936,7 +911,7 @@ var DataSearch = {
936
911
  function (event, handler) {
937
912
  // Prevent the default refresh event under WINDOWS system
938
913
  event.preventDefault();
939
- _this6.focusSearchBox(event);
914
+ _this5.focusSearchBox(event);
940
915
  });
941
916
 
942
917
  // if one of modifier keys are used, they are handled below
@@ -946,7 +921,7 @@ var DataSearch = {
946
921
  for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
947
922
  var element = modifierKeys[index$1];
948
923
  if (hotkeys[element]) {
949
- _this6.focusSearchBox(event);
924
+ _this5.focusSearchBox(event);
950
925
  break;
951
926
  }
952
927
  }
@@ -954,7 +929,7 @@ var DataSearch = {
954
929
  }
955
930
  },
956
931
  render: function render() {
957
- var _this7 = this;
932
+ var _this6 = this;
958
933
  var h = arguments[0];
959
934
  var _this$$props6 = this.$props,
960
935
  theme = _this$$props6.theme,
@@ -989,14 +964,14 @@ var DataSearch = {
989
964
  highlightedIndex = _ref4.highlightedIndex,
990
965
  setHighlightedIndex = _ref4.setHighlightedIndex;
991
966
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
992
- return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
967
+ return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
993
968
  isOpen: isOpen,
994
969
  getItemProps: getItemProps,
995
970
  getItemEvents: getItemEvents,
996
971
  highlightedIndex: highlightedIndex
997
- }), _this7.renderErrorComponent(), !_this7.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
998
- "class": Input.suggestions(_this7.themePreset, theme) + " " + getClassName(_this7.$props.innerClass, 'list')
999
- }, [_this7.suggestionsList.slice(0, size || 10).map(function (item, index) {
972
+ }), _this6.renderErrorComponent(), !_this6.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
973
+ "class": Input.suggestions(_this6.themePreset, theme) + " " + getClassName(_this6.$props.innerClass, 'list')
974
+ }, [_this6.suggestionsList.slice(0, size || 10).map(function (item, index) {
1000
975
  return h("li", {
1001
976
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1002
977
  item: item
@@ -1006,15 +981,15 @@ var DataSearch = {
1006
981
  })),
1007
982
  "key": index + 1 + "-" + item.value,
1008
983
  "style": {
1009
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
984
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1010
985
  }
1011
986
  }, [h(Tags.SuggestionItem, {
1012
987
  "attrs": {
1013
- "currentValue": _this7.currentValue,
988
+ "currentValue": _this6.currentValue,
1014
989
  "suggestion": item
1015
990
  }
1016
991
  })]);
1017
- }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
992
+ }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1018
993
  return h("li", {
1019
994
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1020
995
  item: sugg
@@ -1022,9 +997,9 @@ var DataSearch = {
1022
997
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1023
998
  item: sugg
1024
999
  })),
1025
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1000
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1026
1001
  "style": {
1027
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1002
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1028
1003
  justifyContent: 'flex-start'
1029
1004
  }
1030
1005
  }, [h("div", {
@@ -1033,28 +1008,28 @@ var DataSearch = {
1033
1008
  }
1034
1009
  }, [sugg.source && sugg.source._recent_search && h(Tags.CustomSvg, {
1035
1010
  "attrs": {
1036
- "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1011
+ "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1037
1012
  "icon": recentSearchesIcon,
1038
1013
  "type": "recent-search-icon"
1039
1014
  }
1040
1015
  }), sugg.source && sugg.source._popular_suggestion && h(Tags.CustomSvg, {
1041
1016
  "attrs": {
1042
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1017
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1043
1018
  "icon": popularSearchesIcon,
1044
1019
  "type": "popular-search-icon"
1045
1020
  }
1046
1021
  })]), h(Tags.SuggestionItem, {
1047
1022
  "attrs": {
1048
- "currentValue": _this7.currentValue,
1023
+ "currentValue": _this6.currentValue,
1049
1024
  "suggestion": sugg
1050
1025
  }
1051
1026
  })]);
1052
- }), index.hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1027
+ }), index.hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1053
1028
  isOpen: isOpen,
1054
1029
  getItemProps: getItemProps,
1055
1030
  getItemEvents: getItemEvents,
1056
1031
  highlightedIndex: highlightedIndex
1057
- }, true) : _this7.topSuggestions.map(function (sugg, index) {
1032
+ }, true) : _this6.topSuggestions.map(function (sugg, index) {
1058
1033
  return h("li", {
1059
1034
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1060
1035
  item: sugg
@@ -1062,9 +1037,9 @@ var DataSearch = {
1062
1037
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1063
1038
  item: sugg
1064
1039
  })),
1065
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1040
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1066
1041
  "style": {
1067
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1042
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1068
1043
  justifyContent: 'flex-start'
1069
1044
  }
1070
1045
  }, [h("div", {
@@ -1073,58 +1048,58 @@ var DataSearch = {
1073
1048
  }
1074
1049
  }, [h(Tags.CustomSvg, {
1075
1050
  "attrs": {
1076
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1051
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1077
1052
  "icon": popularSearchesIcon,
1078
1053
  "type": "popular-search-icon"
1079
1054
  }
1080
1055
  })]), h(Tags.SuggestionItem, {
1081
1056
  "attrs": {
1082
- "currentValue": _this7.currentValue,
1057
+ "currentValue": _this6.currentValue,
1083
1058
  "suggestion": sugg
1084
1059
  }
1085
1060
  })]);
1086
- })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1061
+ })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1087
1062
  };
1088
1063
  return h("div", {
1089
1064
  "class": Input.suggestionsContainer
1090
- }, [h(Tags.InputGroup, [_this7.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1065
+ }, [h(Tags.InputGroup, [_this6.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1091
1066
  "attrs": {
1092
- "id": _this7.$props.componentId + "-input",
1093
- "showIcon": _this7.$props.showIcon,
1094
- "showClear": _this7.$props.showClear,
1095
- "iconPosition": _this7.$props.iconPosition,
1096
- "placeholder": _this7.$props.placeholder,
1097
- "autoFocus": _this7.$props.autoFocus,
1098
- "themePreset": _this7.themePreset,
1067
+ "id": _this6.$props.componentId + "-input",
1068
+ "showIcon": _this6.$props.showIcon,
1069
+ "showClear": _this6.$props.showClear,
1070
+ "iconPosition": _this6.$props.iconPosition,
1071
+ "placeholder": _this6.$props.placeholder,
1072
+ "autoFocus": _this6.$props.autoFocus,
1073
+ "themePreset": _this6.themePreset,
1099
1074
  "autocomplete": "off"
1100
1075
  },
1101
- "ref": _this7.$props.innerRef,
1102
- "class": getClassName(_this7.$props.innerClass, 'input'),
1076
+ "ref": _this6.$props.innerRef,
1077
+ "class": getClassName(_this6.$props.innerClass, 'input'),
1103
1078
  "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
1104
- onInput: _this7.onInputChange,
1079
+ onInput: _this6.onInputChange,
1105
1080
  onBlur: function onBlur(e) {
1106
- _this7.$emit('blur', e, _this7.triggerQuery);
1081
+ _this6.$emit('blur', e, _this6.triggerQuery);
1107
1082
  },
1108
- onFocus: _this7.handleFocus,
1083
+ onFocus: _this6.handleFocus,
1109
1084
  onKeyPress: function onKeyPress(e) {
1110
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1111
- _this7.$emit('key-press', e, _this7.triggerQuery);
1085
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1086
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1112
1087
  },
1113
1088
  onKeyDown: function onKeyDown(e) {
1114
- return _this7.handleKeyDown(e, highlightedIndex);
1089
+ return _this6.handleKeyDown(e, highlightedIndex);
1115
1090
  },
1116
1091
  onKeyUp: function onKeyUp(e) {
1117
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1118
- _this7.$emit('key-up', e, _this7.triggerQuery);
1092
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1093
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1119
1094
  },
1120
1095
  onClick: function onClick() {
1121
1096
  setHighlightedIndex(null);
1122
1097
  }
1123
1098
  })),
1124
1099
  "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
1125
- value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
1100
+ value: _this6.$data.currentValue === null || typeof _this6.$data.currentValue !== 'string' ? '' : _this6.$data.currentValue
1126
1101
  }))
1127
- }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1102
+ }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1128
1103
  }
1129
1104
  }
1130
1105
  }) : h("div", {
@@ -1140,22 +1115,22 @@ var DataSearch = {
1140
1115
  },
1141
1116
  "on": _rollupPluginBabelHelpers._extends({}, {
1142
1117
  blur: function blur(e) {
1143
- _this7.$emit('blur', e, _this7.triggerQuery);
1118
+ _this6.$emit('blur', e, _this6.triggerQuery);
1144
1119
  },
1145
1120
  keypress: function keypress(e) {
1146
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1147
- _this7.$emit('key-press', e, _this7.triggerQuery);
1121
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1122
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1148
1123
  },
1149
1124
  input: this.onInputChange,
1150
1125
  focus: function focus(e) {
1151
- _this7.$emit('focus', e, _this7.triggerQuery);
1126
+ _this6.$emit('focus', e, _this6.triggerQuery);
1152
1127
  },
1153
1128
  keydown: function keydown(e) {
1154
- _this7.handleKeyDown(e, null);
1129
+ _this6.handleKeyDown(e, null);
1155
1130
  },
1156
1131
  keyup: function keyup(e) {
1157
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1158
- _this7.$emit('key-up', e, _this7.triggerQuery);
1132
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1133
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1159
1134
  }
1160
1135
  }),
1161
1136
  "domProps": _rollupPluginBabelHelpers._extends({}, {