@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.
- package/app/directives/form/form.directive.d.ts +4 -1
- 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 +47 -8
- package/bundles/firestitch-form.umd.js.map +1 -1
- package/esm2015/app/directives/form/form.directive.js +24 -5
- 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 +44 -6
- package/fesm2015/firestitch-form.js.map +1 -1
- package/package.json +1 -1
|
@@ -150,6 +150,7 @@ var FormStatus;
|
|
|
150
150
|
(function (FormStatus) {
|
|
151
151
|
FormStatus["Valid"] = "valid";
|
|
152
152
|
FormStatus["Invalid"] = "invalid";
|
|
153
|
+
FormStatus["Validating"] = "validating";
|
|
153
154
|
FormStatus["Submitting"] = "submitting";
|
|
154
155
|
FormStatus["Submitted"] = "submitted";
|
|
155
156
|
FormStatus["Error"] = "error";
|
|
@@ -215,7 +216,7 @@ class FsFormDirective {
|
|
|
215
216
|
this.submitted = new EventEmitter();
|
|
216
217
|
this.reseted = new EventEmitter();
|
|
217
218
|
this.cleared = new EventEmitter();
|
|
218
|
-
this.
|
|
219
|
+
this.fsFormClass = true;
|
|
219
220
|
this._tabGroups = new QueryList();
|
|
220
221
|
this._buttons = new QueryList();
|
|
221
222
|
this._dialogBackdropEscape = false;
|
|
@@ -226,6 +227,9 @@ class FsFormDirective {
|
|
|
226
227
|
get submitting() {
|
|
227
228
|
return this._status$.getValue() === FormStatus.Submitting;
|
|
228
229
|
}
|
|
230
|
+
get validating() {
|
|
231
|
+
return this._status$.getValue() === FormStatus.Validating;
|
|
232
|
+
}
|
|
229
233
|
get completing() {
|
|
230
234
|
return this._status$.getValue() === FormStatus.Completing;
|
|
231
235
|
}
|
|
@@ -280,6 +284,7 @@ class FsFormDirective {
|
|
|
280
284
|
this._listenHotKeys();
|
|
281
285
|
this._listenWindowClose();
|
|
282
286
|
this._listenSubmit();
|
|
287
|
+
this._listenFormStatus();
|
|
283
288
|
if (!this.autocomplete) {
|
|
284
289
|
this._registerAutocomplete();
|
|
285
290
|
}
|
|
@@ -362,7 +367,7 @@ class FsFormDirective {
|
|
|
362
367
|
}), filter(() => {
|
|
363
368
|
return [FormStatus.Valid, FormStatus.Invalid]
|
|
364
369
|
.includes(this._status$.getValue());
|
|
365
|
-
}), tap(() => this._markControlsAsTouchedAndUpdateValidity()), tap(() => this._broadcastSubmittingEvents()), switchMap(() => this._waitUntilStatusPending()), tap(() => this._setupActiveSubmitButton()), tap(() => this._disableButtons()), mergeMap(() => {
|
|
370
|
+
}), tap(() => this._broadcasValidatingEvents()), tap(() => this._markControlsAsTouchedAndUpdateValidity()), tap(() => this._broadcastSubmittingEvents()), switchMap(() => this._waitUntilStatusPending()), tap(() => this._setupActiveSubmitButton()), tap(() => this._disableButtons()), mergeMap(() => {
|
|
366
371
|
return this.ngForm.status === 'INVALID'
|
|
367
372
|
? this._formInvalidState$
|
|
368
373
|
: this._formValidState$;
|
|
@@ -374,6 +379,18 @@ class FsFormDirective {
|
|
|
374
379
|
}), takeUntil(this._destroy$))
|
|
375
380
|
.subscribe(() => { });
|
|
376
381
|
}
|
|
382
|
+
_listenFormStatus() {
|
|
383
|
+
this._status$
|
|
384
|
+
.pipe(takeUntil(this._destroy$))
|
|
385
|
+
.subscribe((formStatus) => {
|
|
386
|
+
const cls = [FormStatus.Submitting, FormStatus.Validating];
|
|
387
|
+
const classList = this._element.nativeElement.classList;
|
|
388
|
+
classList.remove(...cls);
|
|
389
|
+
if (cls.indexOf(formStatus) !== -1) {
|
|
390
|
+
classList.add(formStatus);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
377
394
|
_listenWindowClose() {
|
|
378
395
|
fromEvent(window, 'beforeunload')
|
|
379
396
|
.pipe(takeUntil(this._destroy$))
|
|
@@ -685,6 +702,9 @@ class FsFormDirective {
|
|
|
685
702
|
this._status$.next(FormStatus.Submitting);
|
|
686
703
|
this._form.broadcast('submit', this.ngForm);
|
|
687
704
|
}
|
|
705
|
+
_broadcasValidatingEvents() {
|
|
706
|
+
this._status$.next(FormStatus.Validating);
|
|
707
|
+
}
|
|
688
708
|
_markControlsAsTouchedAndUpdateValidity() {
|
|
689
709
|
Object.values(this.ngForm.controls)
|
|
690
710
|
.forEach(control => {
|
|
@@ -723,7 +743,7 @@ class FsFormDirective {
|
|
|
723
743
|
}
|
|
724
744
|
}
|
|
725
745
|
FsFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, deps: [{ token: NgForm }, { token: FsForm }, { token: i0.ElementRef }, { token: i2.FsMessage }, { token: i3.FsPrompt }, { token: i0.NgZone }, { token: MatDialogRef, optional: true }, { token: DrawerRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
726
|
-
FsFormDirective.ɵdir = i0.ɵɵ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.
|
|
746
|
+
FsFormDirective.ɵdir = i0.ɵɵ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: MatTabGroup, descendants: true }], usesOnChanges: true, ngImport: i0 });
|
|
727
747
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, decorators: [{
|
|
728
748
|
type: Directive,
|
|
729
749
|
args: [{
|
|
@@ -787,7 +807,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
787
807
|
type: Output
|
|
788
808
|
}], cleared: [{
|
|
789
809
|
type: Output
|
|
790
|
-
}],
|
|
810
|
+
}], fsFormClass: [{
|
|
791
811
|
type: HostBinding,
|
|
792
812
|
args: ['class.fs-form']
|
|
793
813
|
}], formDialogClose: [{
|
|
@@ -1606,15 +1626,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
1606
1626
|
}] } });
|
|
1607
1627
|
|
|
1608
1628
|
class FsFormFunctionDirective extends FsControlDirective {
|
|
1629
|
+
constructor() {
|
|
1630
|
+
super(...arguments);
|
|
1631
|
+
this.validateOnSubmit = false;
|
|
1632
|
+
}
|
|
1609
1633
|
ngOnChanges() {
|
|
1610
1634
|
this._control.updateValueAndValidity();
|
|
1611
1635
|
}
|
|
1612
1636
|
validateAsync(control) {
|
|
1637
|
+
if (this.validateOnSubmit && !this.formDirective.validating) {
|
|
1638
|
+
return of(null);
|
|
1639
|
+
}
|
|
1613
1640
|
return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
|
|
1614
1641
|
}
|
|
1615
1642
|
}
|
|
1616
1643
|
FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1617
|
-
FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData" }, providers: [
|
|
1644
|
+
FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
|
|
1618
1645
|
VALIDATE_MESSAGE_PROVIDER
|
|
1619
1646
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1620
1647
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
|
|
@@ -1629,6 +1656,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
1629
1656
|
type: Input
|
|
1630
1657
|
}], fsFormFunctionData: [{
|
|
1631
1658
|
type: Input
|
|
1659
|
+
}], validateOnSubmit: [{
|
|
1660
|
+
type: Input
|
|
1632
1661
|
}] } });
|
|
1633
1662
|
|
|
1634
1663
|
class FsFormGreaterDirective extends FsControlDirective {
|
|
@@ -1926,15 +1955,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
1926
1955
|
}] } });
|
|
1927
1956
|
|
|
1928
1957
|
class FsFormValidateDirective extends FsControlDirective {
|
|
1958
|
+
constructor() {
|
|
1959
|
+
super(...arguments);
|
|
1960
|
+
this.validateOnSubmit = false;
|
|
1961
|
+
}
|
|
1929
1962
|
ngOnChanges() {
|
|
1930
1963
|
this._control.updateValueAndValidity();
|
|
1931
1964
|
}
|
|
1932
1965
|
validateAsync(control) {
|
|
1966
|
+
if (this.validateOnSubmit && !this.formDirective.validating) {
|
|
1967
|
+
return of(null);
|
|
1968
|
+
}
|
|
1933
1969
|
return FsValidators.func(this._control, this.validateFn, this.validateFnData);
|
|
1934
1970
|
}
|
|
1935
1971
|
}
|
|
1936
1972
|
FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1937
|
-
FsFormValidateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormValidateDirective, selector: "[validate]", inputs: { validateFn: ["validate", "validateFn"], validateFnData: ["validateData", "validateFnData"] }, providers: [
|
|
1973
|
+
FsFormValidateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormValidateDirective, selector: "[validate]", inputs: { validateFn: ["validate", "validateFn"], validateFnData: ["validateData", "validateFnData"], validateOnSubmit: "validateOnSubmit" }, providers: [
|
|
1938
1974
|
VALIDATE_MESSAGE_PROVIDER
|
|
1939
1975
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1940
1976
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormValidateDirective, decorators: [{
|
|
@@ -1951,6 +1987,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
1951
1987
|
}], validateFnData: [{
|
|
1952
1988
|
type: Input,
|
|
1953
1989
|
args: ['validateData']
|
|
1990
|
+
}], validateOnSubmit: [{
|
|
1991
|
+
type: Input
|
|
1954
1992
|
}] } });
|
|
1955
1993
|
|
|
1956
1994
|
class FsFormDialogActionsComponent {
|