@appbaseio/reactivesearch-vue 1.16.0-alpha.51 → 1.16.0-alpha.54

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.
@@ -100,7 +100,7 @@ var URLParamsProvider = {
100
100
  Object.keys(_this.currentSelectedState).filter(function (item) {
101
101
  return !activeComponents.includes(item);
102
102
  }).forEach(function (component) {
103
- _this.setValue(component, null);
103
+ _this.setValue(component, null, undefined, undefined, undefined, undefined, undefined, undefined, 'URL');
104
104
  }); // update active components in selectedValues
105
105
 
106
106
  Array.from(_this.params.entries()).forEach(function (item) {
@@ -115,7 +115,7 @@ var URLParamsProvider = {
115
115
  showFilter = _ref.showFilter,
116
116
  URLParams = _ref.URLParams;
117
117
 
118
- _this.setValue(component, JSON.parse(value), label, showFilter, URLParams);
118
+ _this.setValue(component, JSON.parse(value), label, showFilter, URLParams, undefined, undefined, undefined, 'URL');
119
119
  } catch (e) {
120
120
  // Do not set value if JSON parsing fails.
121
121
  console.error(e);
@@ -133,39 +133,45 @@ var URLParamsProvider = {
133
133
  selectedValues: function selectedValues(newVal, oldVal) {
134
134
  var _this2 = this;
135
135
 
136
- this.currentSelectedState = newVal;
137
-
138
136
  if (!isEqual(newVal, oldVal)) {
139
137
  this.searchString = this.$props.getSearchParams ? this.$props.getSearchParams() : window.location.search;
140
138
  this.params = new URLSearchParams(this.searchString);
141
139
  var currentComponents = Object.keys(newVal);
142
140
  var urlComponents = Array.from(this.params.keys());
141
+ var shouldPushHistory = false;
143
142
  currentComponents.filter(function (component) {
144
143
  return newVal[component].URLParams;
145
144
  }).forEach(function (component) {
146
- // prevents empty history pollution on initial load
147
- if (_this2.hasValidValue(newVal[component]) || _this2.hasValidValue(oldVal[component])) {
148
- var selectedValues = newVal[component];
145
+ var selectedValues = newVal[component]; // prevents empty history pollution on initial load
149
146
 
147
+ if (_this2.hasValidValue(newVal[component]) || _this2.hasValidValue(oldVal[component])) {
150
148
  if (selectedValues.URLParams) {
151
149
  if (selectedValues.category) {
152
- _this2.setURL(component, _this2.getValue({
150
+ var shouldUpdateHistory = _this2.setURL(component, _this2.getValue({
153
151
  category: selectedValues.category,
154
152
  value: selectedValues.value
155
153
  }));
154
+
155
+ if (shouldUpdateHistory) {
156
+ shouldPushHistory = true;
157
+ }
156
158
  } else {
157
- _this2.setURL(component, _this2.getValue(selectedValues.value));
159
+ var _shouldUpdateHistory = _this2.setURL(component, _this2.getValue(selectedValues.value));
160
+
161
+ if (_shouldUpdateHistory) {
162
+ shouldPushHistory = true;
163
+ }
158
164
  }
159
165
  } else {
160
166
  _this2.params["delete"](component);
161
167
 
162
- _this2.pushToHistory();
168
+ shouldPushHistory = true;
163
169
  }
164
170
  } else if (!_this2.hasValidValue(newVal[component]) && urlComponents.includes(component)) {
165
171
  // doesn't have a valid value, but the url has a (stale) valid value set
166
172
  _this2.params["delete"](component);
167
173
 
168
- _this2.pushToHistory();
174
+ shouldPushHistory = true;
169
175
  }
170
176
  }); // remove unmounted components
171
177
 
@@ -174,15 +180,20 @@ var URLParamsProvider = {
174
180
  }).forEach(function (component) {
175
181
  _this2.params["delete"](component);
176
182
 
177
- _this2.pushToHistory();
183
+ shouldPushHistory = true;
178
184
  });
179
185
 
180
186
  if (!currentComponents.length) {
181
187
  Array.from(this.params.keys()).forEach(function (item) {
182
188
  if (_this2.searchComponents && _this2.searchComponents.includes(item)) {
183
189
  _this2.params["delete"](item);
190
+
191
+ shouldPushHistory = true;
184
192
  }
185
193
  });
194
+ }
195
+
196
+ if (shouldPushHistory) {
186
197
  this.pushToHistory();
187
198
  }
188
199
  }
@@ -245,20 +256,19 @@ var URLParamsProvider = {
245
256
  return value;
246
257
  },
247
258
  setURL: function setURL(component, value) {
248
- this.searchString = this.$props.getSearchParams ? this.$props.getSearchParams() : window.location.search;
249
- this.params = new URLSearchParams(this.searchString);
250
-
251
259
  if (!value || typeof value === 'string' && value.trim() === '' || Array.isArray(value) && value.length === 0) {
252
260
  this.params["delete"](component);
253
- this.pushToHistory();
254
- } else {
255
- var data = JSON.stringify(this.getValue(value));
261
+ return true;
262
+ }
256
263
 
257
- if (data !== this.params.get(component)) {
258
- this.params.set(component, data);
259
- this.pushToHistory();
260
- }
264
+ var data = JSON.stringify(value);
265
+
266
+ if (data !== this.params.get(component)) {
267
+ this.params.set(component, data);
268
+ return true;
261
269
  }
270
+
271
+ return false;
262
272
  },
263
273
  pushToHistory: function pushToHistory() {
264
274
  var paramsSting = this.params.toString() ? "?" + this.params.toString() : '';
@@ -692,6 +692,7 @@ var ReactiveList = {
692
692
  }, [this.data.map(function (item, index) {
693
693
  return renderItem({
694
694
  item: item,
695
+ count: _this2.currentPageState * size + index + 1,
695
696
  triggerClickAnalytics: function triggerClickAnalytics() {
696
697
  return _this2.triggerClickAnalytics(_this2.currentPageState * size + index);
697
698
  }
package/dist/cjs/index.js CHANGED
@@ -34,7 +34,7 @@ require('./Input-64087a69.js');
34
34
  require('compute-scroll-into-view');
35
35
  require('./Container-8a08d663.js');
36
36
  require('vue-highlight-words');
37
- var install = require('./install-adbb807a.js');
37
+ var install = require('./install-856cc730.js');
38
38
  require('@appbaseio/reactivecore/lib/utils/suggestions');
39
39
  require('./FormControlList-73497794.js');
40
40
  require('./utils-23afb20b.js');
@@ -558,10 +558,18 @@ var SearchBox = {
558
558
  this.onValueSelectedHandler('', configureStore.causes.CLEAR_VALUE);
559
559
  },
560
560
  handleKeyDown: function handleKeyDown(event, highlightedIndex) {
561
+ if (highlightedIndex === void 0) {
562
+ highlightedIndex = null;
563
+ }
564
+
561
565
  // if a suggestion was selected, delegate the handling to suggestion handler
562
- if (event.key === 'Enter' && highlightedIndex === null) {
563
- this.setValue(event.target.value, true);
564
- this.onValueSelectedHandler(event.target.value, configureStore.causes.ENTER_PRESS);
566
+ if (event.key === 'Enter') {
567
+ if (this.$props.autosuggest === false) {
568
+ this.enterButtonOnClick();
569
+ } else if (highlightedIndex === null) {
570
+ this.setValue(event.target.value, true);
571
+ this.onValueSelectedHandler(event.target.value, configureStore.causes.ENTER_PRESS);
572
+ }
565
573
  } // Need to review
566
574
 
567
575
 
@@ -733,6 +741,13 @@ var SearchBox = {
733
741
 
734
742
  return null;
735
743
  },
744
+ enterButtonOnClick: function enterButtonOnClick() {
745
+ this.triggerQuery({
746
+ isOpen: false,
747
+ value: this.currentValue,
748
+ customQuery: true
749
+ });
750
+ },
736
751
  renderEnterButtonElement: function renderEnterButtonElement() {
737
752
  var _this4 = this;
738
753
 
@@ -742,18 +757,10 @@ var SearchBox = {
742
757
  innerClass = _this$$props4.innerClass;
743
758
  var renderEnterButton = this.$scopedSlots.renderEnterButton;
744
759
 
745
- var enterButtonOnClick = function enterButtonOnClick() {
746
- return _this4.triggerQuery({
747
- isOpen: false,
748
- value: _this4.currentValue,
749
- customQuery: true
750
- });
751
- };
752
-
753
760
  if (enterButton) {
754
761
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
755
762
  if (renderEnterButton) {
756
- return renderEnterButton(enterButtonOnClick);
763
+ return renderEnterButton(_this4.enterButtonOnClick);
757
764
  }
758
765
 
759
766
  return h(Button.Button, {
@@ -762,7 +769,7 @@ var SearchBox = {
762
769
  "primary": true
763
770
  },
764
771
  "on": {
765
- "click": enterButtonOnClick
772
+ "click": _this4.enterButtonOnClick
766
773
  }
767
774
  }, ["Search"]);
768
775
  };
@@ -1065,11 +1072,7 @@ var SearchBox = {
1065
1072
  focus: function focus(e) {
1066
1073
  _this7.$emit('focus', e, _this7.triggerQuery);
1067
1074
  },
1068
- keydown: function keydown(e) {
1069
- _this7.$emit('keyDown', e, _this7.triggerQuery);
1070
-
1071
- _this7.$emit('key-down', e, _this7.triggerQuery);
1072
- },
1075
+ keydown: this.handleKeyDown,
1073
1076
  keyup: function keyup(e) {
1074
1077
  _this7.$emit('keyUp', e, _this7.triggerQuery);
1075
1078
 
@@ -34,7 +34,7 @@ require('./Input-64087a69.js');
34
34
  require('compute-scroll-into-view');
35
35
  require('./Container-8a08d663.js');
36
36
  require('vue-highlight-words');
37
- var install = require('./install-adbb807a.js');
37
+ var install = require('./install-856cc730.js');
38
38
  require('@appbaseio/reactivecore/lib/utils/suggestions');
39
39
  require('./FormControlList-73497794.js');
40
40
  require('./utils-23afb20b.js');
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "1.16.0-alpha.51";
5
+ var version = "1.16.0-alpha.54";
6
6
 
7
7
  exports.default = version;
@@ -92,7 +92,7 @@ var URLParamsProvider = {
92
92
  Object.keys(_this.currentSelectedState).filter(function (item) {
93
93
  return !activeComponents.includes(item);
94
94
  }).forEach(function (component) {
95
- _this.setValue(component, null);
95
+ _this.setValue(component, null, undefined, undefined, undefined, undefined, undefined, undefined, 'URL');
96
96
  }); // update active components in selectedValues
97
97
 
98
98
  Array.from(_this.params.entries()).forEach(function (item) {
@@ -107,7 +107,7 @@ var URLParamsProvider = {
107
107
  showFilter = _ref.showFilter,
108
108
  URLParams = _ref.URLParams;
109
109
 
110
- _this.setValue(component, JSON.parse(value), label, showFilter, URLParams);
110
+ _this.setValue(component, JSON.parse(value), label, showFilter, URLParams, undefined, undefined, undefined, 'URL');
111
111
  } catch (e) {
112
112
  // Do not set value if JSON parsing fails.
113
113
  console.error(e);
@@ -125,39 +125,45 @@ var URLParamsProvider = {
125
125
  selectedValues: function selectedValues(newVal, oldVal) {
126
126
  var _this2 = this;
127
127
 
128
- this.currentSelectedState = newVal;
129
-
130
128
  if (!isEqual(newVal, oldVal)) {
131
129
  this.searchString = this.$props.getSearchParams ? this.$props.getSearchParams() : window.location.search;
132
130
  this.params = new URLSearchParams(this.searchString);
133
131
  var currentComponents = Object.keys(newVal);
134
132
  var urlComponents = Array.from(this.params.keys());
133
+ var shouldPushHistory = false;
135
134
  currentComponents.filter(function (component) {
136
135
  return newVal[component].URLParams;
137
136
  }).forEach(function (component) {
138
- // prevents empty history pollution on initial load
139
- if (_this2.hasValidValue(newVal[component]) || _this2.hasValidValue(oldVal[component])) {
140
- var selectedValues = newVal[component];
137
+ var selectedValues = newVal[component]; // prevents empty history pollution on initial load
141
138
 
139
+ if (_this2.hasValidValue(newVal[component]) || _this2.hasValidValue(oldVal[component])) {
142
140
  if (selectedValues.URLParams) {
143
141
  if (selectedValues.category) {
144
- _this2.setURL(component, _this2.getValue({
142
+ var shouldUpdateHistory = _this2.setURL(component, _this2.getValue({
145
143
  category: selectedValues.category,
146
144
  value: selectedValues.value
147
145
  }));
146
+
147
+ if (shouldUpdateHistory) {
148
+ shouldPushHistory = true;
149
+ }
148
150
  } else {
149
- _this2.setURL(component, _this2.getValue(selectedValues.value));
151
+ var _shouldUpdateHistory = _this2.setURL(component, _this2.getValue(selectedValues.value));
152
+
153
+ if (_shouldUpdateHistory) {
154
+ shouldPushHistory = true;
155
+ }
150
156
  }
151
157
  } else {
152
158
  _this2.params["delete"](component);
153
159
 
154
- _this2.pushToHistory();
160
+ shouldPushHistory = true;
155
161
  }
156
162
  } else if (!_this2.hasValidValue(newVal[component]) && urlComponents.includes(component)) {
157
163
  // doesn't have a valid value, but the url has a (stale) valid value set
158
164
  _this2.params["delete"](component);
159
165
 
160
- _this2.pushToHistory();
166
+ shouldPushHistory = true;
161
167
  }
162
168
  }); // remove unmounted components
163
169
 
@@ -166,15 +172,20 @@ var URLParamsProvider = {
166
172
  }).forEach(function (component) {
167
173
  _this2.params["delete"](component);
168
174
 
169
- _this2.pushToHistory();
175
+ shouldPushHistory = true;
170
176
  });
171
177
 
172
178
  if (!currentComponents.length) {
173
179
  Array.from(this.params.keys()).forEach(function (item) {
174
180
  if (_this2.searchComponents && _this2.searchComponents.includes(item)) {
175
181
  _this2.params["delete"](item);
182
+
183
+ shouldPushHistory = true;
176
184
  }
177
185
  });
186
+ }
187
+
188
+ if (shouldPushHistory) {
178
189
  this.pushToHistory();
179
190
  }
180
191
  }
@@ -237,20 +248,19 @@ var URLParamsProvider = {
237
248
  return value;
238
249
  },
239
250
  setURL: function setURL(component, value) {
240
- this.searchString = this.$props.getSearchParams ? this.$props.getSearchParams() : window.location.search;
241
- this.params = new URLSearchParams(this.searchString);
242
-
243
251
  if (!value || typeof value === 'string' && value.trim() === '' || Array.isArray(value) && value.length === 0) {
244
252
  this.params["delete"](component);
245
- this.pushToHistory();
246
- } else {
247
- var data = JSON.stringify(this.getValue(value));
253
+ return true;
254
+ }
248
255
 
249
- if (data !== this.params.get(component)) {
250
- this.params.set(component, data);
251
- this.pushToHistory();
252
- }
256
+ var data = JSON.stringify(value);
257
+
258
+ if (data !== this.params.get(component)) {
259
+ this.params.set(component, data);
260
+ return true;
253
261
  }
262
+
263
+ return false;
254
264
  },
255
265
  pushToHistory: function pushToHistory() {
256
266
  var paramsSting = this.params.toString() ? "?" + this.params.toString() : '';
@@ -684,6 +684,7 @@ var ReactiveList = {
684
684
  }, [this.data.map(function (item, index) {
685
685
  return renderItem({
686
686
  item: item,
687
+ count: _this2.currentPageState * size + index + 1,
687
688
  triggerClickAnalytics: function triggerClickAnalytics() {
688
689
  return _this2.triggerClickAnalytics(_this2.currentPageState * size + index);
689
690
  }
package/dist/es/index.js CHANGED
@@ -30,8 +30,8 @@ import './Input-d1bb4868.js';
30
30
  import 'compute-scroll-into-view';
31
31
  import './Container-4383c6f0.js';
32
32
  import 'vue-highlight-words';
33
- import { i as install } from './install-39865f80.js';
34
- export { S as SearchBox, i as install } from './install-39865f80.js';
33
+ import { i as install } from './install-d1a27419.js';
34
+ export { S as SearchBox, i as install } from './install-d1a27419.js';
35
35
  import '@appbaseio/reactivecore/lib/utils/suggestions';
36
36
  import './FormControlList-fe389a2e.js';
37
37
  import './utils-3a32e13f.js';
@@ -552,10 +552,18 @@ var SearchBox = {
552
552
  this.onValueSelectedHandler('', causes.CLEAR_VALUE);
553
553
  },
554
554
  handleKeyDown: function handleKeyDown(event, highlightedIndex) {
555
+ if (highlightedIndex === void 0) {
556
+ highlightedIndex = null;
557
+ }
558
+
555
559
  // if a suggestion was selected, delegate the handling to suggestion handler
556
- if (event.key === 'Enter' && highlightedIndex === null) {
557
- this.setValue(event.target.value, true);
558
- this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
560
+ if (event.key === 'Enter') {
561
+ if (this.$props.autosuggest === false) {
562
+ this.enterButtonOnClick();
563
+ } else if (highlightedIndex === null) {
564
+ this.setValue(event.target.value, true);
565
+ this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
566
+ }
559
567
  } // Need to review
560
568
 
561
569
 
@@ -727,6 +735,13 @@ var SearchBox = {
727
735
 
728
736
  return null;
729
737
  },
738
+ enterButtonOnClick: function enterButtonOnClick() {
739
+ this.triggerQuery({
740
+ isOpen: false,
741
+ value: this.currentValue,
742
+ customQuery: true
743
+ });
744
+ },
730
745
  renderEnterButtonElement: function renderEnterButtonElement() {
731
746
  var _this4 = this;
732
747
 
@@ -736,18 +751,10 @@ var SearchBox = {
736
751
  innerClass = _this$$props4.innerClass;
737
752
  var renderEnterButton = this.$scopedSlots.renderEnterButton;
738
753
 
739
- var enterButtonOnClick = function enterButtonOnClick() {
740
- return _this4.triggerQuery({
741
- isOpen: false,
742
- value: _this4.currentValue,
743
- customQuery: true
744
- });
745
- };
746
-
747
754
  if (enterButton) {
748
755
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
749
756
  if (renderEnterButton) {
750
- return renderEnterButton(enterButtonOnClick);
757
+ return renderEnterButton(_this4.enterButtonOnClick);
751
758
  }
752
759
 
753
760
  return h(Button, {
@@ -756,7 +763,7 @@ var SearchBox = {
756
763
  "primary": true
757
764
  },
758
765
  "on": {
759
- "click": enterButtonOnClick
766
+ "click": _this4.enterButtonOnClick
760
767
  }
761
768
  }, ["Search"]);
762
769
  };
@@ -1059,11 +1066,7 @@ var SearchBox = {
1059
1066
  focus: function focus(e) {
1060
1067
  _this7.$emit('focus', e, _this7.triggerQuery);
1061
1068
  },
1062
- keydown: function keydown(e) {
1063
- _this7.$emit('keyDown', e, _this7.triggerQuery);
1064
-
1065
- _this7.$emit('key-down', e, _this7.triggerQuery);
1066
- },
1069
+ keydown: this.handleKeyDown,
1067
1070
  keyup: function keyup(e) {
1068
1071
  _this7.$emit('keyUp', e, _this7.triggerQuery);
1069
1072
 
@@ -30,7 +30,7 @@ import './Input-d1bb4868.js';
30
30
  import 'compute-scroll-into-view';
31
31
  import './Container-4383c6f0.js';
32
32
  import 'vue-highlight-words';
33
- export { i as default } from './install-39865f80.js';
33
+ export { i as default } from './install-d1a27419.js';
34
34
  import '@appbaseio/reactivecore/lib/utils/suggestions';
35
35
  import './FormControlList-fe389a2e.js';
36
36
  import './utils-3a32e13f.js';
@@ -1,3 +1,3 @@
1
- var version = "1.16.0-alpha.51";
1
+ var version = "1.16.0-alpha.54";
2
2
 
3
3
  export default version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appbaseio/reactivesearch-vue",
3
- "version": "1.16.0-alpha.51",
3
+ "version": "1.16.0-alpha.54",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "jsnext:main": "dist/es/index.js",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "sideEffects": false,
36
36
  "dependencies": {
37
- "@appbaseio/reactivecore": "9.14.6",
37
+ "@appbaseio/reactivecore": "9.14.9",
38
38
  "@appbaseio/vue-emotion": "0.4.4",
39
39
  "@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
40
40
  "appbase-js": "^5.0.0",
@@ -65,10 +65,10 @@
65
65
  "@babel/preset-stage-2": "^7.0.0",
66
66
  "@vue/babel-preset-jsx": "^1.1.0",
67
67
  "@vue/compiler-sfc": "^3.0.11",
68
+ "eslint": "^4.12.0",
68
69
  "eslint-config-airbnb-base": "^13.1.0",
69
70
  "eslint-config-prettier": "^3.1.0",
70
71
  "eslint-plugin-vue": "^4.7.1",
71
- "eslint": "^4.12.0",
72
72
  "nps": "^5.9.3",
73
73
  "nps-utils": "^1.7.0",
74
74
  "postcss": "^8.3.0",