@internetstiftelsen/styleguide 4.0.15 → 4.0.16

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.
@@ -140,12 +140,14 @@ var MultiSelect = function () {
140
140
  }, {
141
141
  key: 'filterData',
142
142
  value: function filterData(query) {
143
- var _this4 = this;
143
+ var selectedValues = this.selectedItems.map(function (item) {
144
+ return item.value;
145
+ });
144
146
 
145
147
  return this.data.filter(function (item) {
146
148
  return item.name.toLowerCase().startsWith(query.toLowerCase());
147
149
  }).filter(function (item) {
148
- return !_this4.selectedItems.includes(item.name);
150
+ return !selectedValues.includes(item.value);
149
151
  });
150
152
  }
151
153
  }, {
@@ -193,7 +195,7 @@ var MultiSelect = function () {
193
195
  }, {
194
196
  key: 'addItem',
195
197
  value: function addItem(item) {
196
- var _this5 = this;
198
+ var _this4 = this;
197
199
 
198
200
  var save = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
199
201
 
@@ -217,7 +219,7 @@ var MultiSelect = function () {
217
219
 
218
220
  // Event listener for removing the selected item
219
221
  removeBtn.addEventListener('click', function () {
220
- _this5.removeItem(item);
222
+ _this4.removeItem(item);
221
223
  });
222
224
 
223
225
  newItem.appendChild(removeBtn);
@@ -265,7 +267,7 @@ var MultiSelect = function () {
265
267
  }, {
266
268
  key: 'selectHighlighted',
267
269
  value: function selectHighlighted() {
268
- var items = this.suggestionsBox.getElementsByClassName(this.baseClassName + '__suggestion-btn');
270
+ var items = this.suggestionsBox.getElementsByClassName((0, _className2.default)(this.baseClassName + '__suggestion-btn'));
269
271
 
270
272
  if (this.currentFocus > -1 && items[this.currentFocus]) {
271
273
  var item = items[this.currentFocus];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "4.0.15",
3
+ "version": "4.0.16",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -0,0 +1,26 @@
1
+ module.exports = {
2
+ status: 'ready',
3
+
4
+ context: {
5
+ default_value: null,
6
+ add: false,
7
+ },
8
+
9
+ variants: [
10
+ {
11
+ name: 'default',
12
+ },
13
+ {
14
+ name: 'pre selected',
15
+ context: {
16
+ default_value: 'stockholm'
17
+ }
18
+ },
19
+ {
20
+ name: 'custom items',
21
+ context: {
22
+ add: true
23
+ }
24
+ }
25
+ ]
26
+ };
@@ -69,9 +69,11 @@ class MultiSelect {
69
69
  }
70
70
 
71
71
  filterData(query) {
72
+ const selectedValues = this.selectedItems.map((item) => item.value);
73
+
72
74
  return this.data
73
75
  .filter((item) => item.name.toLowerCase().startsWith(query.toLowerCase()))
74
- .filter((item) => !this.selectedItems.includes(item.name));
76
+ .filter((item) => !selectedValues.includes(item.value));
75
77
  }
76
78
 
77
79
  populateSuggestions(suggestions) {
@@ -193,7 +195,7 @@ class MultiSelect {
193
195
  }
194
196
 
195
197
  selectHighlighted() {
196
- const items = this.suggestionsBox.getElementsByClassName(`${this.baseClassName}__suggestion-btn`);
198
+ const items = this.suggestionsBox.getElementsByClassName(className(`${this.baseClassName}__suggestion-btn`));
197
199
 
198
200
  if (this.currentFocus > -1 && items[this.currentFocus]) {
199
201
  const item = items[this.currentFocus];