@appbaseio/reactivesearch-vue 1.36.2 → 1.36.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,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,
@@ -602,24 +625,27 @@ var DataSearch = {
602
625
  },
603
626
  clearValue: function clearValue() {
604
627
  this.isPending = false;
605
- this.setValue('', true);
628
+ if (!this.$props.enableDefaultSuggestions) {
629
+ this.isOpen = false;
630
+ }
631
+ this.setValue('', false);
606
632
  this.onValueSelectedHandler('', configureStore.causes.CLEAR_VALUE);
607
633
  },
608
634
  handleKeyDown: function handleKeyDown(event, highlightedIndex) {
609
635
  var targetValue = event.target.value;
610
636
  var _this$$props2 = this.$props,
611
637
  value = _this$$props2.value,
612
- strictSelection = _this$$props2.strictSelection,
613
- size = _this$$props2.size,
614
- autosuggest = _this$$props2.autosuggest;
638
+ size = _this$$props2.size;
615
639
  if (value !== undefined) {
616
640
  this.isPending = true;
617
641
  }
618
642
  // if a suggestion was selected, delegate the handling to suggestion handler
619
643
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
620
644
  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);
645
+ if (!this.isSuggestionSelected) {
646
+ this.setValue(targetValue, true, this.$props, undefined, false);
647
+ this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
648
+ }
623
649
  }
624
650
  // Need to review
625
651
  this.$emit('keyDown', event, this.triggerQuery);
@@ -655,11 +681,16 @@ var DataSearch = {
655
681
  }
656
682
  },
657
683
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
684
+ var _this3 = this;
658
685
  var value = this.$props.value;
659
686
  // Record analytics for selected suggestions
660
687
  this.triggerClickAnalytics(suggestion._click_id);
661
688
  if (value === undefined) {
662
689
  this.setValue(suggestion.value, true, this.$props, configureStore.causes.SUGGESTION_SELECT);
690
+ this.isSuggestionSelected = true;
691
+ setTimeout(function () {
692
+ _this3.isSuggestionSelected = false;
693
+ }, 50);
663
694
  } else if (this.$options.isTagsMode) {
664
695
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
665
696
  if (this.selectedTags.includes(suggestion.value)) {
@@ -765,7 +796,7 @@ var DataSearch = {
765
796
  return null;
766
797
  },
767
798
  renderTag: function renderTag(item) {
768
- var _this3 = this;
799
+ var _this4 = this;
769
800
  var h = this.$createElement;
770
801
  var innerClass = this.$props.innerClass;
771
802
  return h(Tags.TagItem, {
@@ -778,7 +809,7 @@ var DataSearch = {
778
809
  "class": "close-icon",
779
810
  "on": {
780
811
  "click": function click() {
781
- return _this3.clearTag(item);
812
+ return _this4.clearTag(item);
782
813
  }
783
814
  }
784
815
  }, [h(CancelSvg.CancelSvg)])]);
@@ -800,7 +831,7 @@ var DataSearch = {
800
831
  }
801
832
  },
802
833
  renderTags: function renderTags() {
803
- var _this4 = this;
834
+ var _this5 = this;
804
835
  var h = this.$createElement;
805
836
  if (!Array.isArray(this.selectedTags)) {
806
837
  return null;
@@ -813,7 +844,7 @@ var DataSearch = {
813
844
  handleClear: this.clearTag,
814
845
  handleClearAll: this.clearAllTags
815
846
  }) : h(Tags.TagsContainer, [tagsList.map(function (item) {
816
- return _this4.renderTag(item);
847
+ return _this5.renderTag(item);
817
848
  }), shouldRenderClearAllTag && h(Tags.TagItem, {
818
849
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
819
850
  }, [h("span", ["Clear All"]), h("span", {
@@ -892,7 +923,7 @@ var DataSearch = {
892
923
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
893
924
  },
894
925
  listenForFocusShortcuts: function listenForFocusShortcuts() {
895
- var _this5 = this;
926
+ var _this6 = this;
896
927
  var _this$$props$focusSho = this.$props.focusShortcuts,
897
928
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
898
929
  if (index.isEmpty(focusShortcuts)) {
@@ -907,7 +938,7 @@ var DataSearch = {
907
938
  function (event, handler) {
908
939
  // Prevent the default refresh event under WINDOWS system
909
940
  event.preventDefault();
910
- _this5.focusSearchBox(event);
941
+ _this6.focusSearchBox(event);
911
942
  });
912
943
 
913
944
  // if one of modifier keys are used, they are handled below
@@ -917,7 +948,7 @@ var DataSearch = {
917
948
  for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
918
949
  var element = modifierKeys[index$1];
919
950
  if (hotkeys[element]) {
920
- _this5.focusSearchBox(event);
951
+ _this6.focusSearchBox(event);
921
952
  break;
922
953
  }
923
954
  }
@@ -925,7 +956,7 @@ var DataSearch = {
925
956
  }
926
957
  },
927
958
  render: function render() {
928
- var _this6 = this;
959
+ var _this7 = this;
929
960
  var h = arguments[0];
930
961
  var _this$$props6 = this.$props,
931
962
  theme = _this$$props6.theme,
@@ -960,14 +991,14 @@ var DataSearch = {
960
991
  highlightedIndex = _ref4.highlightedIndex,
961
992
  setHighlightedIndex = _ref4.setHighlightedIndex;
962
993
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
963
- return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
994
+ return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
964
995
  isOpen: isOpen,
965
996
  getItemProps: getItemProps,
966
997
  getItemEvents: getItemEvents,
967
998
  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) {
999
+ }), _this7.renderErrorComponent(), !_this7.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1000
+ "class": Input.suggestions(_this7.themePreset, theme) + " " + getClassName(_this7.$props.innerClass, 'list')
1001
+ }, [_this7.suggestionsList.slice(0, size || 10).map(function (item, index) {
971
1002
  return h("li", {
972
1003
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
973
1004
  item: item
@@ -977,15 +1008,15 @@ var DataSearch = {
977
1008
  })),
978
1009
  "key": index + 1 + "-" + item.value,
979
1010
  "style": {
980
- backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1011
+ backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
981
1012
  }
982
1013
  }, [h(Tags.SuggestionItem, {
983
1014
  "attrs": {
984
- "currentValue": _this6.currentValue,
1015
+ "currentValue": _this7.currentValue,
985
1016
  "suggestion": item
986
1017
  }
987
1018
  })]);
988
- }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1019
+ }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
989
1020
  return h("li", {
990
1021
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
991
1022
  item: sugg
@@ -993,9 +1024,9 @@ var DataSearch = {
993
1024
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
994
1025
  item: sugg
995
1026
  })),
996
- "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1027
+ "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
997
1028
  "style": {
998
- backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1029
+ backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
999
1030
  justifyContent: 'flex-start'
1000
1031
  }
1001
1032
  }, [h("div", {
@@ -1004,28 +1035,28 @@ var DataSearch = {
1004
1035
  }
1005
1036
  }, [sugg.source && sugg.source._recent_search && h(Tags.CustomSvg, {
1006
1037
  "attrs": {
1007
- "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1038
+ "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1008
1039
  "icon": recentSearchesIcon,
1009
1040
  "type": "recent-search-icon"
1010
1041
  }
1011
1042
  }), sugg.source && sugg.source._popular_suggestion && h(Tags.CustomSvg, {
1012
1043
  "attrs": {
1013
- "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1044
+ "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1014
1045
  "icon": popularSearchesIcon,
1015
1046
  "type": "popular-search-icon"
1016
1047
  }
1017
1048
  })]), h(Tags.SuggestionItem, {
1018
1049
  "attrs": {
1019
- "currentValue": _this6.currentValue,
1050
+ "currentValue": _this7.currentValue,
1020
1051
  "suggestion": sugg
1021
1052
  }
1022
1053
  })]);
1023
- }), index.hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1054
+ }), index.hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1024
1055
  isOpen: isOpen,
1025
1056
  getItemProps: getItemProps,
1026
1057
  getItemEvents: getItemEvents,
1027
1058
  highlightedIndex: highlightedIndex
1028
- }, true) : _this6.topSuggestions.map(function (sugg, index) {
1059
+ }, true) : _this7.topSuggestions.map(function (sugg, index) {
1029
1060
  return h("li", {
1030
1061
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1031
1062
  item: sugg
@@ -1033,9 +1064,9 @@ var DataSearch = {
1033
1064
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1034
1065
  item: sugg
1035
1066
  })),
1036
- "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1067
+ "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1037
1068
  "style": {
1038
- backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1069
+ backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1039
1070
  justifyContent: 'flex-start'
1040
1071
  }
1041
1072
  }, [h("div", {
@@ -1044,58 +1075,58 @@ var DataSearch = {
1044
1075
  }
1045
1076
  }, [h(Tags.CustomSvg, {
1046
1077
  "attrs": {
1047
- "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1078
+ "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1048
1079
  "icon": popularSearchesIcon,
1049
1080
  "type": "popular-search-icon"
1050
1081
  }
1051
1082
  })]), h(Tags.SuggestionItem, {
1052
1083
  "attrs": {
1053
- "currentValue": _this6.currentValue,
1084
+ "currentValue": _this7.currentValue,
1054
1085
  "suggestion": sugg
1055
1086
  }
1056
1087
  })]);
1057
- })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1088
+ })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1058
1089
  };
1059
1090
  return h("div", {
1060
1091
  "class": Input.suggestionsContainer
1061
- }, [h(Tags.InputGroup, [_this6.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1092
+ }, [h(Tags.InputGroup, [_this7.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1062
1093
  "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,
1094
+ "id": _this7.$props.componentId + "-input",
1095
+ "showIcon": _this7.$props.showIcon,
1096
+ "showClear": _this7.$props.showClear,
1097
+ "iconPosition": _this7.$props.iconPosition,
1098
+ "placeholder": _this7.$props.placeholder,
1099
+ "autoFocus": _this7.$props.autoFocus,
1100
+ "themePreset": _this7.themePreset,
1070
1101
  "autocomplete": "off"
1071
1102
  },
1072
- "ref": _this6.$props.innerRef,
1073
- "class": getClassName(_this6.$props.innerClass, 'input'),
1103
+ "ref": _this7.$props.innerRef,
1104
+ "class": getClassName(_this7.$props.innerClass, 'input'),
1074
1105
  "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
1075
- onInput: _this6.onInputChange,
1106
+ onInput: _this7.onInputChange,
1076
1107
  onBlur: function onBlur(e) {
1077
- _this6.$emit('blur', e, _this6.triggerQuery);
1108
+ _this7.$emit('blur', e, _this7.triggerQuery);
1078
1109
  },
1079
- onFocus: _this6.handleFocus,
1110
+ onFocus: _this7.handleFocus,
1080
1111
  onKeyPress: function onKeyPress(e) {
1081
- _this6.$emit('keyPress', e, _this6.triggerQuery);
1082
- _this6.$emit('key-press', e, _this6.triggerQuery);
1112
+ _this7.$emit('keyPress', e, _this7.triggerQuery);
1113
+ _this7.$emit('key-press', e, _this7.triggerQuery);
1083
1114
  },
1084
1115
  onKeyDown: function onKeyDown(e) {
1085
- return _this6.handleKeyDown(e, highlightedIndex);
1116
+ return _this7.handleKeyDown(e, highlightedIndex);
1086
1117
  },
1087
1118
  onKeyUp: function onKeyUp(e) {
1088
- _this6.$emit('keyUp', e, _this6.triggerQuery);
1089
- _this6.$emit('key-up', e, _this6.triggerQuery);
1119
+ _this7.$emit('keyUp', e, _this7.triggerQuery);
1120
+ _this7.$emit('key-up', e, _this7.triggerQuery);
1090
1121
  },
1091
1122
  onClick: function onClick() {
1092
1123
  setHighlightedIndex(null);
1093
1124
  }
1094
1125
  })),
1095
1126
  "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
1096
- value: _this6.$data.currentValue === null || typeof _this6.$data.currentValue !== 'string' ? '' : _this6.$data.currentValue
1127
+ value: _this7.$data.currentValue === null || typeof _this7.$data.currentValue !== 'string' ? '' : _this7.$data.currentValue
1097
1128
  }))
1098
- }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1129
+ }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1099
1130
  }
1100
1131
  }
1101
1132
  }) : h("div", {
@@ -1111,22 +1142,22 @@ var DataSearch = {
1111
1142
  },
1112
1143
  "on": _rollupPluginBabelHelpers._extends({}, {
1113
1144
  blur: function blur(e) {
1114
- _this6.$emit('blur', e, _this6.triggerQuery);
1145
+ _this7.$emit('blur', e, _this7.triggerQuery);
1115
1146
  },
1116
1147
  keypress: function keypress(e) {
1117
- _this6.$emit('keyPress', e, _this6.triggerQuery);
1118
- _this6.$emit('key-press', e, _this6.triggerQuery);
1148
+ _this7.$emit('keyPress', e, _this7.triggerQuery);
1149
+ _this7.$emit('key-press', e, _this7.triggerQuery);
1119
1150
  },
1120
1151
  input: this.onInputChange,
1121
1152
  focus: function focus(e) {
1122
- _this6.$emit('focus', e, _this6.triggerQuery);
1153
+ _this7.$emit('focus', e, _this7.triggerQuery);
1123
1154
  },
1124
1155
  keydown: function keydown(e) {
1125
- _this6.handleKeyDown(e, null);
1156
+ _this7.handleKeyDown(e, null);
1126
1157
  },
1127
1158
  keyup: function keyup(e) {
1128
- _this6.$emit('keyUp', e, _this6.triggerQuery);
1129
- _this6.$emit('key-up', e, _this6.triggerQuery);
1159
+ _this7.$emit('keyUp', e, _this7.triggerQuery);
1160
+ _this7.$emit('key-up', e, _this7.triggerQuery);
1130
1161
  }
1131
1162
  }),
1132
1163
  "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.4";
6
6
 
7
7
  exports.default = version;