@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.
@@ -60,7 +60,8 @@ var DataSearch = {
60
60
  selectedTags: [],
61
61
  isOpen: false,
62
62
  normalizedSuggestions: [],
63
- isPending: false
63
+ isPending: false,
64
+ isSuggestionSelected: false
64
65
  };
65
66
  this.internalComponent = props.componentId + "__internal";
66
67
  return this.__state;
@@ -454,6 +455,7 @@ var DataSearch = {
454
455
  _this.getRecentSearches();
455
456
  }
456
457
  if (isTagsMode) {
458
+ var isTagAdded = false;
457
459
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
458
460
  // check if value already present in selectedTags
459
461
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -462,14 +464,36 @@ var DataSearch = {
462
464
  }
463
465
  _this.selectedTags = [].concat(_this.selectedTags);
464
466
  if (typeof value === 'string' && !!value) {
465
- _this.selectedTags.push(value);
467
+ if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
468
+ _this.selectedTags.push(value);
469
+ isTagAdded = true;
470
+ } else if (!props.strictSelection) {
471
+ _this.selectedTags.push(value);
472
+ isTagAdded = true;
473
+ }
466
474
  } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
467
- _this.selectedTags = value;
475
+ if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
476
+ _this.selectedTags = value;
477
+ isTagAdded = true;
478
+ } else if (!props.strictSelection) {
479
+ _this.selectedTags.push(value);
480
+ isTagAdded = true;
481
+ }
468
482
  }
469
483
  } else if (value) {
470
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
484
+ if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
485
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
486
+ isTagAdded = true;
487
+ } else if (!props.strictSelection) {
488
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
489
+ isTagAdded = true;
490
+ }
491
+ }
492
+ if (props.strictSelection && !isTagAdded) {
493
+ _this.currentValue = value;
494
+ } else {
495
+ _this.currentValue = '';
471
496
  }
472
- _this.currentValue = '';
473
497
  } else {
474
498
  _this.currentValue = value;
475
499
  }
@@ -489,7 +513,7 @@ var DataSearch = {
489
513
  if (props.strictSelection && props.autosuggest) {
490
514
  if (cause === configureStore.causes.SUGGESTION_SELECT || props.value !== undefined) {
491
515
  _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
492
- } else if (_this.currentValue !== '') {
516
+ } else if (_this.currentValue !== '' && !props.strictSelection) {
493
517
  _this.setValue('', true);
494
518
  }
495
519
  } else {
@@ -503,7 +527,7 @@ var DataSearch = {
503
527
  _this.$emit('value-change', value);
504
528
  // Set the already fetched suggestions if query is same as used last to fetch the hits
505
529
  if (value === _this.lastUsedQuery) {
506
- _this.suggestions = _this.onSuggestions(_this.suggestions);
530
+ _this.normalizedSuggestions = _this.onSuggestions(_this.suggestions);
507
531
  // invoke on suggestions
508
532
  _this.$emit('suggestions', _this.suggestions);
509
533
  } else if (!value) {
@@ -613,17 +637,17 @@ var DataSearch = {
613
637
  var targetValue = event.target.value;
614
638
  var _this$$props2 = this.$props,
615
639
  value = _this$$props2.value,
616
- strictSelection = _this$$props2.strictSelection,
617
- size = _this$$props2.size,
618
- autosuggest = _this$$props2.autosuggest;
640
+ size = _this$$props2.size;
619
641
  if (value !== undefined) {
620
642
  this.isPending = true;
621
643
  }
622
644
  // if a suggestion was selected, delegate the handling to suggestion handler
623
645
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
624
646
  this.isPending = false;
625
- this.setValue(this.$options.isTagsMode && autosuggest && strictSelection ? '' : targetValue, true, this.$props, undefined, false);
626
- this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
647
+ if (!this.isSuggestionSelected) {
648
+ this.setValue(targetValue, true, this.$props, undefined, false);
649
+ this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
650
+ }
627
651
  }
628
652
  // Need to review
629
653
  this.$emit('keyDown', event, this.triggerQuery);
@@ -659,11 +683,16 @@ var DataSearch = {
659
683
  }
660
684
  },
661
685
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
686
+ var _this3 = this;
662
687
  var value = this.$props.value;
663
688
  // Record analytics for selected suggestions
664
689
  this.triggerClickAnalytics(suggestion._click_id);
665
690
  if (value === undefined) {
666
691
  this.setValue(suggestion.value, true, this.$props, configureStore.causes.SUGGESTION_SELECT);
692
+ this.isSuggestionSelected = true;
693
+ setTimeout(function () {
694
+ _this3.isSuggestionSelected = false;
695
+ }, 50);
667
696
  } else if (this.$options.isTagsMode) {
668
697
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
669
698
  if (this.selectedTags.includes(suggestion.value)) {
@@ -769,7 +798,7 @@ var DataSearch = {
769
798
  return null;
770
799
  },
771
800
  renderTag: function renderTag(item) {
772
- var _this3 = this;
801
+ var _this4 = this;
773
802
  var h = this.$createElement;
774
803
  var innerClass = this.$props.innerClass;
775
804
  return h(Tags.TagItem, {
@@ -782,7 +811,7 @@ var DataSearch = {
782
811
  "class": "close-icon",
783
812
  "on": {
784
813
  "click": function click() {
785
- return _this3.clearTag(item);
814
+ return _this4.clearTag(item);
786
815
  }
787
816
  }
788
817
  }, [h(CancelSvg.CancelSvg)])]);
@@ -804,7 +833,7 @@ var DataSearch = {
804
833
  }
805
834
  },
806
835
  renderTags: function renderTags() {
807
- var _this4 = this;
836
+ var _this5 = this;
808
837
  var h = this.$createElement;
809
838
  if (!Array.isArray(this.selectedTags)) {
810
839
  return null;
@@ -817,7 +846,7 @@ var DataSearch = {
817
846
  handleClear: this.clearTag,
818
847
  handleClearAll: this.clearAllTags
819
848
  }) : h(Tags.TagsContainer, [tagsList.map(function (item) {
820
- return _this4.renderTag(item);
849
+ return _this5.renderTag(item);
821
850
  }), shouldRenderClearAllTag && h(Tags.TagItem, {
822
851
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
823
852
  }, [h("span", ["Clear All"]), h("span", {
@@ -896,7 +925,7 @@ var DataSearch = {
896
925
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
897
926
  },
898
927
  listenForFocusShortcuts: function listenForFocusShortcuts() {
899
- var _this5 = this;
928
+ var _this6 = this;
900
929
  var _this$$props$focusSho = this.$props.focusShortcuts,
901
930
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
902
931
  if (index.isEmpty(focusShortcuts)) {
@@ -911,7 +940,7 @@ var DataSearch = {
911
940
  function (event, handler) {
912
941
  // Prevent the default refresh event under WINDOWS system
913
942
  event.preventDefault();
914
- _this5.focusSearchBox(event);
943
+ _this6.focusSearchBox(event);
915
944
  });
916
945
 
917
946
  // if one of modifier keys are used, they are handled below
@@ -921,7 +950,7 @@ var DataSearch = {
921
950
  for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
922
951
  var element = modifierKeys[index$1];
923
952
  if (hotkeys[element]) {
924
- _this5.focusSearchBox(event);
953
+ _this6.focusSearchBox(event);
925
954
  break;
926
955
  }
927
956
  }
@@ -929,7 +958,7 @@ var DataSearch = {
929
958
  }
930
959
  },
931
960
  render: function render() {
932
- var _this6 = this;
961
+ var _this7 = this;
933
962
  var h = arguments[0];
934
963
  var _this$$props6 = this.$props,
935
964
  theme = _this$$props6.theme,
@@ -964,14 +993,14 @@ var DataSearch = {
964
993
  highlightedIndex = _ref4.highlightedIndex,
965
994
  setHighlightedIndex = _ref4.setHighlightedIndex;
966
995
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
967
- return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
996
+ return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
968
997
  isOpen: isOpen,
969
998
  getItemProps: getItemProps,
970
999
  getItemEvents: getItemEvents,
971
1000
  highlightedIndex: highlightedIndex
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) {
1001
+ }), _this7.renderErrorComponent(), !_this7.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1002
+ "class": Input.suggestions(_this7.themePreset, theme) + " " + getClassName(_this7.$props.innerClass, 'list')
1003
+ }, [_this7.suggestionsList.slice(0, size || 10).map(function (item, index) {
975
1004
  return h("li", {
976
1005
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
977
1006
  item: item
@@ -981,15 +1010,15 @@ var DataSearch = {
981
1010
  })),
982
1011
  "key": index + 1 + "-" + item.value,
983
1012
  "style": {
984
- backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1013
+ backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
985
1014
  }
986
1015
  }, [h(Tags.SuggestionItem, {
987
1016
  "attrs": {
988
- "currentValue": _this6.currentValue,
1017
+ "currentValue": _this7.currentValue,
989
1018
  "suggestion": item
990
1019
  }
991
1020
  })]);
992
- }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1021
+ }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
993
1022
  return h("li", {
994
1023
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
995
1024
  item: sugg
@@ -997,9 +1026,9 @@ var DataSearch = {
997
1026
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
998
1027
  item: sugg
999
1028
  })),
1000
- "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1029
+ "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1001
1030
  "style": {
1002
- backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1031
+ backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1003
1032
  justifyContent: 'flex-start'
1004
1033
  }
1005
1034
  }, [h("div", {
@@ -1008,28 +1037,28 @@ var DataSearch = {
1008
1037
  }
1009
1038
  }, [sugg.source && sugg.source._recent_search && h(Tags.CustomSvg, {
1010
1039
  "attrs": {
1011
- "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1040
+ "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1012
1041
  "icon": recentSearchesIcon,
1013
1042
  "type": "recent-search-icon"
1014
1043
  }
1015
1044
  }), sugg.source && sugg.source._popular_suggestion && h(Tags.CustomSvg, {
1016
1045
  "attrs": {
1017
- "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1046
+ "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1018
1047
  "icon": popularSearchesIcon,
1019
1048
  "type": "popular-search-icon"
1020
1049
  }
1021
1050
  })]), h(Tags.SuggestionItem, {
1022
1051
  "attrs": {
1023
- "currentValue": _this6.currentValue,
1052
+ "currentValue": _this7.currentValue,
1024
1053
  "suggestion": sugg
1025
1054
  }
1026
1055
  })]);
1027
- }), index.hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1056
+ }), index.hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1028
1057
  isOpen: isOpen,
1029
1058
  getItemProps: getItemProps,
1030
1059
  getItemEvents: getItemEvents,
1031
1060
  highlightedIndex: highlightedIndex
1032
- }, true) : _this6.topSuggestions.map(function (sugg, index) {
1061
+ }, true) : _this7.topSuggestions.map(function (sugg, index) {
1033
1062
  return h("li", {
1034
1063
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1035
1064
  item: sugg
@@ -1037,9 +1066,9 @@ var DataSearch = {
1037
1066
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1038
1067
  item: sugg
1039
1068
  })),
1040
- "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1069
+ "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1041
1070
  "style": {
1042
- backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1071
+ backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1043
1072
  justifyContent: 'flex-start'
1044
1073
  }
1045
1074
  }, [h("div", {
@@ -1048,58 +1077,58 @@ var DataSearch = {
1048
1077
  }
1049
1078
  }, [h(Tags.CustomSvg, {
1050
1079
  "attrs": {
1051
- "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1080
+ "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1052
1081
  "icon": popularSearchesIcon,
1053
1082
  "type": "popular-search-icon"
1054
1083
  }
1055
1084
  })]), h(Tags.SuggestionItem, {
1056
1085
  "attrs": {
1057
- "currentValue": _this6.currentValue,
1086
+ "currentValue": _this7.currentValue,
1058
1087
  "suggestion": sugg
1059
1088
  }
1060
1089
  })]);
1061
- })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1090
+ })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1062
1091
  };
1063
1092
  return h("div", {
1064
1093
  "class": Input.suggestionsContainer
1065
- }, [h(Tags.InputGroup, [_this6.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1094
+ }, [h(Tags.InputGroup, [_this7.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1066
1095
  "attrs": {
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,
1096
+ "id": _this7.$props.componentId + "-input",
1097
+ "showIcon": _this7.$props.showIcon,
1098
+ "showClear": _this7.$props.showClear,
1099
+ "iconPosition": _this7.$props.iconPosition,
1100
+ "placeholder": _this7.$props.placeholder,
1101
+ "autoFocus": _this7.$props.autoFocus,
1102
+ "themePreset": _this7.themePreset,
1074
1103
  "autocomplete": "off"
1075
1104
  },
1076
- "ref": _this6.$props.innerRef,
1077
- "class": getClassName(_this6.$props.innerClass, 'input'),
1105
+ "ref": _this7.$props.innerRef,
1106
+ "class": getClassName(_this7.$props.innerClass, 'input'),
1078
1107
  "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
1079
- onInput: _this6.onInputChange,
1108
+ onInput: _this7.onInputChange,
1080
1109
  onBlur: function onBlur(e) {
1081
- _this6.$emit('blur', e, _this6.triggerQuery);
1110
+ _this7.$emit('blur', e, _this7.triggerQuery);
1082
1111
  },
1083
- onFocus: _this6.handleFocus,
1112
+ onFocus: _this7.handleFocus,
1084
1113
  onKeyPress: function onKeyPress(e) {
1085
- _this6.$emit('keyPress', e, _this6.triggerQuery);
1086
- _this6.$emit('key-press', e, _this6.triggerQuery);
1114
+ _this7.$emit('keyPress', e, _this7.triggerQuery);
1115
+ _this7.$emit('key-press', e, _this7.triggerQuery);
1087
1116
  },
1088
1117
  onKeyDown: function onKeyDown(e) {
1089
- return _this6.handleKeyDown(e, highlightedIndex);
1118
+ return _this7.handleKeyDown(e, highlightedIndex);
1090
1119
  },
1091
1120
  onKeyUp: function onKeyUp(e) {
1092
- _this6.$emit('keyUp', e, _this6.triggerQuery);
1093
- _this6.$emit('key-up', e, _this6.triggerQuery);
1121
+ _this7.$emit('keyUp', e, _this7.triggerQuery);
1122
+ _this7.$emit('key-up', e, _this7.triggerQuery);
1094
1123
  },
1095
1124
  onClick: function onClick() {
1096
1125
  setHighlightedIndex(null);
1097
1126
  }
1098
1127
  })),
1099
1128
  "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
1100
- value: _this6.$data.currentValue === null || typeof _this6.$data.currentValue !== 'string' ? '' : _this6.$data.currentValue
1129
+ value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
1101
1130
  }))
1102
- }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1131
+ }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1103
1132
  }
1104
1133
  }
1105
1134
  }) : h("div", {
@@ -1115,22 +1144,22 @@ var DataSearch = {
1115
1144
  },
1116
1145
  "on": _rollupPluginBabelHelpers._extends({}, {
1117
1146
  blur: function blur(e) {
1118
- _this6.$emit('blur', e, _this6.triggerQuery);
1147
+ _this7.$emit('blur', e, _this7.triggerQuery);
1119
1148
  },
1120
1149
  keypress: function keypress(e) {
1121
- _this6.$emit('keyPress', e, _this6.triggerQuery);
1122
- _this6.$emit('key-press', e, _this6.triggerQuery);
1150
+ _this7.$emit('keyPress', e, _this7.triggerQuery);
1151
+ _this7.$emit('key-press', e, _this7.triggerQuery);
1123
1152
  },
1124
1153
  input: this.onInputChange,
1125
1154
  focus: function focus(e) {
1126
- _this6.$emit('focus', e, _this6.triggerQuery);
1155
+ _this7.$emit('focus', e, _this7.triggerQuery);
1127
1156
  },
1128
1157
  keydown: function keydown(e) {
1129
- _this6.handleKeyDown(e, null);
1158
+ _this7.handleKeyDown(e, null);
1130
1159
  },
1131
1160
  keyup: function keyup(e) {
1132
- _this6.$emit('keyUp', e, _this6.triggerQuery);
1133
- _this6.$emit('key-up', e, _this6.triggerQuery);
1161
+ _this7.$emit('keyUp', e, _this7.triggerQuery);
1162
+ _this7.$emit('key-up', e, _this7.triggerQuery);
1134
1163
  }
1135
1164
  }),
1136
1165
  "domProps": _rollupPluginBabelHelpers._extends({}, {