@appbaseio/reactivesearch-vue 1.35.2 → 1.35.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.
@@ -83,7 +83,8 @@ var SearchBox = {
83
83
  currentValue: '',
84
84
  selectedTags: [],
85
85
  isOpen: false,
86
- normalizedSuggestions: []
86
+ normalizedSuggestions: [],
87
+ isSuggestionSelected: false
87
88
  };
88
89
  this.internalComponent = props.componentId + "__internal";
89
90
  return this.__state;
@@ -283,7 +284,9 @@ var SearchBox = {
283
284
  if (this.$options.isTagsMode) {
284
285
  cause = configureStore.causes.SUGGESTION_SELECT;
285
286
  }
286
- this.setValue(newVal || '', true, this.$props, cause);
287
+ if (!this.isSuggestionSelected) {
288
+ this.setValue(newVal || '', true, this.$props, cause);
289
+ }
287
290
  }
288
291
  },
289
292
  focusShortcuts: function focusShortcuts() {
@@ -412,10 +415,11 @@ var SearchBox = {
412
415
  categoryValue = undefined;
413
416
  }
414
417
  var performUpdate = function performUpdate() {
418
+ var isTagAdded = false;
415
419
  if (_this.$options.isTagsMode && isEqual(value, _this.selectedTags)) {
416
420
  return;
417
421
  }
418
- if (_this.$options.isTagsMode && cause === configureStore.causes.SUGGESTION_SELECT) {
422
+ if (_this.$options.isTagsMode) {
419
423
  if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
420
424
  // check if value already present in selectedTags
421
425
  if (typeof value === 'string' && _this.selectedTags.includes(value)) {
@@ -424,14 +428,36 @@ var SearchBox = {
424
428
  }
425
429
  _this.selectedTags = [].concat(_this.selectedTags);
426
430
  if (typeof value === 'string' && !!value) {
427
- _this.selectedTags.push(value);
431
+ if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
432
+ _this.selectedTags.push(value);
433
+ isTagAdded = true;
434
+ } else if (!props.strictSelection) {
435
+ _this.selectedTags.push(value);
436
+ isTagAdded = true;
437
+ }
428
438
  } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
429
- _this.selectedTags = value;
439
+ if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
440
+ _this.selectedTags = value;
441
+ isTagAdded = true;
442
+ } else if (!props.strictSelection) {
443
+ _this.selectedTags.push(value);
444
+ isTagAdded = true;
445
+ }
430
446
  }
431
447
  } else if (value) {
432
- _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
448
+ if (props.strictSelection && cause === configureStore.causes.SUGGESTION_SELECT) {
449
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
450
+ isTagAdded = true;
451
+ } else if (!props.strictSelection) {
452
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
453
+ isTagAdded = true;
454
+ }
455
+ }
456
+ if (props.strictSelection && !isTagAdded) {
457
+ _this.currentValue = value;
458
+ } else {
459
+ _this.currentValue = '';
433
460
  }
434
- _this.currentValue = '';
435
461
  } else {
436
462
  _this.currentValue = index.decodeHtml(value);
437
463
  }
@@ -444,16 +470,22 @@ var SearchBox = {
444
470
  if (toggleIsOpen) {
445
471
  _this.isOpen = false;
446
472
  }
447
- if (typeof _this.currentValue === 'string') _this.triggerDefaultQuery(_this.currentValue);
473
+ if (typeof _this.currentValue === 'string') {
474
+ if (_this.$options.isTagsMode && props.strictSelection && isTagAdded) {
475
+ _this.triggerDefaultQuery(_this.currentValue);
476
+ } else if (!_this.$options.isTagsMode) {
477
+ _this.triggerDefaultQuery(_this.currentValue);
478
+ }
479
+ }
448
480
  } // in case of strict selection only SUGGESTION_SELECT should be able
449
481
  // to set the query otherwise the value should reset
450
- if (props.strictSelection) {
482
+ if (_this.$options.isTagsMode && props.strictSelection && isTagAdded) {
451
483
  if (cause === configureStore.causes.SUGGESTION_SELECT || (_this.$options.isTagsMode ? _this.selectedTags.length === 0 : value === '')) {
452
484
  _this.triggerCustomQuery(queryHandlerValue, _this.$options.isTagsMode ? undefined : categoryValue);
453
- } else {
485
+ } else if (!props.strictSelection) {
454
486
  _this.setValue('', true);
455
487
  }
456
- } else if (props.value === undefined || cause === configureStore.causes.SUGGESTION_SELECT || cause === configureStore.causes.CLEAR_VALUE) {
488
+ } else if (!_this.$options.isTagsMode && (props.value === undefined || cause === configureStore.causes.SUGGESTION_SELECT || cause === configureStore.causes.CLEAR_VALUE)) {
457
489
  _this.triggerCustomQuery(queryHandlerValue, _this.$options.isTagsMode ? undefined : categoryValue);
458
490
  }
459
491
  } else {
@@ -572,6 +604,7 @@ var SearchBox = {
572
604
  this.onValueSelectedHandler('', configureStore.causes.CLEAR_VALUE);
573
605
  },
574
606
  handleKeyDown: function handleKeyDown(event, highlightedIndex) {
607
+ var _this2 = this;
575
608
  if (highlightedIndex === void 0) {
576
609
  highlightedIndex = null;
577
610
  }
@@ -580,7 +613,11 @@ var SearchBox = {
580
613
  if (this.$props.autosuggest === false) {
581
614
  this.enterButtonOnClick();
582
615
  } else if (highlightedIndex === null) {
583
- this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? configureStore.causes.SUGGESTION_SELECT : undefined // to handle tags
616
+ this.isSuggestionSelected = true;
617
+ setTimeout(function () {
618
+ _this2.isSuggestionSelected = false;
619
+ }, 50);
620
+ this.setValue(event.target.value, true, this.$props, undefined // to handle tags
584
621
  );
585
622
 
586
623
  this.onValueSelectedHandler(event.target.value, configureStore.causes.ENTER_PRESS);
@@ -592,7 +629,7 @@ var SearchBox = {
592
629
  this.$emit('key-down', event, this.triggerQuery);
593
630
  },
594
631
  onInputChange: function onInputChange(e) {
595
- var _this2 = this;
632
+ var _this3 = this;
596
633
  var inputValue = e.target.value;
597
634
  if (!this.$data.isOpen && this.$props.autosuggest) {
598
635
  this.isOpen = true;
@@ -603,7 +640,7 @@ var SearchBox = {
603
640
  } else {
604
641
  this.$emit('change', inputValue, function (_ref3) {
605
642
  var isOpen = _ref3.isOpen;
606
- return _this2.triggerQuery({
643
+ return _this3.triggerQuery({
607
644
  defaultQuery: true,
608
645
  customQuery: true,
609
646
  value: inputValue,
@@ -613,7 +650,7 @@ var SearchBox = {
613
650
  }
614
651
  },
615
652
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
616
- var _this3 = this;
653
+ var _this4 = this;
617
654
  this.isOpen = false;
618
655
  var value = this.$props.value;
619
656
  // Record analytics for selected suggestions
@@ -634,10 +671,10 @@ var SearchBox = {
634
671
  this.setValue(emitValue, true, this.$props, configureStore.causes.SUGGESTION_SELECT, false, suggestion._category);
635
672
  this.$emit('change', emitValue, function (_ref4) {
636
673
  var isOpen = _ref4.isOpen;
637
- return _this3.triggerQuery(_rollupPluginBabelHelpers._extends({
674
+ return _this4.triggerQuery(_rollupPluginBabelHelpers._extends({
638
675
  isOpen: isOpen,
639
676
  value: emitValue
640
- }, !_this3.$options.isTagsMode && {
677
+ }, !_this4.$options.isTagsMode && {
641
678
  categoryValue: suggestion._category
642
679
  }));
643
680
  });
@@ -752,7 +789,7 @@ var SearchBox = {
752
789
  });
753
790
  },
754
791
  renderEnterButtonElement: function renderEnterButtonElement() {
755
- var _this4 = this;
792
+ var _this5 = this;
756
793
  var h = this.$createElement;
757
794
  var _this$$props4 = this.$props,
758
795
  enterButton = _this$$props4.enterButton,
@@ -761,7 +798,7 @@ var SearchBox = {
761
798
  if (enterButton) {
762
799
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
763
800
  if (renderEnterButton) {
764
- return renderEnterButton(_this4.enterButtonOnClick);
801
+ return renderEnterButton(_this5.enterButtonOnClick);
765
802
  }
766
803
  return h(Button.Button, {
767
804
  "class": "enter-btn " + getClassName(innerClass, 'enter-button'),
@@ -769,7 +806,7 @@ var SearchBox = {
769
806
  "primary": true
770
807
  },
771
808
  "on": {
772
- "click": _this4.enterButtonOnClick
809
+ "click": _this5.enterButtonOnClick
773
810
  }
774
811
  }, ["Search"]);
775
812
  };
@@ -836,7 +873,7 @@ var SearchBox = {
836
873
  (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs.focus(); // eslint-disable-line
837
874
  },
838
875
  listenForFocusShortcuts: function listenForFocusShortcuts() {
839
- var _this5 = this;
876
+ var _this6 = this;
840
877
  var _this$$props$focusSho = this.$props.focusShortcuts,
841
878
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
842
879
  if (index.isEmpty(focusShortcuts)) {
@@ -851,7 +888,7 @@ var SearchBox = {
851
888
  function (event, handler) {
852
889
  // Prevent the default refresh event under WINDOWS system
853
890
  event.preventDefault();
854
- _this5.focusSearchBox(event);
891
+ _this6.focusSearchBox(event);
855
892
  });
856
893
 
857
894
  // if one of modifier keys are used, they are handled below
@@ -861,7 +898,7 @@ var SearchBox = {
861
898
  for (var index$1 = 0; index$1 < modifierKeys.length; index$1 += 1) {
862
899
  var element = modifierKeys[index$1];
863
900
  if (hotkeys[element]) {
864
- _this5.focusSearchBox(event);
901
+ _this6.focusSearchBox(event);
865
902
  break;
866
903
  }
867
904
  }
@@ -874,11 +911,11 @@ var SearchBox = {
874
911
  this.triggerDefaultQuery(value);
875
912
  },
876
913
  renderAutoFill: function renderAutoFill(suggestion) {
877
- var _this6 = this;
914
+ var _this7 = this;
878
915
  var h = this.$createElement;
879
916
  var handleAutoFillClick = function handleAutoFillClick(e) {
880
917
  e.stopPropagation();
881
- _this6.onAutofillClick(suggestion);
918
+ _this7.onAutofillClick(suggestion);
882
919
  };
883
920
  /* 👇 avoid showing autofill for category suggestions👇 */
884
921
  return suggestion._category ? null : h(AutoFillSvg, {
@@ -888,7 +925,7 @@ var SearchBox = {
888
925
  });
889
926
  },
890
927
  renderTag: function renderTag(item) {
891
- var _this7 = this;
928
+ var _this8 = this;
892
929
  var h = this.$createElement;
893
930
  var innerClass = this.$props.innerClass;
894
931
  return h(Tags.TagItem, {
@@ -901,7 +938,7 @@ var SearchBox = {
901
938
  "class": "close-icon",
902
939
  "on": {
903
940
  "click": function click() {
904
- return _this7.clearTag(item);
941
+ return _this8.clearTag(item);
905
942
  }
906
943
  }
907
944
  }, [h(CancelSvg.CancelSvg)])]);
@@ -923,7 +960,7 @@ var SearchBox = {
923
960
  }
924
961
  },
925
962
  renderTags: function renderTags() {
926
- var _this8 = this;
963
+ var _this9 = this;
927
964
  var h = this.$createElement;
928
965
  if (!Array.isArray(this.selectedTags)) {
929
966
  return null;
@@ -936,7 +973,7 @@ var SearchBox = {
936
973
  handleClear: this.clearTag,
937
974
  handleClearAll: this.clearAllTags
938
975
  }) : h(Tags.TagsContainer, [tagsList.map(function (item) {
939
- return _this8.renderTag(item);
976
+ return _this9.renderTag(item);
940
977
  }), shouldRenderClearAllTag && h(Tags.TagItem, {
941
978
  "class": getClassName(this.$props.innerClass, 'selected-tag') || ''
942
979
  }, [h("span", ["Clear All"]), h("span", {
@@ -952,7 +989,7 @@ var SearchBox = {
952
989
  }
953
990
  },
954
991
  render: function render() {
955
- var _this9 = this;
992
+ var _this10 = this;
956
993
  var h = arguments[0];
957
994
  var _this$$props6 = this.$props,
958
995
  theme = _this$$props6.theme,
@@ -993,14 +1030,14 @@ var SearchBox = {
993
1030
  return null;
994
1031
  }
995
1032
  };
996
- return h("div", [_this9.hasCustomRenderer && _this9.getComponent({
1033
+ return h("div", [_this10.hasCustomRenderer && _this10.getComponent({
997
1034
  isOpen: isOpen,
998
1035
  getItemProps: getItemProps,
999
1036
  getItemEvents: getItemEvents,
1000
1037
  highlightedIndex: highlightedIndex
1001
- }), _this9.renderErrorComponent(), !_this9.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1002
- "class": Input.suggestions(_this9.themePreset, theme) + " " + getClassName(_this9.$props.innerClass, 'list')
1003
- }, [_this9.normalizedSuggestions.map(function (item, index) {
1038
+ }), _this10.renderErrorComponent(), !_this10.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1039
+ "class": Input.suggestions(_this10.themePreset, theme) + " " + getClassName(_this10.$props.innerClass, 'list')
1040
+ }, [_this10.normalizedSuggestions.map(function (item, index) {
1004
1041
  return renderItem ? h("li", {
1005
1042
  "domProps": _rollupPluginBabelHelpers._extends({}, getItemProps({
1006
1043
  item: item
@@ -1010,7 +1047,7 @@ var SearchBox = {
1010
1047
  })),
1011
1048
  "key": index + 1 + "-" + item.value,
1012
1049
  "style": {
1013
- backgroundColor: _this9.getBackgroundColor(highlightedIndex, index),
1050
+ backgroundColor: _this10.getBackgroundColor(highlightedIndex, index),
1014
1051
  justifyContent: 'flex-start',
1015
1052
  alignItems: 'center'
1016
1053
  }
@@ -1023,7 +1060,7 @@ var SearchBox = {
1023
1060
  })),
1024
1061
  "key": index + 1 + "-" + item.value,
1025
1062
  "style": {
1026
- backgroundColor: _this9.getBackgroundColor(highlightedIndex, index),
1063
+ backgroundColor: _this10.getBackgroundColor(highlightedIndex, index),
1027
1064
  justifyContent: 'flex-start',
1028
1065
  alignItems: 'center'
1029
1066
  }
@@ -1034,58 +1071,58 @@ var SearchBox = {
1034
1071
  }
1035
1072
  }, [h(Tags.CustomSvg, {
1036
1073
  "attrs": {
1037
- "className": getClassName(_this9.$props.innerClass, item._suggestion_type + "-search-icon") || null,
1074
+ "className": getClassName(_this10.$props.innerClass, item._suggestion_type + "-search-icon") || null,
1038
1075
  "icon": getIcon(item._suggestion_type),
1039
1076
  "type": item._suggestion_type + "-search-icon"
1040
1077
  }
1041
1078
  })]), h(Tags.SuggestionItem, {
1042
1079
  "attrs": {
1043
- "currentValue": _this9.currentValue,
1080
+ "currentValue": _this10.currentValue,
1044
1081
  "suggestion": item
1045
1082
  }
1046
- }), _this9.renderAutoFill(item)]);
1047
- })]) : _this9.renderNoSuggestions(_this9.normalizedSuggestions)]);
1083
+ }), _this10.renderAutoFill(item)]);
1084
+ })]) : _this10.renderNoSuggestions(_this10.normalizedSuggestions)]);
1048
1085
  };
1049
1086
  return h("div", {
1050
1087
  "class": Input.suggestionsContainer
1051
- }, [h(Tags.InputGroup, [_this9.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1088
+ }, [h(Tags.InputGroup, [_this10.renderInputAddonBefore(), h(CancelSvg.InputWrapper, [h(Input.Input, {
1052
1089
  "attrs": {
1053
- "id": _this9.$props.componentId + "-input",
1054
- "showIcon": _this9.$props.showIcon,
1055
- "showClear": _this9.$props.showClear,
1056
- "iconPosition": _this9.$props.iconPosition,
1057
- "placeholder": _this9.$props.placeholder,
1058
- "autoFocus": _this9.$props.autoFocus,
1059
- "themePreset": _this9.themePreset,
1090
+ "id": _this10.$props.componentId + "-input",
1091
+ "showIcon": _this10.$props.showIcon,
1092
+ "showClear": _this10.$props.showClear,
1093
+ "iconPosition": _this10.$props.iconPosition,
1094
+ "placeholder": _this10.$props.placeholder,
1095
+ "autoFocus": _this10.$props.autoFocus,
1096
+ "themePreset": _this10.themePreset,
1060
1097
  "autocomplete": "off"
1061
1098
  },
1062
- "ref": _this9.$props.innerRef,
1063
- "class": getClassName(_this9.$props.innerClass, 'input'),
1099
+ "ref": _this10.$props.innerRef,
1100
+ "class": getClassName(_this10.$props.innerClass, 'input'),
1064
1101
  "on": _rollupPluginBabelHelpers._extends({}, getInputEvents({
1065
- onInput: _this9.onInputChange,
1102
+ onInput: _this10.onInputChange,
1066
1103
  onBlur: function onBlur(e) {
1067
- _this9.$emit('blur', e, _this9.triggerQuery);
1104
+ _this10.$emit('blur', e, _this10.triggerQuery);
1068
1105
  },
1069
- onFocus: _this9.handleFocus,
1106
+ onFocus: _this10.handleFocus,
1070
1107
  onKeyPress: function onKeyPress(e) {
1071
- _this9.$emit('keyPress', e, _this9.triggerQuery);
1072
- _this9.$emit('key-press', e, _this9.triggerQuery);
1108
+ _this10.$emit('keyPress', e, _this10.triggerQuery);
1109
+ _this10.$emit('key-press', e, _this10.triggerQuery);
1073
1110
  },
1074
1111
  onKeyDown: function onKeyDown(e) {
1075
- return _this9.handleKeyDown(e, highlightedIndex);
1112
+ return _this10.handleKeyDown(e, highlightedIndex);
1076
1113
  },
1077
1114
  onKeyUp: function onKeyUp(e) {
1078
- _this9.$emit('keyUp', e, _this9.triggerQuery);
1079
- _this9.$emit('key-up', e, _this9.triggerQuery);
1115
+ _this10.$emit('keyUp', e, _this10.triggerQuery);
1116
+ _this10.$emit('key-up', e, _this10.triggerQuery);
1080
1117
  },
1081
1118
  onClick: function onClick() {
1082
1119
  setHighlightedIndex(null);
1083
1120
  }
1084
1121
  })),
1085
1122
  "domProps": _rollupPluginBabelHelpers._extends({}, getInputProps({
1086
- value: _this9.$data.currentValue === null ? '' : _this9.$data.currentValue
1123
+ value: _this10.$data.currentValue === null ? '' : _this10.$data.currentValue
1087
1124
  }))
1088
- }), _this9.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()]), _this9.renderInputAddonAfter(), _this9.renderEnterButtonElement()]), expandSuggestionsContainer && renderSuggestionsDropdown(), _this9.renderTags()]);
1125
+ }), _this10.renderIcons(), !expandSuggestionsContainer && renderSuggestionsDropdown()]), _this10.renderInputAddonAfter(), _this10.renderEnterButtonElement()]), expandSuggestionsContainer && renderSuggestionsDropdown(), _this10.renderTags()]);
1089
1126
  }
1090
1127
  }
1091
1128
  }) : h("div", {
@@ -1101,20 +1138,20 @@ var SearchBox = {
1101
1138
  },
1102
1139
  "on": _rollupPluginBabelHelpers._extends({}, {
1103
1140
  blur: function blur(e) {
1104
- _this9.$emit('blur', e, _this9.triggerQuery);
1141
+ _this10.$emit('blur', e, _this10.triggerQuery);
1105
1142
  },
1106
1143
  keypress: function keypress(e) {
1107
- _this9.$emit('keyPress', e, _this9.triggerQuery);
1108
- _this9.$emit('key-press', e, _this9.triggerQuery);
1144
+ _this10.$emit('keyPress', e, _this10.triggerQuery);
1145
+ _this10.$emit('key-press', e, _this10.triggerQuery);
1109
1146
  },
1110
1147
  input: this.onInputChange,
1111
1148
  focus: function focus(e) {
1112
- _this9.$emit('focus', e, _this9.triggerQuery);
1149
+ _this10.$emit('focus', e, _this10.triggerQuery);
1113
1150
  },
1114
1151
  keydown: this.handleKeyDown,
1115
1152
  keyup: function keyup(e) {
1116
- _this9.$emit('keyUp', e, _this9.triggerQuery);
1117
- _this9.$emit('key-up', e, _this9.triggerQuery);
1153
+ _this10.$emit('keyUp', e, _this10.triggerQuery);
1154
+ _this10.$emit('key-up', e, _this10.triggerQuery);
1118
1155
  }
1119
1156
  }),
1120
1157
  "domProps": _rollupPluginBabelHelpers._extends({}, {
@@ -31,7 +31,7 @@ require('./Input-ead4cd84.js');
31
31
  require('compute-scroll-into-view');
32
32
  require('./Container-e699ea95.js');
33
33
  require('vue-highlight-words');
34
- var ReactiveComponentPrivate = require('./ReactiveComponentPrivate-1f2d132b.js');
34
+ var ReactiveComponentPrivate = require('./ReactiveComponentPrivate-b7df895b.js');
35
35
  require('@appbaseio/reactivecore/lib/utils/suggestions');
36
36
  require('./FormControlList-bbb5cd24.js');
37
37
  require('./utils-83fd01e9.js');
package/dist/cjs/index.js CHANGED
@@ -37,7 +37,7 @@ require('compute-scroll-into-view');
37
37
  require('./Container-e699ea95.js');
38
38
  require('vue-highlight-words');
39
39
  var DataSearch = require('./DataSearch.js');
40
- var ReactiveComponentPrivate = require('./ReactiveComponentPrivate-1f2d132b.js');
40
+ var ReactiveComponentPrivate = require('./ReactiveComponentPrivate-b7df895b.js');
41
41
  require('@appbaseio/reactivecore/lib/utils/suggestions');
42
42
  require('./FormControlList-bbb5cd24.js');
43
43
  require('./utils-83fd01e9.js');
@@ -37,7 +37,7 @@ require('compute-scroll-into-view');
37
37
  require('./Container-e699ea95.js');
38
38
  require('vue-highlight-words');
39
39
  var DataSearch = require('./DataSearch.js');
40
- var ReactiveComponentPrivate = require('./ReactiveComponentPrivate-1f2d132b.js');
40
+ var ReactiveComponentPrivate = require('./ReactiveComponentPrivate-b7df895b.js');
41
41
  require('@appbaseio/reactivecore/lib/utils/suggestions');
42
42
  require('./FormControlList-bbb5cd24.js');
43
43
  require('./utils-83fd01e9.js');
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "1.35.2";
5
+ var version = "1.35.3";
6
6
 
7
7
  exports.default = version;