@klippa/ngx-enhancy-forms 7.2.1 → 7.3.0

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.
@@ -340,6 +340,7 @@
340
340
  this.controlContainer = controlContainer;
341
341
  this.changed = new Array();
342
342
  this.touched = new Array();
343
+ this.prevValue = null;
343
344
  this.disabled = false;
344
345
  // we support both providing just the formControlName and the full formControl
345
346
  this.formControlName = null;
@@ -390,6 +391,7 @@
390
391
  };
391
392
  ValueAccessorBase.prototype.writeValue = function (value) {
392
393
  this.innerValue = value;
394
+ this.prevValue = value;
393
395
  };
394
396
  ValueAccessorBase.prototype.registerOnChange = function (fn) {
395
397
  this.changed.push(fn);
@@ -398,8 +400,34 @@
398
400
  this.touched.push(fn);
399
401
  };
400
402
  ValueAccessorBase.prototype.setInnerValueAndNotify = function (value) {
401
- this.innerValue = value;
402
- this.changed.forEach(function (fn) { return fn(value); });
403
+ var _this = this;
404
+ var actuallySetValue = function (valueToSet) {
405
+ _this.innerValue = valueToSet;
406
+ _this.prevValue = valueToSet;
407
+ _this.changed.forEach(function (fn) { return fn(valueToSet); });
408
+ };
409
+ if (isValueSet(this.innerValueChangeInterceptor)) {
410
+ this.latestInnerValueChangedInterceptorPromise = this.innerValueChangeInterceptor();
411
+ var myPromise_1 = this.latestInnerValueChangedInterceptorPromise;
412
+ this.latestInnerValueChangedInterceptorPromise.then(function () {
413
+ if (_this.latestInnerValueChangedInterceptorPromise === myPromise_1) {
414
+ actuallySetValue(value);
415
+ }
416
+ else {
417
+ // ignore outdated promises
418
+ }
419
+ }).catch(function () {
420
+ if (_this.latestInnerValueChangedInterceptorPromise === myPromise_1) {
421
+ actuallySetValue(_this.prevValue);
422
+ }
423
+ else {
424
+ // ignore outdated promises
425
+ }
426
+ });
427
+ }
428
+ else {
429
+ actuallySetValue(value);
430
+ }
403
431
  };
404
432
  ValueAccessorBase.prototype.resetToNull = function () {
405
433
  this.setInnerValueAndNotify(null);
@@ -424,6 +452,7 @@
424
452
  ]; };
425
453
  ValueAccessorBase.propDecorators = {
426
454
  disabled: [{ type: core.Input }],
455
+ innerValueChangeInterceptor: [{ type: core.Input }],
427
456
  formControlName: [{ type: core.Input }],
428
457
  formControl: [{ type: core.Input }],
429
458
  onTouch: [{ type: core.Output }]
@@ -1854,6 +1883,7 @@
1854
1883
  exports.DateTimePickerComponent = DateTimePickerComponent;
1855
1884
  exports.EmailInputComponent = EmailInputComponent;
1856
1885
  exports.FORM_ERROR_MESSAGES = FORM_ERROR_MESSAGES;
1886
+ exports.FileInputComponent = FileInputComponent;
1857
1887
  exports.FormCaptionComponent = FormCaptionComponent;
1858
1888
  exports.FormComponent = FormComponent;
1859
1889
  exports.FormElementComponent = FormElementComponent;
@@ -1878,7 +1908,6 @@
1878
1908
  exports.invalidFieldsSymbol = invalidFieldsSymbol;
1879
1909
  exports.matDateFormatsFactory = matDateFormatsFactory;
1880
1910
  exports["ɵa"] = MaterialModule;
1881
- exports["ɵb"] = FileInputComponent;
1882
1911
 
1883
1912
  Object.defineProperty(exports, '__esModule', { value: true });
1884
1913