@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.
@@ -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;
@@ -439,7 +438,6 @@ var DataSearch = {
439
438
  _this.getRecentSearches();
440
439
  }
441
440
  if (isTagsMode) {
442
- var isTagAdded = false;
443
441
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
444
442
  // check if value already present in selectedTags
445
443
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -448,36 +446,14 @@ var DataSearch = {
448
446
  }
449
447
  _this.selectedTags = [].concat(_this.selectedTags);
450
448
  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
- }
449
+ _this.selectedTags.push(value);
458
450
  } 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
- }
451
+ _this.selectedTags = value;
466
452
  }
467
453
  } 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 = '';
454
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
480
455
  }
456
+ _this.currentValue = '';
481
457
  } else {
482
458
  _this.currentValue = value;
483
459
  }
@@ -497,7 +473,7 @@ var DataSearch = {
497
473
  if (props.strictSelection && props.autosuggest) {
498
474
  if (cause === causes.SUGGESTION_SELECT || props.value !== undefined) {
499
475
  _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
500
- } else if (_this.currentValue !== '' && !props.strictSelection) {
476
+ } else if (_this.currentValue !== '') {
501
477
  _this.setValue('', true);
502
478
  }
503
479
  } else {
@@ -626,17 +602,17 @@ var DataSearch = {
626
602
  var targetValue = event.target.value;
627
603
  var _this$$props2 = this.$props,
628
604
  value = _this$$props2.value,
629
- size = _this$$props2.size;
605
+ strictSelection = _this$$props2.strictSelection,
606
+ size = _this$$props2.size,
607
+ autosuggest = _this$$props2.autosuggest;
630
608
  if (value !== undefined) {
631
609
  this.isPending = true;
632
610
  }
633
611
  // if a suggestion was selected, delegate the handling to suggestion handler
634
612
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
635
613
  this.isPending = false;
636
- if (!this.isSuggestionSelected) {
637
- this.setValue(targetValue, true, this.$props, undefined, false);
638
- this.onValueSelectedHandler(targetValue, causes.ENTER_PRESS);
639
- }
614
+ this.setValue(this.$options.isTagsMode && autosuggest && strictSelection ? '' : targetValue, true, this.$props, undefined, false);
615
+ this.onValueSelectedHandler(targetValue, causes.ENTER_PRESS);
640
616
  }
641
617
  // Need to review
642
618
  this.$emit('keyDown', event, this.triggerQuery);
@@ -672,16 +648,11 @@ var DataSearch = {
672
648
  }
673
649
  },
674
650
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
675
- var _this3 = this;
676
651
  var value = this.$props.value;
677
652
  // Record analytics for selected suggestions
678
653
  this.triggerClickAnalytics(suggestion._click_id);
679
654
  if (value === undefined) {
680
655
  this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT);
681
- this.isSuggestionSelected = true;
682
- setTimeout(function () {
683
- _this3.isSuggestionSelected = false;
684
- }, 50);
685
656
  } else if (this.$options.isTagsMode) {
686
657
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
687
658
  if (this.selectedTags.includes(suggestion.value)) {
@@ -787,7 +758,7 @@ var DataSearch = {
787
758
  return null;
788
759
  },
789
760
  renderTag: function renderTag(item) {
790
- var _this4 = this;
761
+ var _this3 = this;
791
762
  var h = this.$createElement;
792
763
  var innerClass = this.$props.innerClass;
793
764
  return h(TagItem, {
@@ -800,7 +771,7 @@ var DataSearch = {
800
771
  "class": "close-icon",
801
772
  "on": {
802
773
  "click": function click() {
803
- return _this4.clearTag(item);
774
+ return _this3.clearTag(item);
804
775
  }
805
776
  }
806
777
  }, [h(CancelSvg)])]);
@@ -822,7 +793,7 @@ var DataSearch = {
822
793
  }
823
794
  },
824
795
  renderTags: function renderTags() {
825
- var _this5 = this;
796
+ var _this4 = this;
826
797
  var h = this.$createElement;
827
798
  if (!Array.isArray(this.selectedTags)) {
828
799
  return null;
@@ -835,7 +806,7 @@ var DataSearch = {
835
806
  handleClear: this.clearTag,
836
807
  handleClearAll: this.clearAllTags
837
808
  }) : h(TagsContainer, [tagsList.map(function (item) {
838
- return _this5.renderTag(item);
809
+ return _this4.renderTag(item);
839
810
  }), shouldRenderClearAllTag && h(TagItem, {
840
811
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
841
812
  }, [h("span", ["Clear All"]), h("span", {
@@ -914,7 +885,7 @@ var DataSearch = {
914
885
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
915
886
  },
916
887
  listenForFocusShortcuts: function listenForFocusShortcuts() {
917
- var _this6 = this;
888
+ var _this5 = this;
918
889
  var _this$$props$focusSho = this.$props.focusShortcuts,
919
890
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
920
891
  if (isEmpty(focusShortcuts)) {
@@ -929,7 +900,7 @@ var DataSearch = {
929
900
  function (event, handler) {
930
901
  // Prevent the default refresh event under WINDOWS system
931
902
  event.preventDefault();
932
- _this6.focusSearchBox(event);
903
+ _this5.focusSearchBox(event);
933
904
  });
934
905
 
935
906
  // if one of modifier keys are used, they are handled below
@@ -939,7 +910,7 @@ var DataSearch = {
939
910
  for (var index = 0; index < modifierKeys.length; index += 1) {
940
911
  var element = modifierKeys[index];
941
912
  if (hotkeys[element]) {
942
- _this6.focusSearchBox(event);
913
+ _this5.focusSearchBox(event);
943
914
  break;
944
915
  }
945
916
  }
@@ -947,7 +918,7 @@ var DataSearch = {
947
918
  }
948
919
  },
949
920
  render: function render() {
950
- var _this7 = this;
921
+ var _this6 = this;
951
922
  var h = arguments[0];
952
923
  var _this$$props6 = this.$props,
953
924
  theme = _this$$props6.theme,
@@ -982,14 +953,14 @@ var DataSearch = {
982
953
  highlightedIndex = _ref4.highlightedIndex,
983
954
  setHighlightedIndex = _ref4.setHighlightedIndex;
984
955
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
985
- return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
956
+ return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
986
957
  isOpen: isOpen,
987
958
  getItemProps: getItemProps,
988
959
  getItemEvents: getItemEvents,
989
960
  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) {
961
+ }), _this6.renderErrorComponent(), !_this6.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
962
+ "class": suggestions(_this6.themePreset, theme) + " " + getClassName(_this6.$props.innerClass, 'list')
963
+ }, [_this6.suggestionsList.slice(0, size || 10).map(function (item, index) {
993
964
  return h("li", {
994
965
  "domProps": _extends({}, getItemProps({
995
966
  item: item
@@ -999,15 +970,15 @@ var DataSearch = {
999
970
  })),
1000
971
  "key": index + 1 + "-" + item.value,
1001
972
  "style": {
1002
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
973
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1003
974
  }
1004
975
  }, [h(SuggestionItem, {
1005
976
  "attrs": {
1006
- "currentValue": _this7.currentValue,
977
+ "currentValue": _this6.currentValue,
1007
978
  "suggestion": item
1008
979
  }
1009
980
  })]);
1010
- }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
981
+ }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1011
982
  return h("li", {
1012
983
  "domProps": _extends({}, getItemProps({
1013
984
  item: sugg
@@ -1015,9 +986,9 @@ var DataSearch = {
1015
986
  "on": _extends({}, getItemEvents({
1016
987
  item: sugg
1017
988
  })),
1018
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
989
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1019
990
  "style": {
1020
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
991
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1021
992
  justifyContent: 'flex-start'
1022
993
  }
1023
994
  }, [h("div", {
@@ -1026,28 +997,28 @@ var DataSearch = {
1026
997
  }
1027
998
  }, [sugg.source && sugg.source._recent_search && h(CustomSvg, {
1028
999
  "attrs": {
1029
- "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1000
+ "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1030
1001
  "icon": recentSearchesIcon,
1031
1002
  "type": "recent-search-icon"
1032
1003
  }
1033
1004
  }), sugg.source && sugg.source._popular_suggestion && h(CustomSvg, {
1034
1005
  "attrs": {
1035
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1006
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1036
1007
  "icon": popularSearchesIcon,
1037
1008
  "type": "popular-search-icon"
1038
1009
  }
1039
1010
  })]), h(SuggestionItem, {
1040
1011
  "attrs": {
1041
- "currentValue": _this7.currentValue,
1012
+ "currentValue": _this6.currentValue,
1042
1013
  "suggestion": sugg
1043
1014
  }
1044
1015
  })]);
1045
- }), hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1016
+ }), hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1046
1017
  isOpen: isOpen,
1047
1018
  getItemProps: getItemProps,
1048
1019
  getItemEvents: getItemEvents,
1049
1020
  highlightedIndex: highlightedIndex
1050
- }, true) : _this7.topSuggestions.map(function (sugg, index) {
1021
+ }, true) : _this6.topSuggestions.map(function (sugg, index) {
1051
1022
  return h("li", {
1052
1023
  "domProps": _extends({}, getItemProps({
1053
1024
  item: sugg
@@ -1055,9 +1026,9 @@ var DataSearch = {
1055
1026
  "on": _extends({}, getItemEvents({
1056
1027
  item: sugg
1057
1028
  })),
1058
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1029
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1059
1030
  "style": {
1060
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1031
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1061
1032
  justifyContent: 'flex-start'
1062
1033
  }
1063
1034
  }, [h("div", {
@@ -1066,58 +1037,58 @@ var DataSearch = {
1066
1037
  }
1067
1038
  }, [h(CustomSvg, {
1068
1039
  "attrs": {
1069
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1040
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1070
1041
  "icon": popularSearchesIcon,
1071
1042
  "type": "popular-search-icon"
1072
1043
  }
1073
1044
  })]), h(SuggestionItem, {
1074
1045
  "attrs": {
1075
- "currentValue": _this7.currentValue,
1046
+ "currentValue": _this6.currentValue,
1076
1047
  "suggestion": sugg
1077
1048
  }
1078
1049
  })]);
1079
- })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1050
+ })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1080
1051
  };
1081
1052
  return h("div", {
1082
1053
  "class": suggestionsContainer
1083
- }, [h(InputGroup, [_this7.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1054
+ }, [h(InputGroup, [_this6.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1084
1055
  "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,
1056
+ "id": _this6.$props.componentId + "-input",
1057
+ "showIcon": _this6.$props.showIcon,
1058
+ "showClear": _this6.$props.showClear,
1059
+ "iconPosition": _this6.$props.iconPosition,
1060
+ "placeholder": _this6.$props.placeholder,
1061
+ "autoFocus": _this6.$props.autoFocus,
1062
+ "themePreset": _this6.themePreset,
1092
1063
  "autocomplete": "off"
1093
1064
  },
1094
- "ref": _this7.$props.innerRef,
1095
- "class": getClassName(_this7.$props.innerClass, 'input'),
1065
+ "ref": _this6.$props.innerRef,
1066
+ "class": getClassName(_this6.$props.innerClass, 'input'),
1096
1067
  "on": _extends({}, getInputEvents({
1097
- onInput: _this7.onInputChange,
1068
+ onInput: _this6.onInputChange,
1098
1069
  onBlur: function onBlur(e) {
1099
- _this7.$emit('blur', e, _this7.triggerQuery);
1070
+ _this6.$emit('blur', e, _this6.triggerQuery);
1100
1071
  },
1101
- onFocus: _this7.handleFocus,
1072
+ onFocus: _this6.handleFocus,
1102
1073
  onKeyPress: function onKeyPress(e) {
1103
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1104
- _this7.$emit('key-press', e, _this7.triggerQuery);
1074
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1075
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1105
1076
  },
1106
1077
  onKeyDown: function onKeyDown(e) {
1107
- return _this7.handleKeyDown(e, highlightedIndex);
1078
+ return _this6.handleKeyDown(e, highlightedIndex);
1108
1079
  },
1109
1080
  onKeyUp: function onKeyUp(e) {
1110
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1111
- _this7.$emit('key-up', e, _this7.triggerQuery);
1081
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1082
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1112
1083
  },
1113
1084
  onClick: function onClick() {
1114
1085
  setHighlightedIndex(null);
1115
1086
  }
1116
1087
  })),
1117
1088
  "domProps": _extends({}, getInputProps({
1118
- value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
1089
+ value: _this6.$data.currentValue === null || typeof _this6.$data.currentValue !== 'string' ? '' : _this6.$data.currentValue
1119
1090
  }))
1120
- }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1091
+ }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1121
1092
  }
1122
1093
  }
1123
1094
  }) : h("div", {
@@ -1133,22 +1104,22 @@ var DataSearch = {
1133
1104
  },
1134
1105
  "on": _extends({}, {
1135
1106
  blur: function blur(e) {
1136
- _this7.$emit('blur', e, _this7.triggerQuery);
1107
+ _this6.$emit('blur', e, _this6.triggerQuery);
1137
1108
  },
1138
1109
  keypress: function keypress(e) {
1139
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1140
- _this7.$emit('key-press', e, _this7.triggerQuery);
1110
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1111
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1141
1112
  },
1142
1113
  input: this.onInputChange,
1143
1114
  focus: function focus(e) {
1144
- _this7.$emit('focus', e, _this7.triggerQuery);
1115
+ _this6.$emit('focus', e, _this6.triggerQuery);
1145
1116
  },
1146
1117
  keydown: function keydown(e) {
1147
- _this7.handleKeyDown(e, null);
1118
+ _this6.handleKeyDown(e, null);
1148
1119
  },
1149
1120
  keyup: function keyup(e) {
1150
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1151
- _this7.$emit('key-up', e, _this7.triggerQuery);
1121
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1122
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1152
1123
  }
1153
1124
  }),
1154
1125
  "domProps": _extends({}, {
@@ -49,6 +49,7 @@ var ReactiveComponent = {
49
49
  var props = this.$props;
50
50
  this.internalComponent = null;
51
51
  this.$defaultQuery = null;
52
+ this.currentValue = this.selectedValue;
52
53
  // Set custom query in store
53
54
  updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
54
55
  var customQuery = props.customQuery,
@@ -133,7 +134,7 @@ var ReactiveComponent = {
133
134
  },
134
135
  watch: {
135
136
  selectedValue: function selectedValue(newVal, oldVal) {
136
- if (!isEqual(newVal, oldVal)) {
137
+ if (!isEqual(newVal, oldVal) || !isEqual(newVal, this.currentValue)) {
137
138
  this.$emit('data', this.getData());
138
139
  this.currentValue = newVal;
139
140
  }