@firestitch/form 12.3.1 → 12.3.3

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.
@@ -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$();
@@ -100,6 +101,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
100
101
  private _registerDirtySubmitButton;
101
102
  private _updateDirtySubmitButtons;
102
103
  private _broadcastSubmittingEvents;
104
+ private _broadcasValidatingEvents;
103
105
  private _markControlsAsTouchedAndUpdateValidity;
104
106
  private _setupActiveSubmitButton;
105
107
  private _disableButtons;
@@ -0,0 +1,2 @@
1
+ export * from './button.directive';
2
+ export * from './submit-button.directive';
@@ -0,0 +1,6 @@
1
+ import { FsButtonDirective } from './button.directive';
2
+ import * as i0 from "@angular/core";
3
+ export declare class FsSubmitButtonDirective extends FsButtonDirective {
4
+ static ɵfac: i0.ɵɵFactoryDeclaration<FsSubmitButtonDirective, never>;
5
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FsSubmitButtonDirective, "dummy-selector", never, {}, {}, never>;
6
+ }
@@ -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",
@@ -24,13 +24,14 @@ import * as i21 from "./directives/validators/validate.directive";
24
24
  import * as i22 from "./components/form-dialog-actions/form-dialog-actions.component";
25
25
  import * as i23 from "./directives/validators/no-fs-validators.directive";
26
26
  import * as i24 from "./directives/button.directive";
27
- import * as i25 from "@angular/common";
28
- import * as i26 from "@angular/forms";
29
- import * as i27 from "@angular/material/button";
30
- import * as i28 from "@angular/material/dialog";
27
+ import * as i25 from "./directives/submit-button.directive";
28
+ import * as i26 from "@angular/common";
29
+ import * as i27 from "@angular/forms";
30
+ import * as i28 from "@angular/material/button";
31
+ import * as i29 from "@angular/material/dialog";
31
32
  export declare class FsFormModule {
32
33
  static forRoot(): ModuleWithProviders<FsFormModule>;
33
34
  static ɵfac: i0.ɵɵFactoryDeclaration<FsFormModule, never>;
34
- static ɵmod: i0.ɵɵNgModuleDeclaration<FsFormModule, [typeof i1.FsFormDirective, typeof i2.FsControlDirective, typeof i3.FsFormRequiredDirective, typeof i4.FsFormMinDirective, typeof i5.FsFormMaxDirective, typeof i6.FsFormMinLengthDirective, typeof i7.FsFormMaxLengthDirective, typeof i8.FsFormEmailDirective, typeof i9.FsFormEmailsDirective, typeof i10.FsFormPhoneDirective, typeof i11.FsFormCompareDirective, typeof i12.FsFormIntegerDirective, typeof i13.FsFormNumericDirective, typeof i14.FsFormPatternDirective, typeof i15.FsFormFunctionDirective, typeof i16.FsFormDateRangeDirective, typeof i17.FsFormGreaterDirective, typeof i18.FsFormLesserDirective, typeof i19.FsFormUrlDirective, typeof i20.FsFormDialogCloseDirective, typeof i21.FsFormValidateDirective, typeof i22.FsFormDialogActionsComponent, typeof i23.FsFormNoFsValidatorsDirective, typeof i24.FsButtonDirective], [typeof i25.CommonModule, typeof i26.FormsModule, typeof i27.MatButtonModule, typeof i28.MatDialogModule], [typeof i1.FsFormDirective, typeof i2.FsControlDirective, typeof i3.FsFormRequiredDirective, typeof i4.FsFormMinDirective, typeof i5.FsFormMaxDirective, typeof i6.FsFormMinLengthDirective, typeof i7.FsFormMaxLengthDirective, typeof i8.FsFormEmailDirective, typeof i9.FsFormEmailsDirective, typeof i10.FsFormPhoneDirective, typeof i11.FsFormCompareDirective, typeof i12.FsFormIntegerDirective, typeof i13.FsFormNumericDirective, typeof i14.FsFormPatternDirective, typeof i15.FsFormFunctionDirective, typeof i16.FsFormDateRangeDirective, typeof i17.FsFormGreaterDirective, typeof i18.FsFormLesserDirective, typeof i19.FsFormUrlDirective, typeof i20.FsFormDialogCloseDirective, typeof i21.FsFormValidateDirective, typeof i22.FsFormDialogActionsComponent, typeof i23.FsFormNoFsValidatorsDirective, typeof i24.FsButtonDirective]>;
35
+ static ɵmod: i0.ɵɵNgModuleDeclaration<FsFormModule, [typeof i1.FsFormDirective, typeof i2.FsControlDirective, typeof i3.FsFormRequiredDirective, typeof i4.FsFormMinDirective, typeof i5.FsFormMaxDirective, typeof i6.FsFormMinLengthDirective, typeof i7.FsFormMaxLengthDirective, typeof i8.FsFormEmailDirective, typeof i9.FsFormEmailsDirective, typeof i10.FsFormPhoneDirective, typeof i11.FsFormCompareDirective, typeof i12.FsFormIntegerDirective, typeof i13.FsFormNumericDirective, typeof i14.FsFormPatternDirective, typeof i15.FsFormFunctionDirective, typeof i16.FsFormDateRangeDirective, typeof i17.FsFormGreaterDirective, typeof i18.FsFormLesserDirective, typeof i19.FsFormUrlDirective, typeof i20.FsFormDialogCloseDirective, typeof i21.FsFormValidateDirective, typeof i22.FsFormDialogActionsComponent, typeof i23.FsFormNoFsValidatorsDirective, typeof i24.FsButtonDirective, typeof i25.FsSubmitButtonDirective], [typeof i26.CommonModule, typeof i27.FormsModule, typeof i28.MatButtonModule, typeof i29.MatDialogModule], [typeof i1.FsFormDirective, typeof i2.FsControlDirective, typeof i3.FsFormRequiredDirective, typeof i4.FsFormMinDirective, typeof i5.FsFormMaxDirective, typeof i6.FsFormMinLengthDirective, typeof i7.FsFormMaxLengthDirective, typeof i8.FsFormEmailDirective, typeof i9.FsFormEmailsDirective, typeof i10.FsFormPhoneDirective, typeof i11.FsFormCompareDirective, typeof i12.FsFormIntegerDirective, typeof i13.FsFormNumericDirective, typeof i14.FsFormPatternDirective, typeof i15.FsFormFunctionDirective, typeof i16.FsFormDateRangeDirective, typeof i17.FsFormGreaterDirective, typeof i18.FsFormLesserDirective, typeof i19.FsFormUrlDirective, typeof i20.FsFormDialogCloseDirective, typeof i21.FsFormValidateDirective, typeof i22.FsFormDialogActionsComponent, typeof i23.FsFormNoFsValidatorsDirective, typeof i24.FsButtonDirective, typeof i25.FsSubmitButtonDirective]>;
35
36
  static ɵinj: i0.ɵɵInjectorDeclaration<FsFormModule>;
36
37
  }
@@ -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";
@@ -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;
@@ -718,7 +726,7 @@
718
726
  }), operators.filter(function () {
719
727
  return [exports.FormStatus.Valid, exports.FormStatus.Invalid]
720
728
  .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 () {
729
+ }), 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
730
  return _this.ngForm.status === 'INVALID'
723
731
  ? _this._formInvalidState$
724
732
  : _this._formValidState$;
@@ -1057,6 +1065,9 @@
1057
1065
  this._status$.next(exports.FormStatus.Submitting);
1058
1066
  this._form.broadcast('submit', this.ngForm);
1059
1067
  };
1068
+ FsFormDirective.prototype._broadcasValidatingEvents = function () {
1069
+ this._status$.next(exports.FormStatus.Validating);
1070
+ };
1060
1071
  FsFormDirective.prototype._markControlsAsTouchedAndUpdateValidity = function () {
1061
1072
  Object.values(this.ngForm.controls)
1062
1073
  .forEach(function (control) {
@@ -2111,18 +2122,23 @@
2111
2122
  var FsFormFunctionDirective = /** @class */ (function (_super) {
2112
2123
  __extends(FsFormFunctionDirective, _super);
2113
2124
  function FsFormFunctionDirective() {
2114
- return _super !== null && _super.apply(this, arguments) || this;
2125
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
2126
+ _this.validateOnSubmit = false;
2127
+ return _this;
2115
2128
  }
2116
2129
  FsFormFunctionDirective.prototype.ngOnChanges = function () {
2117
2130
  this._control.updateValueAndValidity();
2118
2131
  };
2119
2132
  FsFormFunctionDirective.prototype.validateAsync = function (control) {
2133
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2134
+ return rxjs.of(null);
2135
+ }
2120
2136
  return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
2121
2137
  };
2122
2138
  return FsFormFunctionDirective;
2123
2139
  }(FsControlDirective));
2124
2140
  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: [
2141
+ 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
2142
  VALIDATE_MESSAGE_PROVIDER
2127
2143
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
2128
2144
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormFunctionDirective, decorators: [{
@@ -2137,6 +2153,8 @@
2137
2153
  type: i0.Input
2138
2154
  }], fsFormFunctionData: [{
2139
2155
  type: i0.Input
2156
+ }], validateOnSubmit: [{
2157
+ type: i0.Input
2140
2158
  }] } });
2141
2159
 
2142
2160
  var FsFormGreaterDirective = /** @class */ (function (_super) {
@@ -2464,18 +2482,23 @@
2464
2482
  var FsFormValidateDirective = /** @class */ (function (_super) {
2465
2483
  __extends(FsFormValidateDirective, _super);
2466
2484
  function FsFormValidateDirective() {
2467
- return _super !== null && _super.apply(this, arguments) || this;
2485
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
2486
+ _this.validateOnSubmit = false;
2487
+ return _this;
2468
2488
  }
2469
2489
  FsFormValidateDirective.prototype.ngOnChanges = function () {
2470
2490
  this._control.updateValueAndValidity();
2471
2491
  };
2472
2492
  FsFormValidateDirective.prototype.validateAsync = function (control) {
2493
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2494
+ return rxjs.of(null);
2495
+ }
2473
2496
  return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2474
2497
  };
2475
2498
  return FsFormValidateDirective;
2476
2499
  }(FsControlDirective));
2477
2500
  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: [
2501
+ 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
2502
  VALIDATE_MESSAGE_PROVIDER
2480
2503
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
2481
2504
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormValidateDirective, decorators: [{
@@ -2492,6 +2515,8 @@
2492
2515
  }], validateFnData: [{
2493
2516
  type: i0.Input,
2494
2517
  args: ['validateData']
2518
+ }], validateOnSubmit: [{
2519
+ type: i0.Input
2495
2520
  }] } });
2496
2521
 
2497
2522
  var FsFormDialogActionsComponent = /** @class */ (function () {
@@ -2624,6 +2649,22 @@
2624
2649
  }]
2625
2650
  }] });
2626
2651
 
2652
+ var FsSubmitButtonDirective = /** @class */ (function (_super) {
2653
+ __extends(FsSubmitButtonDirective, _super);
2654
+ function FsSubmitButtonDirective() {
2655
+ return _super !== null && _super.apply(this, arguments) || this;
2656
+ }
2657
+ return FsSubmitButtonDirective;
2658
+ }(FsButtonDirective));
2659
+ FsSubmitButtonDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsSubmitButtonDirective, deps: null, target: i0__namespace.ɵɵFactoryTarget.Directive });
2660
+ FsSubmitButtonDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsSubmitButtonDirective, selector: "dummy-selector", usesInheritance: true, ngImport: i0__namespace });
2661
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsSubmitButtonDirective, decorators: [{
2662
+ type: i0.Directive,
2663
+ args: [{
2664
+ selector: 'dummy-selector',
2665
+ }]
2666
+ }] });
2667
+
2627
2668
  var FsFormModule = /** @class */ (function () {
2628
2669
  function FsFormModule() {
2629
2670
  }
@@ -2664,7 +2705,8 @@
2664
2705
  FsFormValidateDirective,
2665
2706
  FsFormDialogActionsComponent,
2666
2707
  FsFormNoFsValidatorsDirective,
2667
- FsButtonDirective], imports: [i4.CommonModule,
2708
+ FsButtonDirective,
2709
+ FsSubmitButtonDirective], imports: [i4.CommonModule,
2668
2710
  i1.FormsModule,
2669
2711
  i1$1.MatButtonModule,
2670
2712
  i2$1.MatDialogModule], exports: [FsFormDirective,
@@ -2690,7 +2732,8 @@
2690
2732
  FsFormValidateDirective,
2691
2733
  FsFormDialogActionsComponent,
2692
2734
  FsFormNoFsValidatorsDirective,
2693
- FsButtonDirective] });
2735
+ FsButtonDirective,
2736
+ FsSubmitButtonDirective] });
2694
2737
  FsFormModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FsFormModule, providers: [
2695
2738
  {
2696
2739
  provide: core.ErrorStateMatcher,
@@ -2736,6 +2779,7 @@
2736
2779
  FsFormDialogActionsComponent,
2737
2780
  FsFormNoFsValidatorsDirective,
2738
2781
  FsButtonDirective,
2782
+ FsSubmitButtonDirective,
2739
2783
  ],
2740
2784
  exports: [
2741
2785
  FsFormDirective,
@@ -2762,6 +2806,7 @@
2762
2806
  FsFormDialogActionsComponent,
2763
2807
  FsFormNoFsValidatorsDirective,
2764
2808
  FsButtonDirective,
2809
+ FsSubmitButtonDirective,
2765
2810
  ],
2766
2811
  providers: [
2767
2812
  {
@@ -2837,6 +2882,7 @@
2837
2882
  exports.FsFormRequiredDirective = FsFormRequiredDirective;
2838
2883
  exports.FsFormUrlDirective = FsFormUrlDirective;
2839
2884
  exports.FsFormValidateDirective = FsFormValidateDirective;
2885
+ exports.FsSubmitButtonDirective = FsSubmitButtonDirective;
2840
2886
  exports.FsValidators = FsValidators;
2841
2887
 
2842
2888
  Object.defineProperty(exports, '__esModule', { value: true });