@enso-ui/select 3.0.3 → 3.0.7

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": "3.0.3",
3
+ "version": "3.0.7",
4
4
  "description": "Select",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,8 +42,8 @@
42
42
  "autoprefixer": "^9.6.1",
43
43
  "babel-eslint": "^10.0.1",
44
44
  "cross-env": "^6.0.0",
45
- "eslint": "^7.0",
45
+ "eslint": "^7.0.0",
46
46
  "eslint-import-resolver-alias": "^1.1.2",
47
- "eslint-plugin-vue": "^7.0.0-beta.4"
47
+ "eslint-plugin-vue": "^8.0.0"
48
48
  }
49
49
  }
@@ -95,12 +95,17 @@ export default {
95
95
  type: Boolean,
96
96
  default: false,
97
97
  },
98
- value: {
98
+ modelValue: {
99
99
  type: null,
100
100
  required: true,
101
101
  },
102
102
  },
103
103
 
104
+ emits: [
105
+ 'add-tag', 'clear', 'deselect', 'fetch', 'select',
106
+ 'selection', 'update', 'update:modelValue',
107
+ ],
108
+
104
109
  data: v => ({
105
110
  allowsSelection: true,
106
111
  internalValue: null,
@@ -133,8 +138,8 @@ export default {
133
138
  },
134
139
  hasSelection() {
135
140
  return this.multiple
136
- ? this.value.length > 0
137
- : this.value !== null;
141
+ ? this.modelValue.length > 0
142
+ : this.modelValue !== null;
138
143
  },
139
144
  modeSelector() {
140
145
  return this.searchModes.length > 1;
@@ -152,10 +157,10 @@ export default {
152
157
  },
153
158
  selection() {
154
159
  return this.multiple
155
- ? this.optionList.filter(option => this.value
160
+ ? this.optionList.filter(option => this.modelValue
156
161
  .some(val => this.valueMatchesOption(val, option)))
157
162
  : this.optionList
158
- .find(option => this.valueMatchesOption(this.value, option)) || null;
163
+ .find(option => this.valueMatchesOption(this.modelValue, option)) || null;
159
164
  },
160
165
  serverSide() {
161
166
  return this.source !== null;
@@ -205,10 +210,10 @@ export default {
205
210
  this.optionList = this.options;
206
211
  this.fetchIfServerSide();
207
212
  },
208
- value: {
213
+ modelValue: {
209
214
  handler(value) {
210
215
  if (JSON.stringify(this.internalValue) !== JSON.stringify(value)) {
211
- this.$emit('input', value);
216
+ this.$emit('update:modelValue', value);
212
217
  }
213
218
  this.internalValue = null;
214
219
  if (this.query) {
@@ -245,7 +250,7 @@ export default {
245
250
  this.$emit('clear');
246
251
  },
247
252
  deselect(deselect) {
248
- const value = JSON.parse(JSON.stringify(this.value));
253
+ const value = JSON.parse(JSON.stringify(this.modelValue));
249
254
 
250
255
  const index = value
251
256
  .findIndex(val => val === deselect[this.trackBy]);
@@ -296,7 +301,7 @@ export default {
296
301
  }
297
302
  },
298
303
  handleMultipleSelection(option) {
299
- const index = this.value
304
+ const index = this.modelValue
300
305
  .findIndex(val => this.valueMatchesOption(val, option));
301
306
 
302
307
  const value = this.updateMultipleSelection(index, option);
@@ -305,7 +310,7 @@ export default {
305
310
  handleSingleSelection(option) {
306
311
  this.reset();
307
312
 
308
- const selection = this.valueMatchesOption(this.value, option);
313
+ const selection = this.valueMatchesOption(this.modelValue, option);
309
314
 
310
315
  if (!selection) {
311
316
  this.update(this.optionValue(option));
@@ -330,8 +335,8 @@ export default {
330
335
  },
331
336
  isSelected(option) {
332
337
  return this.multiple
333
- ? this.value.some(val => this.valueMatchesOption(val, option))
334
- : this.valueMatchesOption(this.value, option);
338
+ ? this.modelValue.some(val => this.valueMatchesOption(val, option))
339
+ : this.valueMatchesOption(this.modelValue, option);
335
340
  },
336
341
  matchesQuery(option) {
337
342
  const label = this.displayLabel(option);
@@ -374,12 +379,12 @@ export default {
374
379
  },
375
380
  requestValue() {
376
381
  if (!this.objects) {
377
- return this.value;
382
+ return this.modelValue;
378
383
  }
379
384
 
380
385
  return this.multiple
381
- ? this.value.map(value => value[this.trackBy])
382
- : this.value[this.trackBy];
386
+ ? this.modelValue.map(value => value[this.trackBy])
387
+ : this.modelValue[this.trackBy];
383
388
  },
384
389
  reset() {
385
390
  this.query = '';
@@ -400,7 +405,7 @@ export default {
400
405
  },
401
406
  update(value) {
402
407
  this.internalValue = value;
403
- this.$emit('input', value);
408
+ this.$emit('update:modelValue', value);
404
409
  this.$emit('update');
405
410
  },
406
411
  updateSelection() {
@@ -408,7 +413,7 @@ export default {
408
413
  ? this.valuesWhithinOptions()
409
414
  : this.valueWhithinOptions();
410
415
 
411
- if (JSON.stringify(value) !== JSON.stringify(this.value)) {
416
+ if (JSON.stringify(value) !== JSON.stringify(this.modelValue)) {
412
417
  this.update(value);
413
418
  }
414
419
  },
@@ -418,17 +423,17 @@ export default {
418
423
  : `${value}` === `${option[this.trackBy]}`;
419
424
  },
420
425
  valuesWhithinOptions() {
421
- return this.value.filter(val => this.optionList
426
+ return this.modelValue.filter(val => this.optionList
422
427
  .some(option => this.valueMatchesOption(val, option)));
423
428
  },
424
429
  valueWhithinOptions() {
425
430
  return this.optionList
426
- .some(option => this.valueMatchesOption(this.value, option))
427
- ? this.value
431
+ .some(option => this.valueMatchesOption(this.modelValue, option))
432
+ ? this.modelValue
428
433
  : null;
429
434
  },
430
435
  updateMultipleSelection(index, option) {
431
- const value = JSON.parse(JSON.stringify(this.value));
436
+ const value = JSON.parse(JSON.stringify(this.modelValue));
432
437
 
433
438
  if (index >= 0) {
434
439
  value.splice(index, 1);
@@ -457,7 +462,7 @@ export default {
457
462
  disabled: this.disabled,
458
463
  displayLabel: this.displayLabel,
459
464
  dropdownDisabled: this.dropdownDisabled,
460
- filterBindings: { value: this.query },
465
+ filterBindings: { modelValue: this.query },
461
466
  filterEvents: {
462
467
  input: e => (this.query = e.target.value),
463
468
  click: e => e.stopPropagation(),
@@ -488,10 +493,10 @@ export default {
488
493
  modeBindings: {
489
494
  modes: this.searchModes,
490
495
  query: this.query,
491
- value: this.mode,
496
+ 'update:modelValue': this.mode,
492
497
  },
493
498
  modeEvents: {
494
- input: event => (this.mode = event),
499
+ 'update:modelValue': event => (this.mode = event),
495
500
  change: this.fetch,
496
501
  },
497
502
  modeSelector: this.modeSelector,