@appbaseio/reactivesearch-vue 1.29.0 → 1.30.0

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.
Files changed (83) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +1238 -545
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{Button-e0b7c1f6.js → Button-0e2e2c02.js} +1 -1
  6. package/dist/cjs/{CancelSvg-4aa35935.js → CancelSvg-c48c1085.js} +1 -1
  7. package/dist/cjs/{Card-fd94ef07.js → Card-4fa0f769.js} +2 -2
  8. package/dist/cjs/{ComponentWrapper-10bad289.js → ComponentWrapper-5cb08414.js} +2 -2
  9. package/dist/cjs/{Container-526efa6a.js → Container-cfd69a34.js} +1 -1
  10. package/dist/cjs/{DataSearch-eec21890.js → DataSearch-e550096e.js} +234 -83
  11. package/dist/cjs/DataSearch.js +9 -9
  12. package/dist/cjs/{DropDown-e4381fcc.js → DropDown-fc59f1ee.js} +4 -4
  13. package/dist/cjs/DynamicRangeSlider.js +5 -5
  14. package/dist/cjs/{Flex-f146cdad.js → Flex-63774e4d.js} +1 -1
  15. package/dist/cjs/{FormControlList-808dbcef.js → FormControlList-a9c64bb8.js} +1 -1
  16. package/dist/cjs/{Input-0d7b25ad.js → Input-43868594.js} +1 -1
  17. package/dist/cjs/{ListItem-b40adb04.js → ListItem-38962297.js} +2 -2
  18. package/dist/cjs/MultiDropdownList.js +10 -10
  19. package/dist/cjs/MultiList.js +8 -8
  20. package/dist/cjs/MultiRange.js +6 -6
  21. package/dist/cjs/RangeInput.js +8 -8
  22. package/dist/cjs/RangeSlider.js +6 -6
  23. package/dist/cjs/ReactiveBase.js +34 -24
  24. package/dist/cjs/ReactiveComponent.js +3 -3
  25. package/dist/cjs/ReactiveList.js +9 -8
  26. package/dist/cjs/ResultCard.js +3 -3
  27. package/dist/cjs/ResultList.js +3 -3
  28. package/dist/cjs/SelectedFilters.js +44 -27
  29. package/dist/cjs/SingleDropdownList.js +10 -10
  30. package/dist/cjs/SingleList.js +8 -8
  31. package/dist/cjs/SingleRange.js +7 -7
  32. package/dist/cjs/StateProvider.js +30 -5
  33. package/dist/cjs/{Title-584a8cc8.js → Title-26661936.js} +1 -1
  34. package/dist/cjs/ToggleButton.js +7 -6
  35. package/dist/cjs/{_rollupPluginBabelHelpers-f127c8b7.js → _rollupPluginBabelHelpers-91d4b5a6.js} +1 -2
  36. package/dist/cjs/{index-4509aa45.js → index-2cd3650b.js} +1 -1
  37. package/dist/cjs/index.js +18 -17
  38. package/dist/cjs/initReactivesearch.js +2 -2
  39. package/dist/cjs/{install-4886582d.js → install-250a14f1.js} +246 -83
  40. package/dist/cjs/install.js +18 -17
  41. package/dist/cjs/{ssr-0ee35a09.js → ssr-949cafb5.js} +1 -1
  42. package/dist/cjs/{utils-1219e1fe.js → utils-0df3cb93.js} +1 -1
  43. package/dist/cjs/version.js +1 -1
  44. package/dist/es/{Button-33de88e6.js → Button-e18ad90f.js} +1 -1
  45. package/dist/es/{CancelSvg-c2c03a35.js → CancelSvg-e3b33cdd.js} +1 -1
  46. package/dist/es/{Card-6446f1b7.js → Card-ad6ba09f.js} +2 -2
  47. package/dist/es/{ComponentWrapper-0f3431d1.js → ComponentWrapper-dc92772a.js} +2 -2
  48. package/dist/es/{Container-18b03fde.js → Container-421450dc.js} +1 -1
  49. package/dist/es/{DataSearch-42f547cd.js → DataSearch-8e5d0972.js} +234 -85
  50. package/dist/es/DataSearch.js +9 -9
  51. package/dist/es/{DropDown-ff6ad982.js → DropDown-565fad6f.js} +4 -4
  52. package/dist/es/DynamicRangeSlider.js +5 -5
  53. package/dist/es/{Flex-8770345d.js → Flex-09d40927.js} +1 -1
  54. package/dist/es/{FormControlList-704f8dee.js → FormControlList-38ffe3d3.js} +1 -1
  55. package/dist/es/{Input-e339e63a.js → Input-c9d757bc.js} +1 -1
  56. package/dist/es/{ListItem-8e8fb535.js → ListItem-41d6ddd7.js} +2 -2
  57. package/dist/es/MultiDropdownList.js +10 -10
  58. package/dist/es/MultiList.js +8 -8
  59. package/dist/es/MultiRange.js +6 -6
  60. package/dist/es/RangeInput.js +8 -8
  61. package/dist/es/RangeSlider.js +6 -6
  62. package/dist/es/ReactiveBase.js +34 -24
  63. package/dist/es/ReactiveComponent.js +3 -3
  64. package/dist/es/ReactiveList.js +9 -8
  65. package/dist/es/ResultCard.js +3 -3
  66. package/dist/es/ResultList.js +3 -3
  67. package/dist/es/SelectedFilters.js +44 -27
  68. package/dist/es/SingleDropdownList.js +10 -10
  69. package/dist/es/SingleList.js +8 -8
  70. package/dist/es/SingleRange.js +7 -7
  71. package/dist/es/StateProvider.js +30 -5
  72. package/dist/es/{Title-3522ff56.js → Title-35edd732.js} +1 -1
  73. package/dist/es/ToggleButton.js +7 -6
  74. package/dist/es/{_rollupPluginBabelHelpers-0f24d612.js → _rollupPluginBabelHelpers-51ce1182.js} +1 -2
  75. package/dist/es/{index-78920565.js → index-5371a13f.js} +1 -1
  76. package/dist/es/index.js +19 -18
  77. package/dist/es/initReactivesearch.js +2 -2
  78. package/dist/es/{install-54ebd72e.js → install-9faa87f1.js} +247 -84
  79. package/dist/es/install.js +18 -17
  80. package/dist/es/{ssr-a41dfea9.js → ssr-ad57b0ad.js} +1 -1
  81. package/dist/es/{utils-64a2e5f0.js → utils-9b45e0ab.js} +1 -1
  82. package/dist/es/version.js +1 -1
  83. package/package.json +3 -3
@@ -1,8 +1,8 @@
1
- import { _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-0f24d612.js';
1
+ import { _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-51ce1182.js';
2
2
  import { css } from 'emotion';
3
3
  import styled from '@appbaseio/vue-emotion';
4
4
  import { lighten } from 'polished';
5
- import './Title-3522ff56.js';
5
+ import './Title-35edd732.js';
6
6
 
7
7
  var _templateObject, _templateObject2, _templateObject3;
8
8
  var container = css(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: row;\n\tjustify-content: center;\n\tflex-wrap: wrap;\n\tmargin: 0 -8px;\n\n\t@media (max-width: 420px) {\n\t\tmargin: 0;\n\t}\n"])));
@@ -1,9 +1,9 @@
1
1
  import { Actions, helper } from '@appbaseio/reactivecore';
2
- import { a as _extends } from './_rollupPluginBabelHelpers-0f24d612.js';
2
+ import { a as _extends } from './_rollupPluginBabelHelpers-51ce1182.js';
3
3
  import VueTypes from 'vue-types';
4
4
  import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
5
5
  import { getInternalComponentID } from '@appbaseio/reactivecore/lib/utils/transform';
6
- import { c as connect, b as getCamelCase, d as getValidPropsKeys } from './index-78920565.js';
6
+ import { c as connect, b as getCamelCase, d as getValidPropsKeys } from './index-5371a13f.js';
7
7
 
8
8
  var addComponent = Actions.addComponent,
9
9
  removeComponent = Actions.removeComponent,
@@ -1,4 +1,4 @@
1
- import { _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-0f24d612.js';
1
+ import { _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-51ce1182.js';
2
2
  import styled from '@appbaseio/vue-emotion';
3
3
 
4
4
  var _templateObject;
@@ -1,18 +1,18 @@
1
1
  import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-0f24d612.js';
2
+ import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-51ce1182.js';
3
3
  import VueTypes from 'vue-types';
4
- import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
4
+ import { SEARCH_COMPONENTS_MODES, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
5
5
  import { getQueryOptions } from '@appbaseio/reactivecore/lib/utils/helper';
6
6
  import styled, { css, cx, injectGlobal } from '@appbaseio/vue-emotion';
7
7
  import { t as types } from './vueTypes-687b2304.js';
8
- import { g as getComponent, h as hasCustomRenderer, f as updateCustomQuery, u as updateDefaultQuery, i as isQueryIdentical, j as getQuerySuggestionsComponent, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, m as hasQuerySuggestionsRenderer, c as connect } from './index-78920565.js';
9
- import { C as ComponentWrapper } from './ComponentWrapper-0f3431d1.js';
10
- import { T as Title } from './Title-3522ff56.js';
11
- import { F as Flex } from './Flex-8770345d.js';
8
+ import { g as getComponent, h as hasCustomRenderer, f as updateCustomQuery, u as updateDefaultQuery, i as isQueryIdentical, j as getQuerySuggestionsComponent, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, m as hasQuerySuggestionsRenderer, c as connect } from './index-5371a13f.js';
9
+ import { C as ComponentWrapper } from './ComponentWrapper-dc92772a.js';
10
+ import { T as Title } from './Title-35edd732.js';
11
+ import { F as Flex } from './Flex-09d40927.js';
12
12
  import hotkeys from 'hotkeys-js';
13
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './CancelSvg-c2c03a35.js';
14
- import { n as noSuggestions, s as suggestionsContainer, I as Input, a as suggestions } from './Input-e339e63a.js';
15
- import { C as Container } from './Container-18b03fde.js';
13
+ import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './CancelSvg-e3b33cdd.js';
14
+ import { n as noSuggestions, s as suggestionsContainer, I as Input, a as suggestions } from './Input-c9d757bc.js';
15
+ import { C as Container } from './Container-421450dc.js';
16
16
  import Highlight from 'vue-highlight-words';
17
17
 
18
18
  var _templateObject;
@@ -898,6 +898,10 @@ var CustomSvg = {
898
898
  }
899
899
  };
900
900
 
901
+ var _templateObject$6, _templateObject2;
902
+ var TagsContainer = styled('div')(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tmargin-top: 10px;\n\twidth: 100%;\n"])));
903
+ var TagItem = styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\tcursor: default;\n\tbox-sizing: border-box;\n\tmargin: 0 4px 4px 0;\n\tcolor: #000000d9;\n\tfont-size: 14px;\n\tfont-variant: tabular-nums;\n\tline-height: 1.5715;\n\tlist-style: none;\n\tfont-feature-settings: 'tnum';\n\tdisplay: inline-block;\n\theight: auto;\n\tpadding: 0 2px 0 7px;\n\tfont-size: 12px;\n\tline-height: 22px;\n\twhite-space: nowrap;\n\tbackground: #fafafa;\n\tborder: 1px solid #d9d9d9;\n\tborder-radius: 2px;\n\topacity: 1;\n\ttransition: all 0.3s;\n\n\tspan.close-icon {\n\t\tsvg {\n\t\t\tcursor: pointer;\n\t\t\theight: 15px;\n\t\t\tposition: relative;\n\t\t\ttop: 4px;\n\t\t\tfill: #262626;\n\t\t}\n\t}\n"])));
904
+
901
905
  var updateQuery = Actions.updateQuery,
902
906
  setQueryOptions = Actions.setQueryOptions,
903
907
  setCustomQuery = Actions.setCustomQuery,
@@ -905,7 +909,8 @@ var updateQuery = Actions.updateQuery,
905
909
  setCustomHighlightOptions = Actions.setCustomHighlightOptions,
906
910
  recordSuggestionClick = Actions.recordSuggestionClick,
907
911
  loadPopularSuggestions = Actions.loadPopularSuggestions,
908
- getRecentSearches = Actions.getRecentSearches;
912
+ getRecentSearches = Actions.getRecentSearches,
913
+ resetStoreForComponent = Actions.resetStoreForComponent;
909
914
  var debounce = helper.debounce,
910
915
  checkValueChange = helper.checkValueChange,
911
916
  getClassName$1 = helper.getClassName,
@@ -920,10 +925,12 @@ var debounce = helper.debounce,
920
925
  normalizeDataField = helper.normalizeDataField;
921
926
  var DataSearch = {
922
927
  name: 'DataSearch',
928
+ isTagsMode: false,
923
929
  data: function data() {
924
930
  var props = this.$props;
925
931
  this.__state = {
926
932
  currentValue: '',
933
+ selectedTags: [],
927
934
  isOpen: false,
928
935
  normalizedSuggestions: [],
929
936
  isPending: false
@@ -943,7 +950,13 @@ var DataSearch = {
943
950
  enableRecentSearches = _this$$props.enableRecentSearches,
944
951
  distinctField = _this$$props.distinctField,
945
952
  distinctFieldConfig = _this$$props.distinctFieldConfig,
946
- index = _this$$props.index; // TODO: Remove in 2.0
953
+ index = _this$$props.index,
954
+ mode = _this$$props.mode;
955
+
956
+ if (mode === SEARCH_COMPONENTS_MODES.TAG) {
957
+ this.$options.isTagsMode = true;
958
+ } // TODO: Remove in 2.0
959
+
947
960
 
948
961
  if (enableQuerySuggestions) {
949
962
  console.warn('Warning(ReactiveSearch): The `enableQuerySuggestions` prop has been marked as deprecated, please use the `enablePopularSuggestions` prop instead.');
@@ -966,7 +979,12 @@ var DataSearch = {
966
979
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
967
980
  }
968
981
 
969
- this.currentValue = this.selectedValue || '';
982
+ this.currentValue = '';
983
+
984
+ if (this.$options.isTagsMode) {
985
+ this.currentValue = '';
986
+ }
987
+
970
988
  var shouldFetchInitialSuggestions = this.$props.enableDefaultSuggestions || this.currentValue;
971
989
 
972
990
  if (shouldFetchInitialSuggestions) {
@@ -1060,7 +1078,7 @@ var DataSearch = {
1060
1078
  debounce: VueTypes.number.def(0),
1061
1079
  defaultValue: types.string,
1062
1080
  excludeFields: types.excludeFields,
1063
- value: types.value,
1081
+ value: VueTypes.oneOfType([VueTypes.arrayOf(VueTypes.string), types.value]),
1064
1082
  defaultSuggestions: types.suggestions,
1065
1083
  enableSynonyms: VueTypes.bool.def(true),
1066
1084
  enableQuerySuggestions: VueTypes.bool.def(false),
@@ -1109,7 +1127,9 @@ var DataSearch = {
1109
1127
  addonAfter: VueTypes.any,
1110
1128
  expandSuggestionsContainer: VueTypes.bool.def(true),
1111
1129
  index: VueTypes.string,
1112
- enableDefaultSuggestions: VueTypes.bool.def(true)
1130
+ enableDefaultSuggestions: VueTypes.bool.def(true),
1131
+ mode: VueTypes.oneOf(['select', 'tag']).def('select'),
1132
+ renderSelectedTags: VueTypes.any
1113
1133
  },
1114
1134
  beforeMount: function beforeMount() {
1115
1135
  if (this.$props.highlight) {
@@ -1126,11 +1146,11 @@ var DataSearch = {
1126
1146
  }
1127
1147
 
1128
1148
  if (this.selectedValue) {
1129
- this.setValue(this.selectedValue, true);
1149
+ this.setValue(this.selectedValue, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
1130
1150
  } else if (this.$props.value) {
1131
- this.setValue(this.$props.value, true);
1151
+ this.setValue(this.$props.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
1132
1152
  } else if (this.$props.defaultValue) {
1133
- this.setValue(this.$props.defaultValue, true);
1153
+ this.setValue(this.$props.defaultValue, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
1134
1154
  }
1135
1155
  },
1136
1156
  mounted: function mounted() {
@@ -1142,19 +1162,19 @@ var DataSearch = {
1142
1162
  },
1143
1163
  dataField: function dataField() {
1144
1164
  this.updateQueryOptions();
1145
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1165
+ this.updateQueryHandler(this.$props.componentId, this.$options.isTagsMode ? this.$data.selectedTags : this.$data.currentValue, this.$props);
1146
1166
  },
1147
1167
  highlightField: function highlightField() {
1148
1168
  this.updateQueryOptions();
1149
1169
  },
1150
1170
  fieldWeights: function fieldWeights() {
1151
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1171
+ this.updateQueryHandler(this.$props.componentId, this.$options.isTagsMode ? this.$data.selectedTags : this.$data.currentValue, this.$props);
1152
1172
  },
1153
1173
  fuzziness: function fuzziness() {
1154
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1174
+ this.updateQueryHandler(this.$props.componentId, this.$options.isTagsMode ? this.$data.selectedTags : this.$data.currentValue, this.$props);
1155
1175
  },
1156
1176
  queryFormat: function queryFormat() {
1157
- this.updateQueryHandler(this.$props.componentId, this.$data.currentValue, this.$props);
1177
+ this.updateQueryHandler(this.$props.componentId, this.$options.isTagsMode ? this.$data.selectedTags : this.$data.currentValue, this.$props);
1158
1178
  },
1159
1179
  defaultValue: function defaultValue(newVal) {
1160
1180
  this.setValue(newVal, true, this.$props);
@@ -1183,13 +1203,18 @@ var DataSearch = {
1183
1203
  }
1184
1204
  },
1185
1205
  selectedValue: function selectedValue(newVal, oldVal) {
1186
- if (oldVal !== newVal && this.$data.currentValue !== newVal) {
1206
+ if (!isEqual(newVal, oldVal) && (this.$options.isTagsMode ? !isEqual(this.$data.selectedTags, newVal) : this.$data.currentValue !== newVal)) {
1187
1207
  if (!newVal && this.$data.currentValue) {
1188
1208
  // selected value is cleared, call onValueSelected
1189
1209
  this.onValueSelectedHandler('', causes.CLEAR_VALUE);
1190
1210
  }
1191
1211
 
1192
- this.setValue(newVal || '', true, this.$props);
1212
+ if (this.$options.isTagsMode) {
1213
+ // handling reset of tags through SelectedFilters or URL
1214
+ this.selectedTags = [];
1215
+ }
1216
+
1217
+ this.setValue(newVal || '', true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined);
1193
1218
  }
1194
1219
  },
1195
1220
  focusShortcuts: function focusShortcuts() {
@@ -1316,12 +1341,47 @@ var DataSearch = {
1316
1341
  }
1317
1342
 
1318
1343
  var performUpdate = function performUpdate() {
1319
- // Refresh recent searches when value becomes empty
1320
- if (!value && _this.currentValue && _this.enableRecentSearches) {
1344
+ if (_this.$options.isTagsMode && isEqual(value, _this.selectedTags)) {
1345
+ return;
1346
+ } // Refresh recent searches when value becomes empty
1347
+
1348
+
1349
+ if (!value && props.enableDefaultSuggestions === false) {
1350
+ _this.resetStoreForComponent(props.componentId);
1351
+ } else if (!value && _this.currentValue && _this.enableRecentSearches) {
1321
1352
  _this.getRecentSearches();
1322
1353
  }
1323
1354
 
1324
- _this.currentValue = value;
1355
+ if (_this.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1356
+ if (Array.isArray(_this.selectedTags) && _this.selectedTags.length) {
1357
+ // check if value already present in selectedTags
1358
+ if (typeof value === 'string' && _this.selectedTags.includes(value)) {
1359
+ _this.isOpen = false;
1360
+ return;
1361
+ }
1362
+
1363
+ _this.selectedTags = [].concat(_this.selectedTags);
1364
+
1365
+ if (typeof value === 'string' && !!value) {
1366
+ _this.selectedTags.push(value);
1367
+ } else if (Array.isArray(value) && !isEqual(_this.selectedTags, value)) {
1368
+ var mergedArray = Array.from(new Set([].concat(_this.selectedTags, value)));
1369
+ _this.selectedTags = mergedArray;
1370
+ }
1371
+ } else if (value) {
1372
+ _this.selectedTags = typeof value !== 'string' ? value : [].concat(value);
1373
+ }
1374
+
1375
+ _this.currentValue = '';
1376
+ } else {
1377
+ _this.currentValue = value;
1378
+ }
1379
+
1380
+ var queryHandlerValue = value;
1381
+
1382
+ if (_this.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
1383
+ queryHandlerValue = Array.isArray(_this.selectedTags) && _this.selectedTags.length ? _this.selectedTags : undefined;
1384
+ }
1325
1385
 
1326
1386
  if (isDefaultValue) {
1327
1387
  if (_this.$props.autosuggest) {
@@ -1329,19 +1389,19 @@ var DataSearch = {
1329
1389
  _this.isOpen = false;
1330
1390
  }
1331
1391
 
1332
- _this.updateDefaultQueryHandler(value, _this.$props);
1392
+ if (typeof value === 'string') _this.updateDefaultQueryHandler(value, _this.$props);
1333
1393
  } // in case of strict selection only SUGGESTION_SELECT should be able
1334
1394
  // to set the query otherwise the value should reset
1335
1395
 
1336
1396
 
1337
1397
  if (props.strictSelection) {
1338
- if (cause === causes.SUGGESTION_SELECT || value === '') {
1339
- _this.updateQueryHandler(props.componentId, value, props);
1398
+ if (cause === causes.SUGGESTION_SELECT || (_this.$options.isTagsMode ? _this.selectedTags.length === 0 : value === '')) {
1399
+ _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
1340
1400
  } else {
1341
1401
  _this.setValue('', true);
1342
1402
  }
1343
1403
  } else {
1344
- _this.updateQueryHandler(props.componentId, value, props);
1404
+ _this.updateQueryHandler(props.componentId, queryHandlerValue, props);
1345
1405
  }
1346
1406
  } else {
1347
1407
  // debounce for handling text while typing
@@ -1368,6 +1428,12 @@ var DataSearch = {
1368
1428
  checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1369
1429
  },
1370
1430
  updateDefaultQueryHandler: function updateDefaultQueryHandler(value, props) {
1431
+ if (!value && props.enableDefaultSuggestions === false) {
1432
+ // clear Component data from store
1433
+ this.resetStoreForComponent(props.componentId);
1434
+ return;
1435
+ }
1436
+
1371
1437
  var defaultQueryOptions;
1372
1438
  var query = DataSearch.defaultQuery(value, props);
1373
1439
 
@@ -1481,7 +1547,8 @@ var DataSearch = {
1481
1547
 
1482
1548
 
1483
1549
  if (event.key === 'Enter' && highlightedIndex === null) {
1484
- this.setValue(event.target.value, true);
1550
+ this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined // to handle tags
1551
+ );
1485
1552
  this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
1486
1553
  } // Need to review
1487
1554
 
@@ -1512,11 +1579,23 @@ var DataSearch = {
1512
1579
 
1513
1580
  if (value === undefined) {
1514
1581
  this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT);
1582
+ } else if (this.$options.isTagsMode) {
1583
+ var emitValue = Array.isArray(this.selectedTags) ? [].concat(this.selectedTags) : [];
1584
+
1585
+ if (this.selectedTags.includes(suggestion.value)) {
1586
+ // avoid duplicates in tags array
1587
+ this.isOpen = false;
1588
+ return;
1589
+ }
1590
+
1591
+ emitValue.push(suggestion.value);
1592
+ this.setValue(emitValue, true, this.$props, causes.SUGGESTION_SELECT, true);
1593
+ this.$emit('change', emitValue, this.triggerQuery);
1515
1594
  } else {
1516
- this.isPending = false;
1517
1595
  this.$emit('change', suggestion.value, this.triggerQuery);
1518
1596
  }
1519
1597
 
1598
+ this.isPending = false;
1520
1599
  this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
1521
1600
  },
1522
1601
  onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
@@ -1622,6 +1701,75 @@ var DataSearch = {
1622
1701
 
1623
1702
  return null;
1624
1703
  },
1704
+ renderTag: function renderTag(item) {
1705
+ var _this2 = this;
1706
+
1707
+ var h = this.$createElement;
1708
+ var innerClass = this.$props.innerClass;
1709
+ return h(TagItem, {
1710
+ "class": getClassName$1(innerClass, 'selected-tag') || ''
1711
+ }, [h("span", [item]), h("span", {
1712
+ "attrs": {
1713
+ "role": "img",
1714
+ "aria-label": "delete-tag"
1715
+ },
1716
+ "class": "close-icon",
1717
+ "on": {
1718
+ "click": function click() {
1719
+ return _this2.clearTag(item);
1720
+ }
1721
+ }
1722
+ }, [h(CancelSvg)])]);
1723
+ },
1724
+ clearAllTags: function clearAllTags() {
1725
+ this.selectedTags = [];
1726
+ this.setValue('', true, this.$props, causes.SUGGESTION_SELECT);
1727
+
1728
+ if (this.$props.value !== undefined) {
1729
+ this.$emit('change', this.selectedTags, this.triggerQuery);
1730
+ }
1731
+ },
1732
+ clearTag: function clearTag(tagValue) {
1733
+ this.selectedTags = [].concat(this.selectedTags.filter(function (tag) {
1734
+ return tag !== tagValue;
1735
+ }));
1736
+ this.setValue('', true, this.$props, causes.SUGGESTION_SELECT);
1737
+
1738
+ if (this.$props.value !== undefined) {
1739
+ this.$emit('change', this.selectedTags, this.triggerQuery);
1740
+ }
1741
+ },
1742
+ renderTags: function renderTags() {
1743
+ var _this3 = this;
1744
+
1745
+ var h = this.$createElement;
1746
+
1747
+ if (!Array.isArray(this.selectedTags)) {
1748
+ return null;
1749
+ }
1750
+
1751
+ var tagsList = [].concat(this.selectedTags);
1752
+ var shouldRenderClearAllTag = tagsList.length > 1;
1753
+ var renderSelectedTags = this.$scopedSlots.renderSelectedTags || this.$props.renderSelectedTags;
1754
+ return renderSelectedTags ? renderSelectedTags({
1755
+ values: this.selectedTags,
1756
+ handleClear: this.clearTag,
1757
+ handleClearAll: this.clearAllTags
1758
+ }) : h(TagsContainer, [tagsList.map(function (item) {
1759
+ return _this3.renderTag(item);
1760
+ }), shouldRenderClearAllTag && h(TagItem, {
1761
+ "class": getClassName$1(this.$props.innerClass, 'selected-tag') || ''
1762
+ }, [h("span", ["Clear All"]), h("span", {
1763
+ "attrs": {
1764
+ "role": "img",
1765
+ "aria-label": "delete-tag"
1766
+ },
1767
+ "class": "close-icon",
1768
+ "on": {
1769
+ "click": this.clearAllTags
1770
+ }
1771
+ }, [h(CancelSvg)])])]);
1772
+ },
1625
1773
  renderInputAddonAfter: function renderInputAddonAfter() {
1626
1774
  var h = this.$createElement;
1627
1775
  var addonAfter = this.$scopedSlots.addonAfter;
@@ -1692,7 +1840,7 @@ var DataSearch = {
1692
1840
  (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$this$$pro = _this$$refs[this.$props.innerRef]) == null ? void 0 : _this$$refs$this$$pro.focus(); // eslint-disable-line
1693
1841
  },
1694
1842
  listenForFocusShortcuts: function listenForFocusShortcuts() {
1695
- var _this2 = this;
1843
+ var _this4 = this;
1696
1844
 
1697
1845
  var _this$$props$focusSho = this.$props.focusShortcuts,
1698
1846
  focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
@@ -1710,7 +1858,7 @@ var DataSearch = {
1710
1858
  // Prevent the default refresh event under WINDOWS system
1711
1859
  event.preventDefault();
1712
1860
 
1713
- _this2.focusSearchBox(event);
1861
+ _this4.focusSearchBox(event);
1714
1862
  }); // if one of modifier keys are used, they are handled below
1715
1863
 
1716
1864
  hotkeys('*', function (event) {
@@ -1721,7 +1869,7 @@ var DataSearch = {
1721
1869
  var element = modifierKeys[index];
1722
1870
 
1723
1871
  if (hotkeys[element]) {
1724
- _this2.focusSearchBox(event);
1872
+ _this4.focusSearchBox(event);
1725
1873
 
1726
1874
  break;
1727
1875
  }
@@ -1730,7 +1878,7 @@ var DataSearch = {
1730
1878
  }
1731
1879
  },
1732
1880
  render: function render() {
1733
- var _this3 = this;
1881
+ var _this5 = this;
1734
1882
 
1735
1883
  var h = arguments[0];
1736
1884
  var _this$$props4 = this.$props,
@@ -1769,14 +1917,14 @@ var DataSearch = {
1769
1917
  setHighlightedIndex = _ref3.setHighlightedIndex;
1770
1918
 
1771
1919
  var renderSuggestionsContainer = function renderSuggestionsContainer() {
1772
- return h("div", [_this3.hasCustomRenderer && _this3.getComponent({
1920
+ return h("div", [_this5.hasCustomRenderer && _this5.getComponent({
1773
1921
  isOpen: isOpen,
1774
1922
  getItemProps: getItemProps,
1775
1923
  getItemEvents: getItemEvents,
1776
1924
  highlightedIndex: highlightedIndex
1777
- }), _this3.renderErrorComponent(), !_this3.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1778
- "class": suggestions(_this3.themePreset, theme) + " " + getClassName$1(_this3.$props.innerClass, 'list')
1779
- }, [_this3.suggestionsList.slice(0, size || 10).map(function (item, index) {
1925
+ }), _this5.renderErrorComponent(), !_this5.hasCustomRenderer && isOpen && hasSuggestions ? h("ul", {
1926
+ "class": suggestions(_this5.themePreset, theme) + " " + getClassName$1(_this5.$props.innerClass, 'list')
1927
+ }, [_this5.suggestionsList.slice(0, size || 10).map(function (item, index) {
1780
1928
  return h("li", {
1781
1929
  "domProps": _extends({}, getItemProps({
1782
1930
  item: item
@@ -1786,15 +1934,15 @@ var DataSearch = {
1786
1934
  })),
1787
1935
  "key": index + 1 + "-" + item.value,
1788
1936
  "style": {
1789
- backgroundColor: _this3.getBackgroundColor(highlightedIndex, index)
1937
+ backgroundColor: _this5.getBackgroundColor(highlightedIndex, index)
1790
1938
  }
1791
1939
  }, [h(SuggestionItem, {
1792
1940
  "attrs": {
1793
- "currentValue": _this3.currentValue,
1941
+ "currentValue": _this5.currentValue,
1794
1942
  "suggestion": item
1795
1943
  }
1796
1944
  })]);
1797
- }), _this3.defaultSearchSuggestions.map(function (sugg, index) {
1945
+ }), _this5.defaultSearchSuggestions.map(function (sugg, index) {
1798
1946
  return h("li", {
1799
1947
  "domProps": _extends({}, getItemProps({
1800
1948
  item: sugg
@@ -1802,9 +1950,9 @@ var DataSearch = {
1802
1950
  "on": _extends({}, getItemEvents({
1803
1951
  item: sugg
1804
1952
  })),
1805
- "key": _this3.suggestionsList.length + index + 1 + "-" + sugg.value,
1953
+ "key": _this5.suggestionsList.length + index + 1 + "-" + sugg.value,
1806
1954
  "style": {
1807
- backgroundColor: _this3.getBackgroundColor(highlightedIndex, _this3.suggestionsList.length + index),
1955
+ backgroundColor: _this5.getBackgroundColor(highlightedIndex, _this5.suggestionsList.length + index),
1808
1956
  justifyContent: 'flex-start'
1809
1957
  }
1810
1958
  }, [h("div", {
@@ -1813,28 +1961,28 @@ var DataSearch = {
1813
1961
  }
1814
1962
  }, [sugg.source && sugg.source._recent_search && h(CustomSvg, {
1815
1963
  "attrs": {
1816
- "className": getClassName$1(_this3.$props.innerClass, 'recent-search-icon') || null,
1964
+ "className": getClassName$1(_this5.$props.innerClass, 'recent-search-icon') || null,
1817
1965
  "icon": recentSearchesIcon,
1818
1966
  "type": "recent-search-icon"
1819
1967
  }
1820
1968
  }), sugg.source && sugg.source._popular_suggestion && h(CustomSvg, {
1821
1969
  "attrs": {
1822
- "className": getClassName$1(_this3.$props.innerClass, 'popular-search-icon') || null,
1970
+ "className": getClassName$1(_this5.$props.innerClass, 'popular-search-icon') || null,
1823
1971
  "icon": popularSearchesIcon,
1824
1972
  "type": "popular-search-icon"
1825
1973
  }
1826
1974
  })]), h(SuggestionItem, {
1827
1975
  "attrs": {
1828
- "currentValue": _this3.currentValue,
1976
+ "currentValue": _this5.currentValue,
1829
1977
  "suggestion": sugg
1830
1978
  }
1831
1979
  })]);
1832
- }), hasQuerySuggestionsRenderer(_this3) ? _this3.getComponent({
1980
+ }), hasQuerySuggestionsRenderer(_this5) ? _this5.getComponent({
1833
1981
  isOpen: isOpen,
1834
1982
  getItemProps: getItemProps,
1835
1983
  getItemEvents: getItemEvents,
1836
1984
  highlightedIndex: highlightedIndex
1837
- }, true) : _this3.topSuggestions.map(function (sugg, index) {
1985
+ }, true) : _this5.topSuggestions.map(function (sugg, index) {
1838
1986
  return h("li", {
1839
1987
  "domProps": _extends({}, getItemProps({
1840
1988
  item: sugg
@@ -1842,9 +1990,9 @@ var DataSearch = {
1842
1990
  "on": _extends({}, getItemEvents({
1843
1991
  item: sugg
1844
1992
  })),
1845
- "key": _this3.suggestionsList.length + index + 1 + "-" + sugg.value,
1993
+ "key": _this5.suggestionsList.length + index + 1 + "-" + sugg.value,
1846
1994
  "style": {
1847
- backgroundColor: _this3.getBackgroundColor(highlightedIndex, _this3.suggestionsList.length + index),
1995
+ backgroundColor: _this5.getBackgroundColor(highlightedIndex, _this5.suggestionsList.length + index),
1848
1996
  justifyContent: 'flex-start'
1849
1997
  }
1850
1998
  }, [h("div", {
@@ -1853,61 +2001,61 @@ var DataSearch = {
1853
2001
  }
1854
2002
  }, [h(CustomSvg, {
1855
2003
  "attrs": {
1856
- "className": getClassName$1(_this3.$props.innerClass, 'popular-search-icon') || null,
2004
+ "className": getClassName$1(_this5.$props.innerClass, 'popular-search-icon') || null,
1857
2005
  "icon": popularSearchesIcon,
1858
2006
  "type": "popular-search-icon"
1859
2007
  }
1860
2008
  })]), h(SuggestionItem, {
1861
2009
  "attrs": {
1862
- "currentValue": _this3.currentValue,
2010
+ "currentValue": _this5.currentValue,
1863
2011
  "suggestion": sugg
1864
2012
  }
1865
2013
  })]);
1866
- })]) : _this3.renderNoSuggestions(_this3.suggestionsList)]);
2014
+ })]) : _this5.renderNoSuggestions(_this5.suggestionsList)]);
1867
2015
  };
1868
2016
 
1869
2017
  return h("div", {
1870
2018
  "class": suggestionsContainer
1871
- }, [h(InputGroup, [_this3.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
2019
+ }, [h(InputGroup, [_this5.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
1872
2020
  "attrs": {
1873
- "id": _this3.$props.componentId + "-input",
1874
- "showIcon": _this3.$props.showIcon,
1875
- "showClear": _this3.$props.showClear,
1876
- "iconPosition": _this3.$props.iconPosition,
1877
- "placeholder": _this3.$props.placeholder,
1878
- "autoFocus": _this3.$props.autoFocus,
1879
- "themePreset": _this3.themePreset,
2021
+ "id": _this5.$props.componentId + "-input",
2022
+ "showIcon": _this5.$props.showIcon,
2023
+ "showClear": _this5.$props.showClear,
2024
+ "iconPosition": _this5.$props.iconPosition,
2025
+ "placeholder": _this5.$props.placeholder,
2026
+ "autoFocus": _this5.$props.autoFocus,
2027
+ "themePreset": _this5.themePreset,
1880
2028
  "autocomplete": "off"
1881
2029
  },
1882
- "ref": _this3.$props.innerRef,
1883
- "class": getClassName$1(_this3.$props.innerClass, 'input'),
2030
+ "ref": _this5.$props.innerRef,
2031
+ "class": getClassName$1(_this5.$props.innerClass, 'input'),
1884
2032
  "on": _extends({}, getInputEvents({
1885
- onInput: _this3.onInputChange,
2033
+ onInput: _this5.onInputChange,
1886
2034
  onBlur: function onBlur(e) {
1887
- _this3.$emit('blur', e, _this3.triggerQuery);
2035
+ _this5.$emit('blur', e, _this5.triggerQuery);
1888
2036
  },
1889
- onFocus: _this3.handleFocus,
2037
+ onFocus: _this5.handleFocus,
1890
2038
  onKeyPress: function onKeyPress(e) {
1891
- _this3.$emit('keyPress', e, _this3.triggerQuery);
2039
+ _this5.$emit('keyPress', e, _this5.triggerQuery);
1892
2040
 
1893
- _this3.$emit('key-press', e, _this3.triggerQuery);
2041
+ _this5.$emit('key-press', e, _this5.triggerQuery);
1894
2042
  },
1895
2043
  onKeyDown: function onKeyDown(e) {
1896
- return _this3.handleKeyDown(e, highlightedIndex);
2044
+ return _this5.handleKeyDown(e, highlightedIndex);
1897
2045
  },
1898
2046
  onKeyUp: function onKeyUp(e) {
1899
- _this3.$emit('keyUp', e, _this3.triggerQuery);
2047
+ _this5.$emit('keyUp', e, _this5.triggerQuery);
1900
2048
 
1901
- _this3.$emit('key-up', e, _this3.triggerQuery);
2049
+ _this5.$emit('key-up', e, _this5.triggerQuery);
1902
2050
  },
1903
2051
  onClick: function onClick() {
1904
2052
  setHighlightedIndex(null);
1905
2053
  }
1906
2054
  })),
1907
2055
  "domProps": _extends({}, getInputProps({
1908
- value: _this3.$data.currentValue === null ? '' : _this3.$data.currentValue
2056
+ value: _this5.$data.currentValue === null ? '' : _this5.$data.currentValue
1909
2057
  }))
1910
- }), _this3.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this3.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer()]);
2058
+ }), _this5.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), ' ', _this5.renderInputAddonAfter()]), expandSuggestionsContainer && renderSuggestionsContainer(), _this5.renderTags()]);
1911
2059
  }
1912
2060
  }
1913
2061
  }) : h("div", {
@@ -1923,26 +2071,26 @@ var DataSearch = {
1923
2071
  },
1924
2072
  "on": _extends({}, {
1925
2073
  blur: function blur(e) {
1926
- _this3.$emit('blur', e, _this3.triggerQuery);
2074
+ _this5.$emit('blur', e, _this5.triggerQuery);
1927
2075
  },
1928
2076
  keypress: function keypress(e) {
1929
- _this3.$emit('keyPress', e, _this3.triggerQuery);
2077
+ _this5.$emit('keyPress', e, _this5.triggerQuery);
1930
2078
 
1931
- _this3.$emit('key-press', e, _this3.triggerQuery);
2079
+ _this5.$emit('key-press', e, _this5.triggerQuery);
1932
2080
  },
1933
2081
  input: this.onInputChange,
1934
2082
  focus: function focus(e) {
1935
- _this3.$emit('focus', e, _this3.triggerQuery);
2083
+ _this5.$emit('focus', e, _this5.triggerQuery);
1936
2084
  },
1937
2085
  keydown: function keydown(e) {
1938
- _this3.$emit('keyDown', e, _this3.triggerQuery);
2086
+ _this5.$emit('keyDown', e, _this5.triggerQuery);
1939
2087
 
1940
- _this3.$emit('key-down', e, _this3.triggerQuery);
2088
+ _this5.$emit('key-down', e, _this5.triggerQuery);
1941
2089
  },
1942
2090
  keyup: function keyup(e) {
1943
- _this3.$emit('keyUp', e, _this3.triggerQuery);
2091
+ _this5.$emit('keyUp', e, _this5.triggerQuery);
1944
2092
 
1945
- _this3.$emit('key-up', e, _this3.triggerQuery);
2093
+ _this5.$emit('key-up', e, _this5.triggerQuery);
1946
2094
  }
1947
2095
  }),
1948
2096
  "domProps": _extends({}, {
@@ -2141,7 +2289,8 @@ var mapDispatchToProps = {
2141
2289
  setCustomHighlightOptions: setCustomHighlightOptions,
2142
2290
  recordSuggestionClick: recordSuggestionClick,
2143
2291
  loadPopularSuggestions: loadPopularSuggestions,
2144
- getRecentSearches: getRecentSearches
2292
+ getRecentSearches: getRecentSearches,
2293
+ resetStoreForComponent: resetStoreForComponent
2145
2294
  };
2146
2295
  var DSConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(DataSearch), {
2147
2296
  componentType: componentTypes.dataSearch,
@@ -2155,4 +2304,4 @@ DataSearch.install = function (Vue) {
2155
2304
 
2156
2305
  DataSearch.componentType = componentTypes.dataSearch;
2157
2306
 
2158
- export { CustomSvg as C, DataSearch as D, InputAddon as I, Mic as M, SearchSvg as S, SuggestionWrapper as a, InputGroup as b, SuggestionItem as c };
2307
+ export { CustomSvg as C, DataSearch as D, InputAddon as I, Mic as M, SearchSvg as S, TagItem as T, SuggestionWrapper as a, TagsContainer as b, InputGroup as c, SuggestionItem as d };