@firestitch/form 12.4.4 → 12.4.6

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.
@@ -87,6 +87,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
87
87
  addButton(button: FsButtonDirective): void;
88
88
  removeButton(button: FsButtonDirective): void;
89
89
  private _listenSubmit;
90
+ validate(): void;
90
91
  private _listenFormStatus;
91
92
  private _listenWindowClose;
92
93
  private _listenHotKeys;
@@ -110,7 +111,6 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
110
111
  private _updateDirtySubmitButtons;
111
112
  private _broadcastSubmittingEvents;
112
113
  private _broadcasValidatingEvents;
113
- private _markControlsAsTouchedAndUpdateValidity;
114
114
  private _setupActiveSubmitButton;
115
115
  private _disableButtons;
116
116
  private _waitUntilStatusPending;
@@ -795,7 +795,7 @@
795
795
  }), operators.tap(function () { return _this._confirmed = false; }), operators.filter(function () {
796
796
  return [exports.FormStatus.Valid, exports.FormStatus.Invalid]
797
797
  .includes(_this._status$.getValue());
798
- }), operators.tap(function () { return _this._broadcasValidatingEvents(); }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function (data) { return _this._waitUntilStatusPending()
798
+ }), operators.tap(function () { return _this._broadcasValidatingEvents(); }), operators.tap(function () { return _this.validate(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function (data) { return _this._waitUntilStatusPending()
799
799
  .pipe(operators.mapTo(data)); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.tap(function () { return _this._disableButtons(); }), operators.mergeMap(function (data) {
800
800
  if (_this.ngForm.status === 'INVALID') {
801
801
  return _this._formInvalidState$;
@@ -810,6 +810,14 @@
810
810
  }), operators.takeUntil(this._destroy$))
811
811
  .subscribe(function () { });
812
812
  };
813
+ FsFormDirective.prototype.validate = function () {
814
+ Object.values(this.ngForm.controls)
815
+ .forEach(function (control) {
816
+ control.markAsDirty();
817
+ control.markAsTouched();
818
+ control.updateValueAndValidity();
819
+ });
820
+ };
813
821
  FsFormDirective.prototype._listenFormStatus = function () {
814
822
  var _this = this;
815
823
  this._status$
@@ -1153,14 +1161,6 @@
1153
1161
  FsFormDirective.prototype._broadcasValidatingEvents = function () {
1154
1162
  this._status$.next(exports.FormStatus.Validating);
1155
1163
  };
1156
- FsFormDirective.prototype._markControlsAsTouchedAndUpdateValidity = function () {
1157
- Object.values(this.ngForm.controls)
1158
- .forEach(function (control) {
1159
- control.markAsDirty();
1160
- control.markAsTouched();
1161
- control.updateValueAndValidity();
1162
- });
1163
- };
1164
1164
  FsFormDirective.prototype._setupActiveSubmitButton = function () {
1165
1165
  this._activeSubmitButton = this._getActiveSubmitButton();
1166
1166
  this._resetButtons();
@@ -1435,6 +1435,14 @@
1435
1435
  var renderer = this.renderer2;
1436
1436
  var wrapper = this.getWrapperElement();
1437
1437
  var error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
1438
+ var shouldErrorBeRendered = this.ngControl.invalid
1439
+ && (this.ngControl.dirty || ((_a = this.formDirective.ngForm) === null || _a === void 0 ? void 0 : _a.submitted));
1440
+ if (shouldErrorBeRendered && error) {
1441
+ wrapper.classList.add('ng-invalid', 'ng-dirty');
1442
+ }
1443
+ else {
1444
+ wrapper.classList.remove('ng-invalid');
1445
+ }
1438
1446
  if (!this.getMessageSelector()) {
1439
1447
  return;
1440
1448
  }
@@ -1466,13 +1474,9 @@
1466
1474
  if (errorWrapper) {
1467
1475
  errorWrapper.remove();
1468
1476
  }
1469
- wrapper.classList.remove('ng-invalid');
1470
- var shouldErrorBeRendered = this.ngControl.invalid
1471
- && (this.ngControl.dirty || ((_a = this.formDirective.ngForm) === null || _a === void 0 ? void 0 : _a.submitted));
1472
1477
  if (!shouldErrorBeRendered || !error) {
1473
1478
  return;
1474
1479
  }
1475
- wrapper.classList.add('ng-invalid', 'ng-dirty');
1476
1480
  errorWrapper = renderer.createElement('div');
1477
1481
  renderer.addClass(errorWrapper, 'fs-form-error-target');
1478
1482
  renderer.addClass(errorWrapper, this.appendErrorClass);