@firestitch/form 12.3.2 → 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.
- package/app/directives/form/form.directive.d.ts +2 -0
- package/app/directives/validators/control.directive.d.ts +1 -1
- package/app/directives/validators/function.directive.d.ts +2 -1
- package/app/directives/validators/validate.directive.d.ts +2 -1
- package/app/enums/form-status.d.ts +1 -0
- package/bundles/firestitch-form.umd.js +30 -5
- package/bundles/firestitch-form.umd.js.map +1 -1
- package/esm2015/app/directives/form/form.directive.js +8 -2
- package/esm2015/app/directives/validators/control.directive.js +1 -1
- package/esm2015/app/directives/validators/function.directive.js +12 -2
- package/esm2015/app/directives/validators/validate.directive.js +12 -2
- package/esm2015/app/enums/form-status.js +2 -1
- package/fesm2015/firestitch-form.js +28 -3
- package/fesm2015/firestitch-form.js.map +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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 () {
|