@enso-ui/select 2.1.6 → 2.1.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enso-ui/select",
3
- "version": "2.1.6",
3
+ "version": "2.1.10",
4
4
  "description": "Select",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <vue-select :i18n="i18n"
2
+ <vue-select v-bind="$attrs"
3
+ :i18n="i18n"
3
4
  :error-handler="errorHandler"
4
5
  :source="source ? route(source) : null"
5
- v-bind="$attrs"
6
6
  v-on="$listeners"
7
7
  ref="select">
8
8
  <template v-slot:option="props">
@@ -33,9 +33,9 @@
33
33
  v-if="hasSelection">
34
34
  <div class="control">
35
35
  <template v-if="multiple">
36
- <tag v-for="value in selection"
36
+ <tag v-bind="selectionBindings(value)"
37
+ v-for="value in selection"
37
38
  :key="value[trackBy]"
38
- v-bind="selectionBindings(value)"
39
39
  v-on="selectionEvents(value)"/>
40
40
  </template>
41
41
  <template v-else>
@@ -64,9 +64,9 @@
64
64
  <div class="dropdown-item search">
65
65
  <div class="control has-icons-right">
66
66
  <input class="input"
67
+ v-bind="filterBindings"
67
68
  type="text"
68
69
  :placeholder="i18n(labels.search)"
69
- v-bind="filterBindings"
70
70
  v-on="filterEvents"
71
71
  v-focus>
72
72
  <search-mode class="is-right icon is-small search-mode"
@@ -77,8 +77,8 @@
77
77
  </div>
78
78
  </template>
79
79
  <template v-slot:items>
80
- <dropdown-item key="add-tag"
81
- v-bind="taggableBindings"
80
+ <dropdown-item v-bind="taggableBindings"
81
+ key="add-tag"
82
82
  v-on="taggableEvents"
83
83
  v-if="canAddTag">
84
84
  {{ query }}
@@ -238,13 +238,17 @@ export default {
238
238
  this.update(this.multiple ? [] : null);
239
239
  this.$emit('clear');
240
240
  },
241
- deselect(value) {
242
- const index = this.value
243
- .findIndex((val) => val === value[this.trackBy]);
241
+ deselect(deselect) {
242
+ const value = JSON.parse(JSON.stringify(this.value));
243
+
244
+ const index = value
245
+ .findIndex(val => this.objects
246
+ ? val[this.trackBy] === deselect[this.trackBy]
247
+ : val === deselect[this.trackBy]);
244
248
 
245
- this.value.splice(index, 1);
246
- this.update(this.value);
247
- this.$emit('deselect', value);
249
+ value.splice(index, 1);
250
+ this.update(value);
251
+ this.$emit('deselect', deselect);
248
252
  },
249
253
  displayLabel(option) {
250
254
  if (!option) {
@@ -291,8 +295,8 @@ export default {
291
295
  const index = this.value
292
296
  .findIndex((val) => this.valueMatchesOption(val, option));
293
297
 
294
- this.updateMultipleSelection(index, option);
295
- this.update(this.value);
298
+ const value = this.updateMultipleSelection(index, option);
299
+ this.update(value);
296
300
  },
297
301
  handleSingleSelection(option) {
298
302
  this.reset();
@@ -420,14 +424,17 @@ export default {
420
424
  : null;
421
425
  },
422
426
  updateMultipleSelection(index, option) {
427
+ const value = JSON.parse(JSON.stringify(this.value));
428
+
423
429
  if (index >= 0) {
424
- this.value.splice(index, 1);
430
+ value.splice(index, 1);
425
431
  this.$emit('deselect', this.objects ? option : option[this.trackBy]);
426
- return;
432
+ } else {
433
+ value.push(this.optionValue(option));
434
+ this.$emit('select', this.objects ? option : option[this.trackBy]);
427
435
  }
428
436
 
429
- this.value.push(this.optionValue(option));
430
- this.$emit('select', this.objects ? option : option[this.trackBy]);
437
+ return value;
431
438
  },
432
439
  },
433
440