@appbaseio/reactivesearch-vue 1.36.2 → 1.36.3

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