@appbaseio/reactivesearch-vue 1.35.3 → 1.35.5

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;
@@ -446,7 +445,6 @@ var DataSearch = {
446
445
  _this.getRecentSearches();
447
446
  }
448
447
  if (isTagsMode) {
449
- var isTagAdded = false;
450
448
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
451
449
  // check if value already present in selectedTags
452
450
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -455,36 +453,14 @@ var DataSearch = {
455
453
  }
456
454
  _this.selectedTags = [].concat(_this.selectedTags);
457
455
  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
- }
456
+ _this.selectedTags.push(value);
465
457
  } 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
- }
458
+ _this.selectedTags = value;
473
459
  }
474
460
  } 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 = '';
461
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
487
462
  }
463
+ _this.currentValue = '';
488
464
  } else {
489
465
  _this.currentValue = value;
490
466
  }
@@ -504,7 +480,7 @@ var DataSearch = {
504
480
  if (props.strictSelection && props.autosuggest) {
505
481
  if (cause === configureStore.causes.SUGGESTION_SELECT || props.value !== undefined) {
506
482
  _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
507
- } else if (_this.currentValue !== '' && !props.strictSelection) {
483
+ } else if (_this.currentValue !== '') {
508
484
  _this.setValue('', true);
509
485
  }
510
486
  } else {
@@ -633,17 +609,17 @@ var DataSearch = {
633
609
  var targetValue = event.target.value;
634
610
  var _this$$props2 = this.$props,
635
611
  value = _this$$props2.value,
636
- size = _this$$props2.size;
612
+ strictSelection = _this$$props2.strictSelection,
613
+ size = _this$$props2.size,
614
+ autosuggest = _this$$props2.autosuggest;
637
615
  if (value !== undefined) {
638
616
  this.isPending = true;
639
617
  }
640
618
  // if a suggestion was selected, delegate the handling to suggestion handler
641
619
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
642
620
  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
- }
621
+ this.setValue(this.$options.isTagsMode && autosuggest && strictSelection ? '' : targetValue, true, this.$props, undefined, false);
622
+ this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
647
623
  }
648
624
  // Need to review
649
625
  this.$emit('keyDown', event, this.triggerQuery);
@@ -679,16 +655,11 @@ var DataSearch = {
679
655
  }
680
656
  },
681
657
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
682
- var _this3 = this;
683
658
  var value = this.$props.value;
684
659
  // Record analytics for selected suggestions
685
660
  this.triggerClickAnalytics(suggestion._click_id);
686
661
  if (value === undefined) {
687
662
  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
663
  } else if (this.$options.isTagsMode) {
693
664
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
694
665
  if (this.selectedTags.includes(suggestion.value)) {
@@ -794,7 +765,7 @@ var DataSearch = {
794
765
  return null;
795
766
  },
796
767
  renderTag: function renderTag(item) {
797
- var _this4 = this;
768
+ var _this3 = this;
798
769
  var h = this.$createElement;
799
770
  var innerClass = this.$props.innerClass;
800
771
  return h(Tags.TagItem, {
@@ -807,7 +778,7 @@ var DataSearch = {
807
778
  "class": "close-icon",
808
779
  "on": {
809
780
  "click": function click() {
810
- return _this4.clearTag(item);
781
+ return _this3.clearTag(item);
811
782
  }
812
783
  }
813
784
  }, [h(CancelSvg.CancelSvg)])]);
@@ -829,7 +800,7 @@ var DataSearch = {
829
800
  }
830
801
  },
831
802
  renderTags: function renderTags() {
832
- var _this5 = this;
803
+ var _this4 = this;
833
804
  var h = this.$createElement;
834
805
  if (!Array.isArray(this.selectedTags)) {
835
806
  return null;
@@ -842,7 +813,7 @@ var DataSearch = {
842
813
  handleClear: this.clearTag,
843
814
  handleClearAll: this.clearAllTags
844
815
  }) : h(Tags.TagsContainer, [tagsList.map(function (item) {
845
- return _this5.renderTag(item);
816
+ return _this4.renderTag(item);
846
817
  }), shouldRenderClearAllTag && h(Tags.TagItem, {
847
818
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
848
819
  }, [h("span", ["Clear All"]), h("span", {
@@ -921,7 +892,7 @@ var DataSearch = {
921
892
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
922
893
  },
923
894
  listenForFocusShortcuts: function listenForFocusShortcuts() {
924
- var _this6 = this;
895
+ var _this5 = this;
925
896
  var _this$$props$focusSho = this.$props.focusShortcuts,
926
897
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
927
898
  if (index.isEmpty(focusShortcuts)) {
@@ -936,7 +907,7 @@ var DataSearch = {
936
907
  function (event, handler) {
937
908
  // Prevent the default refresh event under WINDOWS system
938
909
  event.preventDefault();
939
- _this6.focusSearchBox(event);
910
+ _this5.focusSearchBox(event);
940
911
  });
941
912
 
942
913
  // if one of modifier keys are used, they are handled below
@@ -946,7 +917,7 @@ var DataSearch = {
946
917
  for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
947
918
  var element = modifierKeys[index$1];
948
919
  if (hotkeys[element]) {
949
- _this6.focusSearchBox(event);
920
+ _this5.focusSearchBox(event);
950
921
  break;
951
922
  }
952
923
  }
@@ -954,7 +925,7 @@ var DataSearch = {
954
925
  }
955
926
  },
956
927
  render: function render() {
957
- var _this7 = this;
928
+ var _this6 = this;
958
929
  var h = arguments[0];
959
930
  var _this$$props6 = this.$props,
960
931
  theme = _this$$props6.theme,
@@ -989,14 +960,14 @@ var DataSearch = {
989
960
  highlightedIndex = _ref4.highlightedIndex,
990
961
  setHighlightedIndex = _ref4.setHighlightedIndex;
991
962
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
992
- return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
963
+ return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
993
964
  isOpen: isOpen,
994
965
  getItemProps: getItemProps,
995
966
  getItemEvents: getItemEvents,
996
967
  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) {
968
+ }), _this6.renderErrorComponent(), !_this6.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
969
+ "class": Input.suggestions(_this6.themePreset, theme) + " " + getClassName(_this6.$props.innerClass, 'list')
970
+ }, [_this6.suggestionsList.slice(0, size || 10).map(function (item, index) {
1000
971
  return h("li", {
1001
972
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1002
973
  item: item
@@ -1006,15 +977,15 @@ var DataSearch = {
1006
977
  })),
1007
978
  "key": index + 1 + "-" + item.value,
1008
979
  "style": {
1009
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
980
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1010
981
  }
1011
982
  }, [h(Tags.SuggestionItem, {
1012
983
  "attrs": {
1013
- "currentValue": _this7.currentValue,
984
+ "currentValue": _this6.currentValue,
1014
985
  "suggestion": item
1015
986
  }
1016
987
  })]);
1017
- }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
988
+ }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1018
989
  return h("li", {
1019
990
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1020
991
  item: sugg
@@ -1022,9 +993,9 @@ var DataSearch = {
1022
993
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1023
994
  item: sugg
1024
995
  })),
1025
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
996
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1026
997
  "style": {
1027
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
998
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1028
999
  justifyContent: 'flex-start'
1029
1000
  }
1030
1001
  }, [h("div", {
@@ -1033,28 +1004,28 @@ var DataSearch = {
1033
1004
  }
1034
1005
  }, [sugg.source && sugg.source._recent_search && h(Tags.CustomSvg, {
1035
1006
  "attrs": {
1036
- "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1007
+ "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1037
1008
  "icon": recentSearchesIcon,
1038
1009
  "type": "recent-search-icon"
1039
1010
  }
1040
1011
  }), sugg.source && sugg.source._popular_suggestion && h(Tags.CustomSvg, {
1041
1012
  "attrs": {
1042
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1013
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1043
1014
  "icon": popularSearchesIcon,
1044
1015
  "type": "popular-search-icon"
1045
1016
  }
1046
1017
  })]), h(Tags.SuggestionItem, {
1047
1018
  "attrs": {
1048
- "currentValue": _this7.currentValue,
1019
+ "currentValue": _this6.currentValue,
1049
1020
  "suggestion": sugg
1050
1021
  }
1051
1022
  })]);
1052
- }), index.hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1023
+ }), index.hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1053
1024
  isOpen: isOpen,
1054
1025
  getItemProps: getItemProps,
1055
1026
  getItemEvents: getItemEvents,
1056
1027
  highlightedIndex: highlightedIndex
1057
- }, true) : _this7.topSuggestions.map(function (sugg, index) {
1028
+ }, true) : _this6.topSuggestions.map(function (sugg, index) {
1058
1029
  return h("li", {
1059
1030
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1060
1031
  item: sugg
@@ -1062,9 +1033,9 @@ var DataSearch = {
1062
1033
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1063
1034
  item: sugg
1064
1035
  })),
1065
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1036
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1066
1037
  "style": {
1067
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1038
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1068
1039
  justifyContent: 'flex-start'
1069
1040
  }
1070
1041
  }, [h("div", {
@@ -1073,58 +1044,58 @@ var DataSearch = {
1073
1044
  }
1074
1045
  }, [h(Tags.CustomSvg, {
1075
1046
  "attrs": {
1076
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1047
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1077
1048
  "icon": popularSearchesIcon,
1078
1049
  "type": "popular-search-icon"
1079
1050
  }
1080
1051
  })]), h(Tags.SuggestionItem, {
1081
1052
  "attrs": {
1082
- "currentValue": _this7.currentValue,
1053
+ "currentValue": _this6.currentValue,
1083
1054
  "suggestion": sugg
1084
1055
  }
1085
1056
  })]);
1086
- })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1057
+ })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1087
1058
  };
1088
1059
  return h("div", {
1089
1060
  "class": Input.suggestionsContainer
1090
- }, [h(Tags.InputGroup, [_this7.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1061
+ }, [h(Tags.InputGroup, [_this6.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1091
1062
  "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,
1063
+ "id": _this6.$props.componentId + "-input",
1064
+ "showIcon": _this6.$props.showIcon,
1065
+ "showClear": _this6.$props.showClear,
1066
+ "iconPosition": _this6.$props.iconPosition,
1067
+ "placeholder": _this6.$props.placeholder,
1068
+ "autoFocus": _this6.$props.autoFocus,
1069
+ "themePreset": _this6.themePreset,
1099
1070
  "autocomplete": "off"
1100
1071
  },
1101
- "ref": _this7.$props.innerRef,
1102
- "class": getClassName(_this7.$props.innerClass, 'input'),
1072
+ "ref": _this6.$props.innerRef,
1073
+ "class": getClassName(_this6.$props.innerClass, 'input'),
1103
1074
  "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
1104
- onInput: _this7.onInputChange,
1075
+ onInput: _this6.onInputChange,
1105
1076
  onBlur: function onBlur(e) {
1106
- _this7.$emit('blur', e, _this7.triggerQuery);
1077
+ _this6.$emit('blur', e, _this6.triggerQuery);
1107
1078
  },
1108
- onFocus: _this7.handleFocus,
1079
+ onFocus: _this6.handleFocus,
1109
1080
  onKeyPress: function onKeyPress(e) {
1110
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1111
- _this7.$emit('key-press', e, _this7.triggerQuery);
1081
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1082
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1112
1083
  },
1113
1084
  onKeyDown: function onKeyDown(e) {
1114
- return _this7.handleKeyDown(e, highlightedIndex);
1085
+ return _this6.handleKeyDown(e, highlightedIndex);
1115
1086
  },
1116
1087
  onKeyUp: function onKeyUp(e) {
1117
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1118
- _this7.$emit('key-up', e, _this7.triggerQuery);
1088
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1089
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1119
1090
  },
1120
1091
  onClick: function onClick() {
1121
1092
  setHighlightedIndex(null);
1122
1093
  }
1123
1094
  })),
1124
1095
  "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
1125
- value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
1096
+ value: _this6.$data.currentValue === null || typeof _this6.$data.currentValue !== 'string' ? '' : _this6.$data.currentValue
1126
1097
  }))
1127
- }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1098
+ }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1128
1099
  }
1129
1100
  }
1130
1101
  }) : h("div", {
@@ -1140,22 +1111,22 @@ var DataSearch = {
1140
1111
  },
1141
1112
  "on": _rollupPluginBabelHelpers._extends({}, {
1142
1113
  blur: function blur(e) {
1143
- _this7.$emit('blur', e, _this7.triggerQuery);
1114
+ _this6.$emit('blur', e, _this6.triggerQuery);
1144
1115
  },
1145
1116
  keypress: function keypress(e) {
1146
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1147
- _this7.$emit('key-press', e, _this7.triggerQuery);
1117
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1118
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1148
1119
  },
1149
1120
  input: this.onInputChange,
1150
1121
  focus: function focus(e) {
1151
- _this7.$emit('focus', e, _this7.triggerQuery);
1122
+ _this6.$emit('focus', e, _this6.triggerQuery);
1152
1123
  },
1153
1124
  keydown: function keydown(e) {
1154
- _this7.handleKeyDown(e, null);
1125
+ _this6.handleKeyDown(e, null);
1155
1126
  },
1156
1127
  keyup: function keyup(e) {
1157
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1158
- _this7.$emit('key-up', e, _this7.triggerQuery);
1128
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1129
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1159
1130
  }
1160
1131
  }),
1161
1132
  "domProps": _rollupPluginBabelHelpers._extends({}, {
@@ -56,6 +56,7 @@ var ReactiveComponent = {
56
56
  var props = this.$props;
57
57
  this.internalComponent = null;
58
58
  this.$defaultQuery = null;
59
+ this.currentValue = this.selectedValue;
59
60
  // Set custom query in store
60
61
  index.updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
61
62
  var customQuery = props.customQuery,
@@ -140,7 +141,7 @@ var ReactiveComponent = {
140
141
  },
141
142
  watch: {
142
143
  selectedValue: function selectedValue(newVal, oldVal) {
143
- if (!isEqual(newVal, oldVal)) {
144
+ if (!isEqual(newVal, oldVal) || !isEqual(newVal, this.currentValue)) {
144
145
  this.$emit('data', this.getData());
145
146
  this.currentValue = newVal;
146
147
  }