@appbaseio/reactivesearch-vue 1.36.1 → 1.36.2

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;
@@ -301,23 +300,12 @@ var DataSearch = {
301
300
  this.updateQueryHandler(this.componentId, this.$data.currentValue, this.$props);
302
301
  }
303
302
  },
304
- isLoading: function isLoading(newVal) {
305
- if (newVal) {
306
- this.suggestions = [];
307
- }
308
- },
309
303
  suggestions: function suggestions(newVal) {
310
- if (this.isLoading) {
311
- this.normalizedSuggestions = [];
312
- return;
313
- }
314
304
  if (Array.isArray(newVal) && this.$data.currentValue.trim().length) {
315
305
  // shallow check allows us to set suggestions even if the next set
316
306
  // of suggestions are same as the current one
317
307
  this.$emit('suggestions', newVal);
318
- if (!isEqual(this.normalizedSuggestions, newVal)) {
319
- this.normalizedSuggestions = this.onSuggestions(newVal);
320
- }
308
+ this.normalizedSuggestions = this.onSuggestions(newVal);
321
309
  }
322
310
  },
323
311
  selectedValue: function selectedValue(newVal, oldVal) {
@@ -451,11 +439,12 @@ var DataSearch = {
451
439
  return;
452
440
  }
453
441
  // Refresh recent searches when value becomes empty
454
- if (props.enableDefaultSuggestions && !value && _this.currentValue && _this.enableRecentSearches) {
442
+ if (!value && props.enableDefaultSuggestions === false) {
443
+ _this.resetStoreForComponent(props.componentId);
444
+ } else if (!value && _this.currentValue && _this.enableRecentSearches) {
455
445
  _this.getRecentSearches();
456
446
  }
457
447
  if (isTagsMode) {
458
- var isTagAdded = false;
459
448
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
460
449
  // check if value already present in selectedTags
461
450
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -464,36 +453,14 @@ var DataSearch = {
464
453
  }
465
454
  _this.selectedTags = [].concat(_this.selectedTags);
466
455
  if (typeof value === 'string' && !!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
- }
456
+ _this.selectedTags.push(value);
474
457
  } else if (Array.isArray(value) && !isEqual(_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
- }
458
+ _this.selectedTags = value;
482
459
  }
483
460
  } else if (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 = '';
461
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
496
462
  }
463
+ _this.currentValue = '';
497
464
  } else {
498
465
  _this.currentValue = value;
499
466
  }
@@ -513,7 +480,7 @@ var DataSearch = {
513
480
  if (props.strictSelection && props.autosuggest) {
514
481
  if (cause === configureStore.causes.SUGGESTION_SELECT || props.value !== undefined) {
515
482
  _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
516
- } else if (_this.currentValue !== '' && !props.strictSelection) {
483
+ } else if (_this.currentValue !== '') {
517
484
  _this.setValue('', true);
518
485
  }
519
486
  } else {
@@ -543,6 +510,11 @@ var DataSearch = {
543
510
  if (props === void 0) {
544
511
  props = this.$props;
545
512
  }
513
+ if (!value && props.enableDefaultSuggestions === false) {
514
+ // clear Component data from store
515
+ this.resetStoreForComponent(props.componentId);
516
+ return;
517
+ }
546
518
  var defaultQueryOptions;
547
519
  var query = DataSearch.defaultQuery(value, props);
548
520
  if (this.defaultQuery) {
@@ -637,17 +609,17 @@ var DataSearch = {
637
609
  var targetValue = event.target.value;
638
610
  var _this$$props2 = this.$props,
639
611
  value = _this$$props2.value,
640
- size = _this$$props2.size;
612
+ strictSelection = _this$$props2.strictSelection,
613
+ size = _this$$props2.size,
614
+ autosuggest = _this$$props2.autosuggest;
641
615
  if (value !== undefined) {
642
616
  this.isPending = true;
643
617
  }
644
618
  // if a suggestion was selected, delegate the handling to suggestion handler
645
619
  if (event.key === 'Enter' && (highlightedIndex === null || highlightedIndex < 0 || highlightedIndex === [].concat([].concat(this.suggestionsList).slice(0, size || 10), this.defaultSearchSuggestions, this.topSuggestions).length)) {
646
620
  this.isPending = false;
647
- if (!this.isSuggestionSelected) {
648
- this.setValue(targetValue, true, this.$props, undefined, false);
649
- this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
650
- }
621
+ this.setValue(this.$options.isTagsMode && autosuggest && strictSelection ? '' : targetValue, true, this.$props, undefined, false);
622
+ this.onValueSelectedHandler(targetValue, configureStore.causes.ENTER_PRESS);
651
623
  }
652
624
  // Need to review
653
625
  this.$emit('keyDown', event, this.triggerQuery);
@@ -683,16 +655,11 @@ var DataSearch = {
683
655
  }
684
656
  },
685
657
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
686
- var _this3 = this;
687
658
  var value = this.$props.value;
688
659
  // Record analytics for selected suggestions
689
660
  this.triggerClickAnalytics(suggestion._click_id);
690
661
  if (value === undefined) {
691
662
  this.setValue(suggestion.value, true, this.$props, configureStore.causes.SUGGESTION_SELECT);
692
- this.isSuggestionSelected = true;
693
- setTimeout(function () {
694
- _this3.isSuggestionSelected = false;
695
- }, 50);
696
663
  } else if (this.$options.isTagsMode) {
697
664
  var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
698
665
  if (this.selectedTags.includes(suggestion.value)) {
@@ -798,7 +765,7 @@ var DataSearch = {
798
765
  return null;
799
766
  },
800
767
  renderTag: function renderTag(item) {
801
- var _this4 = this;
768
+ var _this3 = this;
802
769
  var h = this.$createElement;
803
770
  var innerClass = this.$props.innerClass;
804
771
  return h(Tags.TagItem, {
@@ -811,7 +778,7 @@ var DataSearch = {
811
778
  "class": "close-icon",
812
779
  "on": {
813
780
  "click": function click() {
814
- return _this4.clearTag(item);
781
+ return _this3.clearTag(item);
815
782
  }
816
783
  }
817
784
  }, [h(CancelSvg.CancelSvg)])]);
@@ -833,7 +800,7 @@ var DataSearch = {
833
800
  }
834
801
  },
835
802
  renderTags: function renderTags() {
836
- var _this5 = this;
803
+ var _this4 = this;
837
804
  var h = this.$createElement;
838
805
  if (!Array.isArray(this.selectedTags)) {
839
806
  return null;
@@ -846,7 +813,7 @@ var DataSearch = {
846
813
  handleClear: this.clearTag,
847
814
  handleClearAll: this.clearAllTags
848
815
  }) : h(Tags.TagsContainer, [tagsList.map(function (item) {
849
- return _this5.renderTag(item);
816
+ return _this4.renderTag(item);
850
817
  }), shouldRenderClearAllTag && h(Tags.TagItem, {
851
818
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
852
819
  }, [h("span", ["Clear All"]), h("span", {
@@ -925,7 +892,7 @@ var DataSearch = {
925
892
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
926
893
  },
927
894
  listenForFocusShortcuts: function listenForFocusShortcuts() {
928
- var _this6 = this;
895
+ var _this5 = this;
929
896
  var _this$$props$focusSho = this.$props.focusShortcuts,
930
897
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
931
898
  if (index.isEmpty(focusShortcuts)) {
@@ -940,7 +907,7 @@ var DataSearch = {
940
907
  function (event, handler) {
941
908
  // Prevent the default refresh event under WINDOWS system
942
909
  event.preventDefault();
943
- _this6.focusSearchBox(event);
910
+ _this5.focusSearchBox(event);
944
911
  });
945
912
 
946
913
  // if one of modifier keys are used, they are handled below
@@ -950,7 +917,7 @@ var DataSearch = {
950
917
  for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
951
918
  var element = modifierKeys[index$1];
952
919
  if (hotkeys[element]) {
953
- _this6.focusSearchBox(event);
920
+ _this5.focusSearchBox(event);
954
921
  break;
955
922
  }
956
923
  }
@@ -958,7 +925,7 @@ var DataSearch = {
958
925
  }
959
926
  },
960
927
  render: function render() {
961
- var _this7 = this;
928
+ var _this6 = this;
962
929
  var h = arguments[0];
963
930
  var _this$$props6 = this.$props,
964
931
  theme = _this$$props6.theme,
@@ -993,14 +960,14 @@ var DataSearch = {
993
960
  highlightedIndex = _ref4.highlightedIndex,
994
961
  setHighlightedIndex = _ref4.setHighlightedIndex;
995
962
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
996
- return h("div", [_this7.hasCustomRenderer && _this7.getComponent({
963
+ return h("div", [_this6.hasCustomRenderer && _this6.getComponent({
997
964
  isOpen: isOpen,
998
965
  getItemProps: getItemProps,
999
966
  getItemEvents: getItemEvents,
1000
967
  highlightedIndex: highlightedIndex
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) {
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) {
1004
971
  return h("li", {
1005
972
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1006
973
  item: item
@@ -1010,15 +977,15 @@ var DataSearch = {
1010
977
  })),
1011
978
  "key": index + 1 + "-" + item.value,
1012
979
  "style": {
1013
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, index)
980
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, index)
1014
981
  }
1015
982
  }, [h(Tags.SuggestionItem, {
1016
983
  "attrs": {
1017
- "currentValue": _this7.currentValue,
984
+ "currentValue": _this6.currentValue,
1018
985
  "suggestion": item
1019
986
  }
1020
987
  })]);
1021
- }), _this7.defaultSearchSuggestions.map(function (sugg, index) {
988
+ }), _this6.defaultSearchSuggestions.map(function (sugg, index) {
1022
989
  return h("li", {
1023
990
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1024
991
  item: sugg
@@ -1026,9 +993,9 @@ var DataSearch = {
1026
993
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1027
994
  item: sugg
1028
995
  })),
1029
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
996
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1030
997
  "style": {
1031
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
998
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1032
999
  justifyContent: 'flex-start'
1033
1000
  }
1034
1001
  }, [h("div", {
@@ -1037,28 +1004,28 @@ var DataSearch = {
1037
1004
  }
1038
1005
  }, [sugg.source && sugg.source._recent_search && h(Tags.CustomSvg, {
1039
1006
  "attrs": {
1040
- "className": getClassName(_this7.$props.innerClass, 'recent-search-icon') || null,
1007
+ "className": getClassName(_this6.$props.innerClass, 'recent-search-icon') || null,
1041
1008
  "icon": recentSearchesIcon,
1042
1009
  "type": "recent-search-icon"
1043
1010
  }
1044
1011
  }), sugg.source && sugg.source._popular_suggestion && h(Tags.CustomSvg, {
1045
1012
  "attrs": {
1046
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1013
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1047
1014
  "icon": popularSearchesIcon,
1048
1015
  "type": "popular-search-icon"
1049
1016
  }
1050
1017
  })]), h(Tags.SuggestionItem, {
1051
1018
  "attrs": {
1052
- "currentValue": _this7.currentValue,
1019
+ "currentValue": _this6.currentValue,
1053
1020
  "suggestion": sugg
1054
1021
  }
1055
1022
  })]);
1056
- }), index.hasQuerySuggestionsRenderer(_this7) ? _this7.getComponent({
1023
+ }), index.hasQuerySuggestionsRenderer(_this6) ? _this6.getComponent({
1057
1024
  isOpen: isOpen,
1058
1025
  getItemProps: getItemProps,
1059
1026
  getItemEvents: getItemEvents,
1060
1027
  highlightedIndex: highlightedIndex
1061
- }, true) : _this7.topSuggestions.map(function (sugg, index) {
1028
+ }, true) : _this6.topSuggestions.map(function (sugg, index) {
1062
1029
  return h("li", {
1063
1030
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1064
1031
  item: sugg
@@ -1066,9 +1033,9 @@ var DataSearch = {
1066
1033
  "on": _rollupPluginBabelHelpers._extends({}, getItemEvents({
1067
1034
  item: sugg
1068
1035
  })),
1069
- "key": _this7.suggestionsList.length + index + 1 + "-" + sugg.value,
1036
+ "key": _this6.suggestionsList.length + index + 1 + "-" + sugg.value,
1070
1037
  "style": {
1071
- backgroundColor: _this7.getBackgroundColor(highlightedIndex, _this7.suggestionsList.length + index),
1038
+ backgroundColor: _this6.getBackgroundColor(highlightedIndex, _this6.suggestionsList.length + index),
1072
1039
  justifyContent: 'flex-start'
1073
1040
  }
1074
1041
  }, [h("div", {
@@ -1077,58 +1044,58 @@ var DataSearch = {
1077
1044
  }
1078
1045
  }, [h(Tags.CustomSvg, {
1079
1046
  "attrs": {
1080
- "className": getClassName(_this7.$props.innerClass, 'popular-search-icon') || null,
1047
+ "className": getClassName(_this6.$props.innerClass, 'popular-search-icon') || null,
1081
1048
  "icon": popularSearchesIcon,
1082
1049
  "type": "popular-search-icon"
1083
1050
  }
1084
1051
  })]), h(Tags.SuggestionItem, {
1085
1052
  "attrs": {
1086
- "currentValue": _this7.currentValue,
1053
+ "currentValue": _this6.currentValue,
1087
1054
  "suggestion": sugg
1088
1055
  }
1089
1056
  })]);
1090
- })]) : _this7.renderNoSuggestions(_this7.suggestionsList)]);
1057
+ })]) : _this6.renderNoSuggestions(_this6.suggestionsList)]);
1091
1058
  };
1092
1059
  return h("div", {
1093
1060
  "class": Input.suggestionsContainer
1094
- }, [h(Tags.InputGroup, [_this7.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1061
+ }, [h(Tags.InputGroup, [_this6.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1095
1062
  "attrs": {
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,
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,
1103
1070
  "autocomplete": "off"
1104
1071
  },
1105
- "ref": _this7.$props.innerRef,
1106
- "class": getClassName(_this7.$props.innerClass, 'input'),
1072
+ "ref": _this6.$props.innerRef,
1073
+ "class": getClassName(_this6.$props.innerClass, 'input'),
1107
1074
  "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
1108
- onInput: _this7.onInputChange,
1075
+ onInput: _this6.onInputChange,
1109
1076
  onBlur: function onBlur(e) {
1110
- _this7.$emit('blur', e, _this7.triggerQuery);
1077
+ _this6.$emit('blur', e, _this6.triggerQuery);
1111
1078
  },
1112
- onFocus: _this7.handleFocus,
1079
+ onFocus: _this6.handleFocus,
1113
1080
  onKeyPress: function onKeyPress(e) {
1114
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1115
- _this7.$emit('key-press', e, _this7.triggerQuery);
1081
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1082
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1116
1083
  },
1117
1084
  onKeyDown: function onKeyDown(e) {
1118
- return _this7.handleKeyDown(e, highlightedIndex);
1085
+ return _this6.handleKeyDown(e, highlightedIndex);
1119
1086
  },
1120
1087
  onKeyUp: function onKeyUp(e) {
1121
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1122
- _this7.$emit('key-up', e, _this7.triggerQuery);
1088
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1089
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1123
1090
  },
1124
1091
  onClick: function onClick() {
1125
1092
  setHighlightedIndex(null);
1126
1093
  }
1127
1094
  })),
1128
1095
  "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
1129
- 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
1130
1097
  }))
1131
- }), _this7.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this7.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this7.renderTags()]);
1098
+ }), _this6.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this6.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this6.renderTags()]);
1132
1099
  }
1133
1100
  }
1134
1101
  }) : h("div", {
@@ -1144,22 +1111,22 @@ var DataSearch = {
1144
1111
  },
1145
1112
  "on": _rollupPluginBabelHelpers._extends({}, {
1146
1113
  blur: function blur(e) {
1147
- _this7.$emit('blur', e, _this7.triggerQuery);
1114
+ _this6.$emit('blur', e, _this6.triggerQuery);
1148
1115
  },
1149
1116
  keypress: function keypress(e) {
1150
- _this7.$emit('keyPress', e, _this7.triggerQuery);
1151
- _this7.$emit('key-press', e, _this7.triggerQuery);
1117
+ _this6.$emit('keyPress', e, _this6.triggerQuery);
1118
+ _this6.$emit('key-press', e, _this6.triggerQuery);
1152
1119
  },
1153
1120
  input: this.onInputChange,
1154
1121
  focus: function focus(e) {
1155
- _this7.$emit('focus', e, _this7.triggerQuery);
1122
+ _this6.$emit('focus', e, _this6.triggerQuery);
1156
1123
  },
1157
1124
  keydown: function keydown(e) {
1158
- _this7.handleKeyDown(e, null);
1125
+ _this6.handleKeyDown(e, null);
1159
1126
  },
1160
1127
  keyup: function keyup(e) {
1161
- _this7.$emit('keyUp', e, _this7.triggerQuery);
1162
- _this7.$emit('key-up', e, _this7.triggerQuery);
1128
+ _this6.$emit('keyUp', e, _this6.triggerQuery);
1129
+ _this6.$emit('key-up', e, _this6.triggerQuery);
1163
1130
  }
1164
1131
  }),
1165
1132
  "domProps": _rollupPluginBabelHelpers._extends({}, {
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "1.36.1";
5
+ var version = "1.36.2";
6
6
 
7
7
  exports.default = version;