@internetstiftelsen/styleguide 4.0.14 → 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);
@@ -238,7 +240,7 @@ var MultiSelect = function () {
238
240
  }, {
239
241
  key: 'removeHighlight',
240
242
  value: function removeHighlight() {
241
- var items = this.suggestionsBox.getElementsByClassName(this.baseClassName + '__suggestion-btn');
243
+ var items = this.suggestionsBox.getElementsByClassName((0, _className2.default)(this.baseClassName + '__suggestion-btn'));
242
244
 
243
245
  [].forEach.call(items, function (item) {
244
246
  item.classList.remove('autocomplete-active');
@@ -247,7 +249,7 @@ var MultiSelect = function () {
247
249
  }, {
248
250
  key: 'highlight',
249
251
  value: function highlight(direction) {
250
- var items = this.suggestionsBox.getElementsByClassName(this.baseClassName + '__suggestion-btn');
252
+ var items = this.suggestionsBox.getElementsByClassName((0, _className2.default)(this.baseClassName + '__suggestion-btn'));
251
253
  var focus = this.currentFocus;
252
254
 
253
255
  if (direction === 'down') {
@@ -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.14",
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) {
@@ -168,7 +170,7 @@ class MultiSelect {
168
170
  }
169
171
 
170
172
  removeHighlight() {
171
- const items = this.suggestionsBox.getElementsByClassName(`${this.baseClassName}__suggestion-btn`);
173
+ const items = this.suggestionsBox.getElementsByClassName(className(`${this.baseClassName}__suggestion-btn`));
172
174
 
173
175
  [].forEach.call(items, (item) => {
174
176
  item.classList.remove('autocomplete-active');
@@ -176,7 +178,7 @@ class MultiSelect {
176
178
  }
177
179
 
178
180
  highlight(direction) {
179
- const items = this.suggestionsBox.getElementsByClassName(`${this.baseClassName}__suggestion-btn`);
181
+ const items = this.suggestionsBox.getElementsByClassName(className(`${this.baseClassName}__suggestion-btn`));
180
182
  let focus = this.currentFocus;
181
183
 
182
184
  if (direction === 'down') {
@@ -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];