goodteditor-ui 1.0.64 → 1.0.66

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": "goodteditor-ui",
3
- "version": "1.0.64",
3
+ "version": "1.0.66",
4
4
  "main": "index.js",
5
5
  "homepage": "https://goodt-ui.netlify.app/",
6
6
  "scripts": {
@@ -346,19 +346,23 @@ export default {
346
346
  }
347
347
  return model && model.length ? model[0] : null;
348
348
  },
349
- triggerModelChange() {
349
+ /**
350
+ *
351
+ * @param {function(): void} rollback
352
+ */
353
+ triggerModelChange(rollback) {
350
354
  let value = this.exportModel();
351
355
  /**
352
356
  * Input event
353
357
  * @property {any} value
354
358
  */
355
- this.$emit('input', value);
359
+ this.$emit('input', value, { cancel: rollback });
356
360
  /**
357
361
  * Change event
358
362
  * @property {any} model
359
363
  * @property {Array} meta
360
364
  */
361
- this.$emit('change', value);
365
+ this.$emit('change', value, { cancel: rollback });
362
366
  },
363
367
  getOptionLabel(option) {
364
368
  let label = option ? option[this.labelField] : null;
@@ -375,27 +379,37 @@ export default {
375
379
  isOptionSelected(option) {
376
380
  return !!this.optionsSelected.find((o) => this.getOptionValue(o) === this.getOptionValue(option));
377
381
  },
382
+ /**
383
+ * @return {function(): void} rollback
384
+ */
385
+ createOptionRollback() {
386
+ const optionsSelected = [...this.optionsSelected];
387
+ return () => this.optionsSelected = optionsSelected;
388
+ },
378
389
  selectOption(option) {
379
390
  if (this.isOptionSelected(option)) {
380
391
  return;
381
392
  }
393
+ const rollback = this.createOptionRollback();
382
394
  if (this.multiple) {
383
395
  this.optionsSelected.push(option);
384
396
  } else {
385
397
  this.optionsSelected = [option];
386
398
  this.popoverShow = false;
387
399
  }
388
- this.triggerModelChange();
400
+
401
+ this.triggerModelChange(rollback);
389
402
  },
390
403
  deselectOption(option) {
391
404
  if (!this.multiple) {
392
405
  this.popoverShow = false;
393
406
  return;
394
407
  }
408
+ const rollback = this.createOptionRollback();
395
409
  this.optionsSelected = this.optionsSelected.filter(
396
410
  (o) => this.getOptionValue(o) !== this.getOptionValue(option)
397
411
  );
398
- this.triggerModelChange();
412
+ this.triggerModelChange(rollback);
399
413
  },
400
414
  toggleOption(option) {
401
415
  if (!this.isOptionSelected(option)) {
@@ -292,10 +292,6 @@ export default {
292
292
  box-shadow: 0 1px 4px -2px rgba(0, 0, 0, 0.25);
293
293
  }
294
294
  }
295
-
296
- &-content {
297
- min-height: 7.5rem;
298
- }
299
295
  }
300
296
 
301
297
  .group-header {