@firestitch/form 12.3.2 → 12.3.4

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.
@@ -44,7 +44,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
44
44
  submitted: EventEmitter<SubmitEvent>;
45
45
  reseted: EventEmitter<SubmitEvent>;
46
46
  cleared: EventEmitter<SubmitEvent>;
47
- fsformClass: boolean;
47
+ fsFormClass: boolean;
48
48
  formDialogClose: QueryList<FsFormDialogCloseDirective>;
49
49
  private _tabGroups;
50
50
  private _buttons;
@@ -56,6 +56,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
56
56
  private _destroy$;
57
57
  constructor(ngForm: NgForm, _form: FsForm, _element: ElementRef, _message: FsMessage, _prompt: FsPrompt, _ngZone: NgZone, _dialogRef: MatDialogRef<any>, _drawerRef: DrawerRef<any>);
58
58
  get submitting(): boolean;
59
+ get validating(): boolean;
59
60
  get completing(): boolean;
60
61
  private get _submitEvent();
61
62
  private get _formValidState$();
@@ -79,6 +80,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
79
80
  addButton(button: FsButtonDirective): void;
80
81
  removeButton(button: FsButtonDirective): void;
81
82
  private _listenSubmit;
83
+ private _listenFormStatus;
82
84
  private _listenWindowClose;
83
85
  private _listenHotKeys;
84
86
  private _formClose;
@@ -100,6 +102,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
100
102
  private _registerDirtySubmitButton;
101
103
  private _updateDirtySubmitButtons;
102
104
  private _broadcastSubmittingEvents;
105
+ private _broadcasValidatingEvents;
103
106
  private _markControlsAsTouchedAndUpdateValidity;
104
107
  private _setupActiveSubmitButton;
105
108
  private _disableButtons;
@@ -13,7 +13,7 @@ export declare class FsControlDirective implements OnInit, AfterContentInit, OnD
13
13
  protected injector: Injector;
14
14
  protected _validateMessages: any;
15
15
  protected ngControl: NgControl;
16
- private formDirective;
16
+ protected formDirective: FsFormDirective;
17
17
  wrapperSelector: string | false;
18
18
  messageSelector: string | false;
19
19
  hintSelector: string | false;
@@ -7,8 +7,9 @@ import * as i0 from "@angular/core";
7
7
  export declare class FsFormFunctionDirective extends FsControlDirective implements OnChanges, FsAsyncValidator {
8
8
  fsFormFunction: any;
9
9
  fsFormFunctionData: any;
10
+ validateOnSubmit: boolean;
10
11
  ngOnChanges(): void;
11
12
  validateAsync(control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null>;
12
13
  static ɵfac: i0.ɵɵFactoryDeclaration<FsFormFunctionDirective, never>;
13
- static ɵdir: i0.ɵɵDirectiveDeclaration<FsFormFunctionDirective, "[fsFormFunction]", never, { "fsFormFunction": "fsFormFunction"; "fsFormFunctionData": "fsFormFunctionData"; }, {}, never>;
14
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FsFormFunctionDirective, "[fsFormFunction]", never, { "fsFormFunction": "fsFormFunction"; "fsFormFunctionData": "fsFormFunctionData"; "validateOnSubmit": "validateOnSubmit"; }, {}, never>;
14
15
  }
@@ -7,8 +7,9 @@ import * as i0 from "@angular/core";
7
7
  export declare class FsFormValidateDirective extends FsControlDirective implements OnChanges, FsAsyncValidator {
8
8
  validateFn: any;
9
9
  validateFnData: any;
10
+ validateOnSubmit: boolean;
10
11
  ngOnChanges(): void;
11
12
  validateAsync(control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null>;
12
13
  static ɵfac: i0.ɵɵFactoryDeclaration<FsFormValidateDirective, never>;
13
- static ɵdir: i0.ɵɵDirectiveDeclaration<FsFormValidateDirective, "[validate]", never, { "validateFn": "validate"; "validateFnData": "validateData"; }, {}, never>;
14
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FsFormValidateDirective, "[validate]", never, { "validateFn": "validate"; "validateFnData": "validateData"; "validateOnSubmit": "validateOnSubmit"; }, {}, never>;
14
15
  }
@@ -1,6 +1,7 @@
1
1
  export declare enum FormStatus {
2
2
  Valid = "valid",
3
3
  Invalid = "invalid",
4
+ Validating = "validating",
4
5
  Submitting = "submitting",
5
6
  Submitted = "submitted",
6
7
  Error = "error",
@@ -458,6 +458,7 @@
458
458
  (function (FormStatus) {
459
459
  FormStatus["Valid"] = "valid";
460
460
  FormStatus["Invalid"] = "invalid";
461
+ FormStatus["Validating"] = "validating";
461
462
  FormStatus["Submitting"] = "submitting";
462
463
  FormStatus["Submitted"] = "submitted";
463
464
  FormStatus["Error"] = "error";
@@ -547,7 +548,7 @@
547
548
  this.submitted = new i0.EventEmitter();
548
549
  this.reseted = new i0.EventEmitter();
549
550
  this.cleared = new i0.EventEmitter();
550
- this.fsformClass = true;
551
+ this.fsFormClass = true;
551
552
  this._tabGroups = new i0.QueryList();
552
553
  this._buttons = new i0.QueryList();
553
554
  this._dialogBackdropEscape = false;
@@ -562,6 +563,13 @@
562
563
  enumerable: false,
563
564
  configurable: true
564
565
  });
566
+ Object.defineProperty(FsFormDirective.prototype, "validating", {
567
+ get: function () {
568
+ return this._status$.getValue() === exports.FormStatus.Validating;
569
+ },
570
+ enumerable: false,
571
+ configurable: true
572
+ });
565
573
  Object.defineProperty(FsFormDirective.prototype, "completing", {
566
574
  get: function () {
567
575
  return this._status$.getValue() === exports.FormStatus.Completing;
@@ -636,6 +644,7 @@
636
644
  this._listenHotKeys();
637
645
  this._listenWindowClose();
638
646
  this._listenSubmit();
647
+ this._listenFormStatus();
639
648
  if (!this.autocomplete) {
640
649
  this._registerAutocomplete();
641
650
  }
@@ -718,7 +727,7 @@
718
727
  }), operators.filter(function () {
719
728
  return [exports.FormStatus.Valid, exports.FormStatus.Invalid]
720
729
  .includes(_this._status$.getValue());
721
- }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function () { return _this._waitUntilStatusPending(); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.tap(function () { return _this._disableButtons(); }), operators.mergeMap(function () {
730
+ }), operators.tap(function () { return _this._broadcasValidatingEvents(); }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function () { return _this._waitUntilStatusPending(); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.tap(function () { return _this._disableButtons(); }), operators.mergeMap(function () {
722
731
  return _this.ngForm.status === 'INVALID'
723
732
  ? _this._formInvalidState$
724
733
  : _this._formValidState$;
@@ -730,6 +739,19 @@
730
739
  }), operators.takeUntil(this._destroy$))
731
740
  .subscribe(function () { });
732
741
  };
742
+ FsFormDirective.prototype._listenFormStatus = function () {
743
+ var _this = this;
744
+ this._status$
745
+ .pipe(operators.takeUntil(this._destroy$))
746
+ .subscribe(function (formStatus) {
747
+ var cls = [exports.FormStatus.Submitting, exports.FormStatus.Validating];
748
+ var classList = _this._element.nativeElement.classList;
749
+ classList.remove.apply(classList, __spreadArray([], __read(cls)));
750
+ if (cls.indexOf(formStatus) !== -1) {
751
+ classList.add(formStatus);
752
+ }
753
+ });
754
+ };
733
755
  FsFormDirective.prototype._listenWindowClose = function () {
734
756
  var _this = this;
735
757
  rxjs.fromEvent(window, 'beforeunload')
@@ -1057,6 +1079,9 @@
1057
1079
  this._status$.next(exports.FormStatus.Submitting);
1058
1080
  this._form.broadcast('submit', this.ngForm);
1059
1081
  };
1082
+ FsFormDirective.prototype._broadcasValidatingEvents = function () {
1083
+ this._status$.next(exports.FormStatus.Validating);
1084
+ };
1060
1085
  FsFormDirective.prototype._markControlsAsTouchedAndUpdateValidity = function () {
1061
1086
  Object.values(this.ngForm.controls)
1062
1087
  .forEach(function (control) {
@@ -1096,7 +1121,7 @@
1096
1121
  return FsFormDirective;
1097
1122
  }());
1098
1123
  FsFormDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormDirective, deps: [{ token: i1.NgForm }, { token: FsForm }, { token: i0__namespace.ElementRef }, { token: i2__namespace.FsMessage }, { token: i3__namespace.FsPrompt }, { token: i0__namespace.NgZone }, { token: i2$1.MatDialogRef, optional: true }, { token: i6.DrawerRef, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1099
- FsFormDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDirective, selector: "[fsForm]", inputs: { wrapperSelector: "wrapperSelector", messageSelector: "messageSelector", hintSelector: "hintSelector", labelSelector: "labelSelector", autocomplete: "autocomplete", shortcuts: "shortcuts", confirm: "confirm", confirmDialog: "confirmDialog", confirmDrawer: "confirmDrawer", confirmBrowser: "confirmBrowser", confirmTabs: "confirmTabs", dirtySubmitButton: "dirtySubmitButton", submit: "submit", successDelay: "successDelay", errorDelay: "errorDelay", tabGroup: "tabGroup" }, outputs: { submitEvent: "fsForm", invalid: "invalid", valid: "valid", submitted: "submitted", reseted: "reseted", cleared: "cleared" }, host: { properties: { "class.fs-form": "this.fsformClass" } }, queries: [{ propertyName: "formDialogClose", predicate: FsFormDialogCloseDirective, descendants: true }, { propertyName: "_tabGroups", predicate: tabs.MatTabGroup, descendants: true }], usesOnChanges: true, ngImport: i0__namespace });
1124
+ FsFormDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDirective, selector: "[fsForm]", inputs: { wrapperSelector: "wrapperSelector", messageSelector: "messageSelector", hintSelector: "hintSelector", labelSelector: "labelSelector", autocomplete: "autocomplete", shortcuts: "shortcuts", confirm: "confirm", confirmDialog: "confirmDialog", confirmDrawer: "confirmDrawer", confirmBrowser: "confirmBrowser", confirmTabs: "confirmTabs", dirtySubmitButton: "dirtySubmitButton", submit: "submit", successDelay: "successDelay", errorDelay: "errorDelay", tabGroup: "tabGroup" }, outputs: { submitEvent: "fsForm", invalid: "invalid", valid: "valid", submitted: "submitted", reseted: "reseted", cleared: "cleared" }, host: { properties: { "class.fs-form": "this.fsFormClass" } }, queries: [{ propertyName: "formDialogClose", predicate: FsFormDialogCloseDirective, descendants: true }, { propertyName: "_tabGroups", predicate: tabs.MatTabGroup, descendants: true }], usesOnChanges: true, ngImport: i0__namespace });
1100
1125
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormDirective, decorators: [{
1101
1126
  type: i0.Directive,
1102
1127
  args: [{
@@ -1162,7 +1187,7 @@
1162
1187
  type: i0.Output
1163
1188
  }], cleared: [{
1164
1189
  type: i0.Output
1165
- }], fsformClass: [{
1190
+ }], fsFormClass: [{
1166
1191
  type: i0.HostBinding,
1167
1192
  args: ['class.fs-form']
1168
1193
  }], formDialogClose: [{
@@ -2111,18 +2136,23 @@
2111
2136
  var FsFormFunctionDirective = /** @class */ (function (_super) {
2112
2137
  __extends(FsFormFunctionDirective, _super);
2113
2138
  function FsFormFunctionDirective() {
2114
- return _super !== null && _super.apply(this, arguments) || this;
2139
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
2140
+ _this.validateOnSubmit = false;
2141
+ return _this;
2115
2142
  }
2116
2143
  FsFormFunctionDirective.prototype.ngOnChanges = function () {
2117
2144
  this._control.updateValueAndValidity();
2118
2145
  };
2119
2146
  FsFormFunctionDirective.prototype.validateAsync = function (control) {
2147
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2148
+ return rxjs.of(null);
2149
+ }
2120
2150
  return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
2121
2151
  };
2122
2152
  return FsFormFunctionDirective;
2123
2153
  }(FsControlDirective));
2124
2154
  FsFormFunctionDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormFunctionDirective, deps: null, target: i0__namespace.ɵɵFactoryTarget.Directive });
2125
- FsFormFunctionDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData" }, providers: [
2155
+ FsFormFunctionDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
2126
2156
  VALIDATE_MESSAGE_PROVIDER
2127
2157
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
2128
2158
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormFunctionDirective, decorators: [{
@@ -2137,6 +2167,8 @@
2137
2167
  type: i0.Input
2138
2168
  }], fsFormFunctionData: [{
2139
2169
  type: i0.Input
2170
+ }], validateOnSubmit: [{
2171
+ type: i0.Input
2140
2172
  }] } });
2141
2173
 
2142
2174
  var FsFormGreaterDirective = /** @class */ (function (_super) {
@@ -2464,18 +2496,23 @@
2464
2496
  var FsFormValidateDirective = /** @class */ (function (_super) {
2465
2497
  __extends(FsFormValidateDirective, _super);
2466
2498
  function FsFormValidateDirective() {
2467
- return _super !== null && _super.apply(this, arguments) || this;
2499
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
2500
+ _this.validateOnSubmit = false;
2501
+ return _this;
2468
2502
  }
2469
2503
  FsFormValidateDirective.prototype.ngOnChanges = function () {
2470
2504
  this._control.updateValueAndValidity();
2471
2505
  };
2472
2506
  FsFormValidateDirective.prototype.validateAsync = function (control) {
2507
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2508
+ return rxjs.of(null);
2509
+ }
2473
2510
  return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2474
2511
  };
2475
2512
  return FsFormValidateDirective;
2476
2513
  }(FsControlDirective));
2477
2514
  FsFormValidateDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormValidateDirective, deps: null, target: i0__namespace.ɵɵFactoryTarget.Directive });
2478
- FsFormValidateDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormValidateDirective, selector: "[validate]", inputs: { validateFn: ["validate", "validateFn"], validateFnData: ["validateData", "validateFnData"] }, providers: [
2515
+ FsFormValidateDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormValidateDirective, selector: "[validate]", inputs: { validateFn: ["validate", "validateFn"], validateFnData: ["validateData", "validateFnData"], validateOnSubmit: "validateOnSubmit" }, providers: [
2479
2516
  VALIDATE_MESSAGE_PROVIDER
2480
2517
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
2481
2518
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormValidateDirective, decorators: [{
@@ -2492,6 +2529,8 @@
2492
2529
  }], validateFnData: [{
2493
2530
  type: i0.Input,
2494
2531
  args: ['validateData']
2532
+ }], validateOnSubmit: [{
2533
+ type: i0.Input
2495
2534
  }] } });
2496
2535
 
2497
2536
  var FsFormDialogActionsComponent = /** @class */ (function () {