@firestitch/form 12.3.4 → 12.4.0

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.
Files changed (105) hide show
  1. package/app/components/form-dialog-actions/form-dialog-actions.component.d.ts +22 -22
  2. package/app/consts/error-messages.const.d.ts +19 -19
  3. package/app/directives/button.directive.d.ts +34 -34
  4. package/app/directives/form/form.directive.d.ts +119 -113
  5. package/app/directives/form-dialog-close.directive.d.ts +12 -12
  6. package/app/directives/index.d.ts +2 -2
  7. package/app/directives/submit-button.directive.d.ts +6 -6
  8. package/app/directives/validators/compare.directive.d.ts +15 -15
  9. package/app/directives/validators/control.directive.d.ts +48 -48
  10. package/app/directives/validators/daterange.directive.d.ts +13 -13
  11. package/app/directives/validators/email.directive.d.ts +13 -13
  12. package/app/directives/validators/emails.directive.d.ts +13 -13
  13. package/app/directives/validators/function.directive.d.ts +15 -15
  14. package/app/directives/validators/greater.directive.d.ts +13 -13
  15. package/app/directives/validators/integer.directive.d.ts +13 -13
  16. package/app/directives/validators/lesser.directive.d.ts +13 -13
  17. package/app/directives/validators/max.directive.d.ts +13 -13
  18. package/app/directives/validators/maxlength.directive.d.ts +13 -13
  19. package/app/directives/validators/min.directive.d.ts +13 -13
  20. package/app/directives/validators/minlength.directive.d.ts +13 -13
  21. package/app/directives/validators/no-fs-validators.directive.d.ts +13 -13
  22. package/app/directives/validators/numeric.directive.d.ts +13 -13
  23. package/app/directives/validators/pattern.directive.d.ts +13 -13
  24. package/app/directives/validators/phone.directive.d.ts +13 -13
  25. package/app/directives/validators/required.directive.d.ts +16 -16
  26. package/app/directives/validators/url.directive.d.ts +14 -14
  27. package/app/directives/validators/validate.directive.d.ts +15 -15
  28. package/app/enums/confirm-result.d.ts +7 -7
  29. package/app/enums/form-status.d.ts +10 -10
  30. package/app/fs-form.module.d.ts +37 -37
  31. package/app/guards/form-deactivate.guard.d.ts +14 -12
  32. package/app/helpers/confirm-result-continue.d.ts +1 -1
  33. package/app/helpers/confirm-unsaved.d.ts +5 -5
  34. package/app/helpers/get-active-route.d.ts +2 -0
  35. package/app/helpers/get-form-errors.d.ts +2 -2
  36. package/app/helpers/index.d.ts +2 -2
  37. package/app/helpers/is-enabled.d.ts +1 -1
  38. package/app/interfaces/async-validator.d.ts +14 -14
  39. package/app/interfaces/confirm-config.d.ts +7 -7
  40. package/app/interfaces/confirm-tab-group.d.ts +10 -10
  41. package/app/interfaces/index.d.ts +4 -4
  42. package/app/interfaces/submit-event.d.ts +5 -5
  43. package/app/interfaces/submitted-event.d.ts +6 -6
  44. package/app/interfaces/validator.d.ts +13 -13
  45. package/app/providers/validate-messages.provider.d.ts +25 -25
  46. package/app/services/fsform.service.d.ts +16 -10
  47. package/app/validators/validators.d.ts +12 -12
  48. package/bundles/firestitch-form.umd.js +2828 -2767
  49. package/bundles/firestitch-form.umd.js.map +1 -1
  50. package/esm2015/app/components/form-dialog-actions/form-dialog-actions.component.js +88 -88
  51. package/esm2015/app/consts/error-messages.const.js +19 -19
  52. package/esm2015/app/directives/button.directive.js +150 -142
  53. package/esm2015/app/directives/form/form.directive.js +687 -656
  54. package/esm2015/app/directives/form-dialog-close.directive.js +30 -30
  55. package/esm2015/app/directives/index.js +2 -2
  56. package/esm2015/app/directives/submit-button.directive.js +13 -13
  57. package/esm2015/app/directives/validators/compare.directive.js +48 -48
  58. package/esm2015/app/directives/validators/control.directive.js +256 -256
  59. package/esm2015/app/directives/validators/daterange.directive.js +40 -40
  60. package/esm2015/app/directives/validators/email.directive.js +40 -40
  61. package/esm2015/app/directives/validators/emails.directive.js +40 -40
  62. package/esm2015/app/directives/validators/function.directive.js +40 -40
  63. package/esm2015/app/directives/validators/greater.directive.js +39 -39
  64. package/esm2015/app/directives/validators/integer.directive.js +40 -40
  65. package/esm2015/app/directives/validators/lesser.directive.js +39 -39
  66. package/esm2015/app/directives/validators/max.directive.js +35 -35
  67. package/esm2015/app/directives/validators/maxlength.directive.js +34 -34
  68. package/esm2015/app/directives/validators/min.directive.js +35 -35
  69. package/esm2015/app/directives/validators/minlength.directive.js +34 -34
  70. package/esm2015/app/directives/validators/no-fs-validators.directive.js +46 -46
  71. package/esm2015/app/directives/validators/numeric.directive.js +40 -40
  72. package/esm2015/app/directives/validators/pattern.directive.js +34 -34
  73. package/esm2015/app/directives/validators/phone.directive.js +40 -40
  74. package/esm2015/app/directives/validators/required.directive.js +70 -70
  75. package/esm2015/app/directives/validators/url.directive.js +46 -46
  76. package/esm2015/app/directives/validators/validate.directive.js +42 -42
  77. package/esm2015/app/enums/confirm-result.js +8 -8
  78. package/esm2015/app/enums/form-status.js +11 -11
  79. package/esm2015/app/fs-form.module.js +180 -180
  80. package/esm2015/app/guards/form-deactivate.guard.js +45 -40
  81. package/esm2015/app/helpers/confirm-result-continue.js +4 -4
  82. package/esm2015/app/helpers/confirm-unsaved.js +72 -70
  83. package/esm2015/app/helpers/get-active-route.js +7 -0
  84. package/esm2015/app/helpers/get-form-errors.js +24 -24
  85. package/esm2015/app/helpers/index.js +2 -2
  86. package/esm2015/app/helpers/is-enabled.js +3 -3
  87. package/esm2015/app/interfaces/async-validator.js +1 -1
  88. package/esm2015/app/interfaces/confirm-config.js +1 -1
  89. package/esm2015/app/interfaces/confirm-tab-group.js +1 -1
  90. package/esm2015/app/interfaces/index.js +4 -4
  91. package/esm2015/app/interfaces/submit-event.js +1 -1
  92. package/esm2015/app/interfaces/submitted-event.js +1 -1
  93. package/esm2015/app/interfaces/validator.js +1 -1
  94. package/esm2015/app/providers/validate-messages.provider.js +10 -10
  95. package/esm2015/app/services/fsform.service.js +40 -25
  96. package/esm2015/app/validators/validators.js +96 -96
  97. package/esm2015/firestitch-form.js +4 -4
  98. package/esm2015/public_api.js +37 -37
  99. package/fesm2015/firestitch-form.js +2263 -2202
  100. package/fesm2015/firestitch-form.js.map +1 -1
  101. package/firestitch-form.d.ts +5 -5
  102. package/package.json +1 -1
  103. package/public_api.d.ts +34 -35
  104. package/app/interfaces/form-deactivate.d.ts +0 -4
  105. package/esm2015/app/interfaces/form-deactivate.js +0 -2
@@ -2,1912 +2,2004 @@ import * as i0 from '@angular/core';
2
2
  import { Directive, HostBinding, HostListener, Injectable, EventEmitter, QueryList, Inject, Optional, Input, Output, ContentChildren, InjectionToken, Self, Host, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
3
3
  import * as i4 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
- import * as i1 from '@angular/forms';
5
+ import * as i1$1 from '@angular/forms';
6
6
  import { FormGroup, NgForm, Validators, FormsModule } from '@angular/forms';
7
- import * as i1$1 from '@angular/material/button';
7
+ import * as i1$2 from '@angular/material/button';
8
8
  import { MatButtonModule } from '@angular/material/button';
9
9
  import * as i2$1 from '@angular/material/dialog';
10
10
  import { MatDialogRef, MatDialogModule } from '@angular/material/dialog';
11
11
  import { ErrorStateMatcher, ShowOnDirtyErrorStateMatcher } from '@angular/material/core';
12
+ import * as i3 from '@angular/router';
12
13
  import { MatTabGroup } from '@angular/material/tabs';
13
14
  import * as i2 from '@firestitch/message';
14
15
  import { MessageMode } from '@firestitch/message';
15
- import * as i3 from '@firestitch/prompt';
16
+ import * as i1 from '@firestitch/prompt';
16
17
  import { guid, email, isEmpty, isNumeric, phone, url } from '@firestitch/common';
17
- import * as i6 from '@firestitch/drawer';
18
+ import * as i7 from '@firestitch/drawer';
18
19
  import { DrawerRef } from '@firestitch/drawer';
19
- import { Observable, Subject, BehaviorSubject, of, isObservable, throwError, fromEvent, iif, defer, from } from 'rxjs';
20
+ import { Observable, Subject, of, BehaviorSubject, isObservable, throwError, fromEvent, iif, defer, from } from 'rxjs';
20
21
  import { first, filter, map, take, mergeMap, tap, switchMap, catchError, takeUntil, delay, startWith } from 'rxjs/operators';
21
22
  import { values, keys, isObject } from 'lodash-es';
22
23
  import { isValid } from 'date-fns';
23
24
 
24
- var ConfirmResult;
25
- (function (ConfirmResult) {
26
- ConfirmResult["Save"] = "save";
27
- ConfirmResult["Discard"] = "discard";
28
- ConfirmResult["Review"] = "review";
29
- ConfirmResult["Invalid"] = "invalid";
30
- ConfirmResult["Pristine"] = "pristine";
25
+ var ConfirmResult;
26
+ (function (ConfirmResult) {
27
+ ConfirmResult["Save"] = "save";
28
+ ConfirmResult["Discard"] = "discard";
29
+ ConfirmResult["Review"] = "review";
30
+ ConfirmResult["Invalid"] = "invalid";
31
+ ConfirmResult["Pristine"] = "pristine";
31
32
  })(ConfirmResult || (ConfirmResult = {}));
32
33
 
33
- function confirmUnsaved(form, prompt) {
34
- return new Observable(observer => {
35
- if (!form.confirm || !form.ngForm.dirty) {
36
- observer.next(ConfirmResult.Pristine);
37
- observer.complete();
38
- return;
39
- }
40
- let title = 'You Have Unsaved Changes';
41
- let message = 'What would you like to do with your changes?';
42
- let saveLabel = 'Save & Continue';
43
- let discardLabel = 'Discard Changes & Continue';
44
- let cancelLabel = 'Review Changes';
45
- if (typeof form.confirm === 'object') {
46
- title = form.confirm.title || title;
47
- message = form.confirm.message || message;
48
- saveLabel = form.confirm.saveLabel || saveLabel;
49
- discardLabel = form.confirm.discardLabel || discardLabel;
50
- cancelLabel = form.confirm.cancelLabel || cancelLabel;
51
- }
52
- prompt.confirm({
53
- title: title,
54
- template: message,
55
- dialogConfig: { width: 'auto' },
56
- buttons: [
57
- {
58
- label: saveLabel,
59
- color: 'primary',
60
- value: 'save'
61
- },
62
- {
63
- label: discardLabel,
64
- value: 'discard'
65
- },
66
- {
67
- label: cancelLabel,
68
- cancel: true
69
- }
70
- ]
71
- }).subscribe((value) => {
72
- if (value === 'discard') {
73
- observer.next(ConfirmResult.Discard);
74
- observer.complete();
75
- form.reset();
76
- }
77
- if (value === 'save') {
78
- form.submitted
79
- .pipe(first())
80
- .subscribe(() => {
81
- observer.next(ConfirmResult.Save);
82
- observer.complete();
83
- });
84
- form.invalid
85
- .pipe(first())
86
- .subscribe(() => {
87
- observer.next(ConfirmResult.Invalid);
88
- observer.complete();
89
- });
90
- form.ngForm.control.markAsPristine();
91
- form.ngForm.ngSubmit.emit();
92
- }
93
- }, (error) => {
94
- observer.next(ConfirmResult.Review);
95
- observer.complete();
96
- });
97
- });
34
+ function confirmUnsaved(directives, prompt) {
35
+ return new Observable(observer => {
36
+ // TODO support for multiple directives per page
37
+ const form = directives[0];
38
+ if (!form.confirm || !form.ngForm.dirty) {
39
+ observer.next(ConfirmResult.Pristine);
40
+ observer.complete();
41
+ return;
42
+ }
43
+ let title = 'You Have Unsaved Changes';
44
+ let message = 'What would you like to do with your changes?';
45
+ let saveLabel = 'Save & Continue';
46
+ let discardLabel = 'Discard Changes & Continue';
47
+ let cancelLabel = 'Review Changes';
48
+ if (typeof form.confirm === 'object') {
49
+ title = form.confirm.title || title;
50
+ message = form.confirm.message || message;
51
+ saveLabel = form.confirm.saveLabel || saveLabel;
52
+ discardLabel = form.confirm.discardLabel || discardLabel;
53
+ cancelLabel = form.confirm.cancelLabel || cancelLabel;
54
+ }
55
+ prompt.confirm({
56
+ title: title,
57
+ template: message,
58
+ dialogConfig: { width: 'auto' },
59
+ buttons: [
60
+ {
61
+ label: saveLabel,
62
+ color: 'primary',
63
+ value: 'save'
64
+ },
65
+ {
66
+ label: discardLabel,
67
+ value: 'discard'
68
+ },
69
+ {
70
+ label: cancelLabel,
71
+ cancel: true
72
+ }
73
+ ]
74
+ }).subscribe((value) => {
75
+ if (value === 'discard') {
76
+ observer.next(ConfirmResult.Discard);
77
+ observer.complete();
78
+ form.reset();
79
+ }
80
+ if (value === 'save') {
81
+ form.submitted
82
+ .pipe(first())
83
+ .subscribe(() => {
84
+ observer.next(ConfirmResult.Save);
85
+ observer.complete();
86
+ });
87
+ form.invalid
88
+ .pipe(first())
89
+ .subscribe(() => {
90
+ observer.next(ConfirmResult.Invalid);
91
+ observer.complete();
92
+ });
93
+ form.ngForm.control.markAsPristine();
94
+ form.ngForm.ngSubmit.emit();
95
+ }
96
+ }, (error) => {
97
+ observer.next(ConfirmResult.Review);
98
+ observer.complete();
99
+ });
100
+ });
98
101
  }
99
102
 
100
- class FsFormDialogCloseDirective {
101
- constructor() {
102
- this.clicked$ = new Subject();
103
- this.registered = false;
104
- this.type = 'button';
105
- }
106
- click() {
107
- this.clicked$.next();
108
- }
109
- ngOnDestroy() {
110
- this.clicked$.complete();
111
- }
112
- }
113
- FsFormDialogCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
114
- FsFormDialogCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", host: { listeners: { "click": "click($event.target)" }, properties: { "attr.type": "this.type" } }, ngImport: i0 });
115
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
116
- type: Directive,
117
- args: [{
118
- selector: '[fsFormDialogClose],[fs-form-dialog-close]'
119
- }]
120
- }], propDecorators: { type: [{
121
- type: HostBinding,
122
- args: ['attr.type']
123
- }], click: [{
124
- type: HostListener,
125
- args: ['click', ['$event.target']]
103
+ class FsFormDialogCloseDirective {
104
+ constructor() {
105
+ this.clicked$ = new Subject();
106
+ this.registered = false;
107
+ this.type = 'button';
108
+ }
109
+ click() {
110
+ this.clicked$.next();
111
+ }
112
+ ngOnDestroy() {
113
+ this.clicked$.complete();
114
+ }
115
+ }
116
+ FsFormDialogCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
117
+ FsFormDialogCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", host: { listeners: { "click": "click($event.target)" }, properties: { "attr.type": "this.type" } }, ngImport: i0 });
118
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
119
+ type: Directive,
120
+ args: [{
121
+ selector: '[fsFormDialogClose],[fs-form-dialog-close]'
122
+ }]
123
+ }], propDecorators: { type: [{
124
+ type: HostBinding,
125
+ args: ['attr.type']
126
+ }], click: [{
127
+ type: HostListener,
128
+ args: ['click', ['$event.target']]
126
129
  }] } });
127
130
 
128
- class FsForm {
129
- constructor() {
130
- this._eventBus = new Subject();
131
- }
132
- broadcast(key, data) {
133
- this._eventBus.next({ key, data });
134
- }
135
- on(key) {
136
- return this._eventBus.asObservable()
137
- .pipe(filter(event => event.key === key), map(event => event.data));
138
- }
139
- }
140
- FsForm.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsForm, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
141
- FsForm.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsForm, providedIn: 'root' });
142
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsForm, decorators: [{
143
- type: Injectable,
144
- args: [{
145
- providedIn: 'root',
146
- }]
131
+ class FsForm {
132
+ constructor() {
133
+ // value is array for future possibilities of extension
134
+ this._formDirectiveStore = new WeakMap();
135
+ this._eventBus = new Subject();
136
+ }
137
+ // @deprecated
138
+ broadcast(key, data) {
139
+ this._eventBus.next({ key, data });
140
+ }
141
+ // @deprecated
142
+ on(key) {
143
+ return this._eventBus.asObservable()
144
+ .pipe(filter(event => event.key === key), map(event => event.data));
145
+ }
146
+ registerFormDirective(routeComponent, directive) {
147
+ const directives = this.getFormDirectives(routeComponent) || [];
148
+ directives.push(directive);
149
+ this._formDirectiveStore.set(routeComponent, directives);
150
+ }
151
+ getFormDirectives(routeComponent) {
152
+ return this._formDirectiveStore.get(routeComponent);
153
+ }
154
+ removeFormDirective(routeComponent) {
155
+ this._formDirectiveStore.delete(routeComponent);
156
+ }
157
+ }
158
+ FsForm.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsForm, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
159
+ FsForm.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsForm, providedIn: 'root' });
160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsForm, decorators: [{
161
+ type: Injectable,
162
+ args: [{
163
+ providedIn: 'root',
164
+ }]
147
165
  }], ctorParameters: function () { return []; } });
148
166
 
149
- var FormStatus;
150
- (function (FormStatus) {
151
- FormStatus["Valid"] = "valid";
152
- FormStatus["Invalid"] = "invalid";
153
- FormStatus["Validating"] = "validating";
154
- FormStatus["Submitting"] = "submitting";
155
- FormStatus["Submitted"] = "submitted";
156
- FormStatus["Error"] = "error";
157
- FormStatus["Success"] = "success";
158
- FormStatus["Completing"] = "completing";
167
+ var FormStatus;
168
+ (function (FormStatus) {
169
+ FormStatus["Valid"] = "valid";
170
+ FormStatus["Invalid"] = "invalid";
171
+ FormStatus["Validating"] = "validating";
172
+ FormStatus["Submitting"] = "submitting";
173
+ FormStatus["Submitted"] = "submitted";
174
+ FormStatus["Error"] = "error";
175
+ FormStatus["Success"] = "success";
176
+ FormStatus["Completing"] = "completing";
159
177
  })(FormStatus || (FormStatus = {}));
160
178
 
161
- function confirmResultContinue(result) {
162
- return result === ConfirmResult.Discard || result === ConfirmResult.Save || result === ConfirmResult.Pristine;
179
+ function confirmResultContinue(result) {
180
+ return result === ConfirmResult.Discard || result === ConfirmResult.Save || result === ConfirmResult.Pristine;
163
181
  }
164
182
 
165
- function getFormErrors(control, key) {
166
- let errors = null;
167
- if (control.invalid && control.errors) {
168
- errors = {
169
- [key]: Object.assign({}, control.errors),
170
- };
171
- }
172
- if (control instanceof FormGroup) {
173
- Object.entries(control.controls)
174
- .forEach(([name, childControl]) => {
175
- const childErrors = getFormErrors(childControl, name);
176
- if (childErrors) {
177
- if (!errors) {
178
- errors = Object.assign({}, childErrors);
179
- }
180
- else {
181
- Object.assign(errors, childErrors);
182
- }
183
- }
184
- });
185
- }
186
- return errors;
183
+ function getFormErrors(control, key) {
184
+ let errors = null;
185
+ if (control.invalid && control.errors) {
186
+ errors = {
187
+ [key]: Object.assign({}, control.errors),
188
+ };
189
+ }
190
+ if (control instanceof FormGroup) {
191
+ Object.entries(control.controls)
192
+ .forEach(([name, childControl]) => {
193
+ const childErrors = getFormErrors(childControl, name);
194
+ if (childErrors) {
195
+ if (!errors) {
196
+ errors = Object.assign({}, childErrors);
197
+ }
198
+ else {
199
+ Object.assign(errors, childErrors);
200
+ }
201
+ }
202
+ });
203
+ }
204
+ return errors;
187
205
  }
188
206
 
189
- class FsFormDirective {
190
- constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef) {
191
- this.ngForm = ngForm;
192
- this._form = _form;
193
- this._element = _element;
194
- this._message = _message;
195
- this._prompt = _prompt;
196
- this._ngZone = _ngZone;
197
- this._dialogRef = _dialogRef;
198
- this._drawerRef = _drawerRef;
199
- this.wrapperSelector = '.fs-form-wrapper,.mat-form-field';
200
- this.messageSelector = '.fs-form-message,.mat-form-field-subscript-wrapper';
201
- this.hintSelector = '.fs-form-hint,.mat-form-field-hint-wrapper';
202
- this.labelSelector = '.fs-form-label,.mat-form-field-label';
203
- this.autocomplete = false;
204
- this.shortcuts = true; // Ctrl + s
205
- this.confirm = true;
206
- this.confirmDialog = true;
207
- this.confirmDrawer = true;
208
- this.confirmBrowser = true;
209
- this.confirmTabs = true;
210
- this.dirtySubmitButton = true;
211
- this.successDelay = 0;
212
- this.errorDelay = 1000;
213
- this.submitEvent = new EventEmitter();
214
- this.invalid = new EventEmitter();
215
- this.valid = new EventEmitter();
216
- this.submitted = new EventEmitter();
217
- this.reseted = new EventEmitter();
218
- this.cleared = new EventEmitter();
219
- this.fsFormClass = true;
220
- this._tabGroups = new QueryList();
221
- this._buttons = new QueryList();
222
- this._dialogBackdropEscape = false;
223
- this._snapshot = {};
224
- this._status$ = new BehaviorSubject(FormStatus.Valid);
225
- this._destroy$ = new Subject();
226
- }
227
- get submitting() {
228
- return this._status$.getValue() === FormStatus.Submitting;
229
- }
230
- get validating() {
231
- return this._status$.getValue() === FormStatus.Validating;
232
- }
233
- get completing() {
234
- return this._status$.getValue() === FormStatus.Completing;
235
- }
236
- get _submitEvent() {
237
- return {
238
- ngForm: this.ngForm,
239
- submitter: this._submitter,
240
- };
241
- }
242
- get _formValidState$() {
243
- this._form.broadcast('valid', this._submitEvent);
244
- this.submitEvent.emit(this._submitEvent);
245
- this.valid.emit(this._submitEvent);
246
- const submittedEvent = {
247
- ngForm: this.ngForm,
248
- submitter: this._submitter,
249
- response: null
250
- };
251
- if (!this.submit) {
252
- return of(submittedEvent);
253
- }
254
- const result = this.submit(this._submitEvent);
255
- if (!isObservable(result)) {
256
- return of(submittedEvent);
257
- }
258
- return result
259
- .pipe(map((response) => {
260
- submittedEvent.response = response;
261
- return submittedEvent;
262
- }));
263
- }
264
- get _formInvalidState$() {
265
- this._form.broadcast('invalid', this._submitEvent);
266
- if (this.invalid) {
267
- this.invalid.emit(this._submitEvent);
268
- }
269
- const message = 'Changes not saved. Please review errors highlighted in red.';
270
- this._message.error(message, { mode: MessageMode.Toast });
271
- const el = this._element.nativeElement.querySelector('.ng-invalid');
272
- if (el) {
273
- el.scrollIntoView({ behavior: 'smooth', block: 'center' });
274
- }
275
- return throwError('Form validation error');
276
- }
277
- get _submitter() {
278
- return this._activeSubmitButton
279
- ? this._activeSubmitButton.name
280
- : null;
281
- }
282
- ngOnInit() {
283
- this._registerConfirmDialogBackdropEscape();
284
- this._listenHotKeys();
285
- this._listenWindowClose();
286
- this._listenSubmit();
287
- this._listenFormStatus();
288
- if (!this.autocomplete) {
289
- this._registerAutocomplete();
290
- }
291
- }
292
- ngOnChanges(changes) {
293
- if (changes.confirm) {
294
- this._updateDirtySubmitButtons();
295
- }
296
- }
297
- ngAfterContentInit() {
298
- this._registerConfirm();
299
- this._registerConfirmDialogClose();
300
- this._registerConfirmDrawerClose();
301
- this._registerConfirmTabs();
302
- this._registerDrawerClose();
303
- this._registerDirtySubmitButton();
304
- }
305
- ngOnDestroy() {
306
- this._destroy$.next();
307
- this._destroy$.complete();
308
- }
309
- createSnapshot() {
310
- this._snapshot = this.ngForm.value;
311
- }
312
- getSnapshot() {
313
- return this._snapshot || {};
314
- }
315
- reset() {
316
- this.ngForm.resetForm();
317
- Object.keys(this.ngForm.controls)
318
- .forEach((name) => {
319
- const control = this.ngForm.controls[name];
320
- control.reset(this._snapshot[name]);
321
- });
322
- this.reseted.emit();
323
- }
324
- clear() {
325
- this.ngForm.resetForm();
326
- this.cleared.emit();
327
- }
328
- dirty() {
329
- this.ngForm.form.markAsDirty();
330
- this._updateDirtySubmitButtons();
331
- }
332
- triggerSubmit() {
333
- this.ngForm.ngSubmit.next();
334
- }
335
- triggerConfirm() {
336
- const submitted = this.submitting ? this.submitted.asObservable() : of({});
337
- return submitted
338
- .pipe(take(1), mergeMap(() => confirmUnsaved(this, this._prompt)));
339
- }
340
- enable() {
341
- this.ngForm.control.enable();
342
- this._updateDirtySubmitButtons();
343
- }
344
- disable() {
345
- this.ngForm.control.disable();
346
- this._buttons.forEach((button) => {
347
- button.disable();
348
- });
349
- }
350
- addButton(button) {
351
- this._buttons.reset([
352
- ...this._buttons.toArray(),
353
- button,
354
- ]);
355
- }
356
- removeButton(button) {
357
- this._buttons.reset([
358
- ...this._buttons.toArray()
359
- .filter((item) => (button !== item)),
360
- ]);
361
- }
362
- _listenSubmit() {
363
- this.ngForm
364
- .ngSubmit
365
- .pipe(tap((event) => {
366
- event === null || event === void 0 ? void 0 : event.preventDefault();
367
- }), filter(() => {
368
- return [FormStatus.Valid, FormStatus.Invalid]
369
- .includes(this._status$.getValue());
370
- }), tap(() => this._broadcasValidatingEvents()), tap(() => this._markControlsAsTouchedAndUpdateValidity()), tap(() => this._broadcastSubmittingEvents()), switchMap(() => this._waitUntilStatusPending()), tap(() => this._setupActiveSubmitButton()), tap(() => this._disableButtons()), mergeMap(() => {
371
- return this.ngForm.status === 'INVALID'
372
- ? this._formInvalidState$
373
- : this._formValidState$;
374
- }), catchError((e, source$) => {
375
- this._handleError(e);
376
- return source$;
377
- }), tap((submittedEvent) => {
378
- this._completeSubmit(true, submittedEvent);
379
- }), takeUntil(this._destroy$))
380
- .subscribe(() => { });
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
- }
394
- _listenWindowClose() {
395
- fromEvent(window, 'beforeunload')
396
- .pipe(takeUntil(this._destroy$))
397
- .subscribe((event) => {
398
- if (this.confirm && this.confirmBrowser && this.ngForm.dirty) {
399
- event.returnValue = false;
400
- }
401
- });
402
- }
403
- _listenHotKeys() {
404
- this._ngZone.runOutsideAngular(() => {
405
- fromEvent(document, 'keydown')
406
- .pipe(takeUntil(this._destroy$))
407
- .subscribe((event) => {
408
- if (this._dialogBackdropEscape && event.code === 'Escape') {
409
- const dialog = document.getElementById(this._dialogRef.id);
410
- const paths = event.composedPath();
411
- if (paths) {
412
- paths.forEach(item => {
413
- if (dialog === item) {
414
- this._ngZone.run(() => {
415
- this._formClose();
416
- });
417
- }
418
- });
419
- }
420
- }
421
- if ((event.ctrlKey || event.metaKey) && event.code === 'KeyS') {
422
- event.preventDefault();
423
- if (this.shortcuts) {
424
- if (this._elementInForm(document.activeElement)) {
425
- this.ngForm.ngSubmit.next();
426
- }
427
- }
428
- }
429
- });
430
- });
431
- }
432
- _formClose() {
433
- if (this.confirm && this.confirmDialog) {
434
- this.triggerConfirm()
435
- .pipe(filter((result) => confirmResultContinue(result)), switchMap((result) => {
436
- return result === ConfirmResult.Pristine || result === ConfirmResult.Discard
437
- ? of(null)
438
- : this.submitted.asObservable();
439
- }), takeUntil(this._destroy$))
440
- .subscribe((result) => {
441
- this._dialogRef.close(result === null || result === void 0 ? void 0 : result.response);
442
- });
443
- }
444
- else {
445
- this._dialogRef.close(null);
446
- }
447
- }
448
- _registerDialogClose(directive) {
449
- if (!directive.registered) {
450
- directive.registered = true;
451
- directive.clicked$
452
- .pipe(takeUntil(this._destroy$))
453
- .subscribe(() => {
454
- this._formClose();
455
- });
456
- }
457
- }
458
- _getActiveSubmitButton() {
459
- const submitButtons = this._buttons
460
- .filter((button) => button.submit);
461
- const activeButton = submitButtons
462
- .find(button => {
463
- return button.active;
464
- });
465
- return activeButton ? activeButton : submitButtons[0];
466
- }
467
- _elementInForm(el) {
468
- if (el.isSameNode(this._element.nativeElement)) {
469
- return true;
470
- }
471
- else if (el.parentElement) {
472
- return this._elementInForm(el.parentElement);
473
- }
474
- return false;
475
- }
476
- _completeSubmit(success, submitEvent) {
477
- if (success) {
478
- this.ngForm.control.markAsPristine();
479
- this.createSnapshot();
480
- this.submitted.emit(submitEvent);
481
- }
482
- else {
483
- this._resetButtons();
484
- }
485
- if (this._activeSubmitButton) {
486
- if (success) {
487
- this._activeSubmitButton.success();
488
- }
489
- else {
490
- this._activeSubmitButton.error();
491
- }
492
- }
493
- this._status$.next(FormStatus.Submitted);
494
- if (success) {
495
- this._status$.next(FormStatus.Success);
496
- }
497
- else {
498
- this._status$.next(FormStatus.Error);
499
- }
500
- this._status$.next(FormStatus.Completing);
501
- const resetDelay = success ? this.successDelay : this.errorDelay;
502
- of(true)
503
- .pipe(delay(resetDelay), first(), takeUntil(this._destroy$)).subscribe(() => {
504
- if (this.ngForm.form.status === 'VALID') {
505
- this._status$.next(FormStatus.Valid);
506
- }
507
- else {
508
- this._status$.next(FormStatus.Invalid);
509
- }
510
- this._resetButtons();
511
- this._resetActiveButtons();
512
- this._updateDirtySubmitButtons();
513
- });
514
- }
515
- _resetButtons() {
516
- this._buttons.forEach((button) => {
517
- button.reset();
518
- });
519
- }
520
- _resetActiveButtons() {
521
- this._buttons.forEach((button) => {
522
- button.resetActive();
523
- });
524
- }
525
- _registerConfirm() {
526
- this.ngForm.form.valueChanges
527
- .pipe(takeUntil(this._destroy$))
528
- .subscribe((changes) => {
529
- if (this.confirm) {
530
- const existing = Object.keys(this._snapshot);
531
- Object.keys(changes)
532
- .forEach((name) => {
533
- if (existing.indexOf(name) === -1) {
534
- this._snapshot[name] = changes[name];
535
- }
536
- });
537
- }
538
- });
539
- }
540
- _registerDrawerClose() {
541
- if (this._drawerRef) {
542
- this._drawerRef.closeStart$
543
- .pipe(takeUntil(this._destroy$))
544
- .subscribe((subscriber) => {
545
- if (this.submitting) {
546
- this._status$
547
- .pipe(filter((status) => status === FormStatus.Success || status === FormStatus.Error), takeUntil(this._destroy$))
548
- .subscribe((status) => {
549
- if (status === FormStatus.Success) {
550
- subscriber.next();
551
- subscriber.complete();
552
- }
553
- else {
554
- subscriber.error();
555
- }
556
- });
557
- }
558
- else {
559
- subscriber.next();
560
- subscriber.complete();
561
- }
562
- });
563
- }
564
- }
565
- _registerConfirmDrawerClose() {
566
- if (this._drawerRef) {
567
- this._drawerRef.closeStart$
568
- .pipe(switchMap((subscriber) => {
569
- return iif(() => this.confirm && this.confirmDrawer, this.triggerConfirm()
570
- .pipe(map((result) => confirmResultContinue(result)), tap((result) => {
571
- if (result) {
572
- subscriber.next();
573
- subscriber.complete();
574
- }
575
- })), defer(() => {
576
- subscriber.next();
577
- subscriber.complete();
578
- }));
579
- }), takeUntil(this._destroy$))
580
- .subscribe();
581
- }
582
- }
583
- _registerConfirmTabs() {
584
- if (this.tabGroup) {
585
- this.registerConfirmTabGroup(this.tabGroup);
586
- }
587
- this.registerConfirmTabGroups(this._tabGroups.toArray());
588
- this._tabGroups.changes
589
- .pipe(takeUntil(this._destroy$))
590
- .subscribe(() => {
591
- this.registerConfirmTabGroups(this._tabGroups.toArray());
592
- });
593
- }
594
- registerConfirmTabGroups(tabGroups) {
595
- tabGroups.forEach((tabGroup) => {
596
- this.registerConfirmTabGroup(tabGroup);
597
- });
598
- }
599
- registerConfirmTabGroup(tabGroup) {
600
- const confirmTabGroup = tabGroup;
601
- if (!confirmTabGroup._originalHandleClick) {
602
- confirmTabGroup._originalHandleClick = tabGroup._handleClick;
603
- confirmTabGroup._handlClick$ = new Subject();
604
- confirmTabGroup._handleClick = (tab, tabHeader, idx) => {
605
- if (confirmTabGroup._handlClick$.observers.length) {
606
- confirmTabGroup._handlClick$.next({ tab, tabHeader, idx });
607
- }
608
- else {
609
- confirmTabGroup._originalHandleClick(tab, tabHeader, idx);
610
- }
611
- };
612
- }
613
- confirmTabGroup._handlClick$
614
- .pipe(takeUntil(this._destroy$))
615
- .subscribe((event) => {
616
- if (!this.submitting) {
617
- if (this.confirm && this.confirmTabs) {
618
- this.triggerConfirm()
619
- .pipe(takeUntil(this._destroy$))
620
- .subscribe((result) => {
621
- if (confirmResultContinue(result)) {
622
- confirmTabGroup.selectedIndex = event.idx;
623
- }
624
- });
625
- }
626
- else {
627
- confirmTabGroup._originalHandleClick(event.tab, event.tabHeader, event.idx);
628
- }
629
- }
630
- });
631
- }
632
- _registerConfirmDialogClose() {
633
- if (this._dialogRef) {
634
- this.formDialogClose.forEach(item => {
635
- this._registerDialogClose(item);
636
- });
637
- this.formDialogClose.changes
638
- .pipe(takeUntil(this._destroy$))
639
- .subscribe((e) => {
640
- e.forEach(item => {
641
- this._registerDialogClose(item);
642
- });
643
- });
644
- }
645
- }
646
- _registerConfirmDialogBackdropEscape() {
647
- this._dialogBackdropEscape = this._dialogRef && this._dialogRef.disableClose !== true;
648
- if (this._dialogRef && !this._dialogRef.disableClose) {
649
- this._dialogRef.disableClose = true;
650
- this._dialogRef.backdropClick()
651
- .pipe(takeUntil(this._destroy$))
652
- .subscribe(() => {
653
- this._formClose();
654
- });
655
- this._destroy$
656
- .subscribe(() => {
657
- this._dialogRef.disableClose = false;
658
- });
659
- }
660
- }
661
- _registerAutocomplete() {
662
- this._registerControl = this.ngForm.form.registerControl.bind(this.ngForm.form);
663
- this.ngForm.form.registerControl = (name, control) => {
664
- const el = this._element.nativeElement.querySelector(`input[name='${name}']`);
665
- if (el) {
666
- el.setAttribute('name', name + '_' + guid());
667
- if (!el.getAttribute('autocomplete')) {
668
- el.setAttribute('autocomplete', 'none');
669
- }
670
- }
671
- return this._registerControl(name, control);
672
- };
673
- }
674
- _registerDirtySubmitButton() {
675
- if (!this.ngForm) {
676
- return;
677
- }
678
- this.ngForm.form.valueChanges
679
- .pipe(takeUntil(this._destroy$))
680
- .subscribe(() => {
681
- this._updateDirtySubmitButtons();
682
- });
683
- this._buttons.changes
684
- .pipe(takeUntil(this._destroy$))
685
- .subscribe(() => {
686
- this._updateDirtySubmitButtons();
687
- });
688
- }
689
- _updateDirtySubmitButtons() {
690
- this._buttons
691
- .filter((button) => button.submit)
692
- .forEach((submitButton) => {
693
- if (!this.confirm || !this.dirtySubmitButton || this.ngForm.dirty || !submitButton.dirtySubmit) {
694
- submitButton.enable();
695
- }
696
- else {
697
- submitButton.disable();
698
- }
699
- });
700
- }
701
- _broadcastSubmittingEvents() {
702
- this._status$.next(FormStatus.Submitting);
703
- this._form.broadcast('submit', this.ngForm);
704
- }
705
- _broadcasValidatingEvents() {
706
- this._status$.next(FormStatus.Validating);
707
- }
708
- _markControlsAsTouchedAndUpdateValidity() {
709
- Object.values(this.ngForm.controls)
710
- .forEach(control => {
711
- control.markAsDirty();
712
- control.markAsTouched();
713
- control.updateValueAndValidity();
714
- });
715
- }
716
- _setupActiveSubmitButton() {
717
- this._activeSubmitButton = this._getActiveSubmitButton();
718
- this._resetButtons();
719
- if (this._activeSubmitButton) {
720
- this._activeSubmitButton.process();
721
- }
722
- }
723
- _disableButtons() {
724
- this._buttons.forEach((button) => {
725
- button.disable();
726
- });
727
- }
728
- _waitUntilStatusPending() {
729
- return this.ngForm.statusChanges
730
- .pipe(startWith(this.ngForm.status), first((state) => state !== 'PENDING'));
731
- }
732
- _handleError(e) {
733
- console.log('%c Form Submit ', 'color: white; background-color: #D33F49', 'Error occured');
734
- console.group('Error Details:');
735
- console.log('Message: ', e);
736
- console.log('FormRef: ', this);
737
- if (this.ngForm.invalid) {
738
- const errors = getFormErrors(this.ngForm.control, null);
739
- console.log('Validation Errors: ', errors);
740
- }
741
- console.groupEnd();
742
- this._completeSubmit(false, null);
743
- }
744
- }
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 });
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 });
747
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, decorators: [{
748
- type: Directive,
749
- args: [{
750
- selector: '[fsForm]',
751
- }]
752
- }], ctorParameters: function () { return [{ type: i1.NgForm, decorators: [{
753
- type: Inject,
754
- args: [NgForm]
755
- }] }, { type: FsForm }, { type: i0.ElementRef }, { type: i2.FsMessage }, { type: i3.FsPrompt }, { type: i0.NgZone }, { type: i2$1.MatDialogRef, decorators: [{
756
- type: Optional
757
- }, {
758
- type: Inject,
759
- args: [MatDialogRef]
760
- }] }, { type: i6.DrawerRef, decorators: [{
761
- type: Optional
762
- }, {
763
- type: Inject,
764
- args: [DrawerRef]
765
- }] }]; }, propDecorators: { wrapperSelector: [{
766
- type: Input
767
- }], messageSelector: [{
768
- type: Input
769
- }], hintSelector: [{
770
- type: Input
771
- }], labelSelector: [{
772
- type: Input
773
- }], autocomplete: [{
774
- type: Input
775
- }], shortcuts: [{
776
- type: Input
777
- }], confirm: [{
778
- type: Input
779
- }], confirmDialog: [{
780
- type: Input
781
- }], confirmDrawer: [{
782
- type: Input
783
- }], confirmBrowser: [{
784
- type: Input
785
- }], confirmTabs: [{
786
- type: Input
787
- }], dirtySubmitButton: [{
788
- type: Input
789
- }], submit: [{
790
- type: Input
791
- }], successDelay: [{
792
- type: Input
793
- }], errorDelay: [{
794
- type: Input
795
- }], tabGroup: [{
796
- type: Input
797
- }], submitEvent: [{
798
- type: Output,
799
- args: ['fsForm']
800
- }], invalid: [{
801
- type: Output
802
- }], valid: [{
803
- type: Output
804
- }], submitted: [{
805
- type: Output
806
- }], reseted: [{
807
- type: Output
808
- }], cleared: [{
809
- type: Output
810
- }], fsFormClass: [{
811
- type: HostBinding,
812
- args: ['class.fs-form']
813
- }], formDialogClose: [{
814
- type: ContentChildren,
815
- args: [FsFormDialogCloseDirective, { descendants: true }]
816
- }], _tabGroups: [{
817
- type: ContentChildren,
818
- args: [MatTabGroup, { descendants: true }]
207
+ function getActiveRoute(route) {
208
+ while (route.firstChild) {
209
+ route = route.firstChild;
210
+ }
211
+ return route;
212
+ }
213
+
214
+ class FormDeactivateGuard {
215
+ constructor(_prompt, _fsForm, _route) {
216
+ this._prompt = _prompt;
217
+ this._fsForm = _fsForm;
218
+ this._route = _route;
219
+ }
220
+ canDeactivate() {
221
+ const route = getActiveRoute(this._route);
222
+ if (!route) {
223
+ console.error(`Can not find route for FormDeactivateGuard checks`);
224
+ return of(true);
225
+ }
226
+ const directives = this._fsForm.getFormDirectives(route.routeConfig.component);
227
+ if (!Array.isArray(directives) || directives.length === 0) {
228
+ console.error(`Can not find a valid FsFormDirective`);
229
+ return of(true);
230
+ }
231
+ return confirmUnsaved(directives, this._prompt)
232
+ .pipe(map((result) => {
233
+ return confirmResultContinue(result);
234
+ }));
235
+ }
236
+ }
237
+ FormDeactivateGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormDeactivateGuard, deps: [{ token: i1.FsPrompt }, { token: FsForm }, { token: i3.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
238
+ FormDeactivateGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormDeactivateGuard, providedIn: 'root' });
239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormDeactivateGuard, decorators: [{
240
+ type: Injectable,
241
+ args: [{
242
+ providedIn: 'root',
243
+ }]
244
+ }], ctorParameters: function () { return [{ type: i1.FsPrompt }, { type: FsForm }, { type: i3.ActivatedRoute }]; } });
245
+
246
+ class FsFormDirective {
247
+ constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef, _route) {
248
+ this.ngForm = ngForm;
249
+ this._form = _form;
250
+ this._element = _element;
251
+ this._message = _message;
252
+ this._prompt = _prompt;
253
+ this._ngZone = _ngZone;
254
+ this._dialogRef = _dialogRef;
255
+ this._drawerRef = _drawerRef;
256
+ this._route = _route;
257
+ this.wrapperSelector = '.fs-form-wrapper,.mat-form-field';
258
+ this.messageSelector = '.fs-form-message,.mat-form-field-subscript-wrapper';
259
+ this.hintSelector = '.fs-form-hint,.mat-form-field-hint-wrapper';
260
+ this.labelSelector = '.fs-form-label,.mat-form-field-label';
261
+ this.autocomplete = false;
262
+ this.shortcuts = true; // Ctrl + s
263
+ this.confirm = true;
264
+ this.confirmDialog = true;
265
+ this.confirmDrawer = true;
266
+ this.confirmBrowser = true;
267
+ this.confirmTabs = true;
268
+ this.dirtySubmitButton = true;
269
+ this.successDelay = 0;
270
+ this.errorDelay = 1000;
271
+ this.deactivationGuard = true;
272
+ this.submitEvent = new EventEmitter();
273
+ this.invalid = new EventEmitter();
274
+ this.valid = new EventEmitter();
275
+ this.submitted = new EventEmitter();
276
+ this.reseted = new EventEmitter();
277
+ this.cleared = new EventEmitter();
278
+ this.fsFormClass = true;
279
+ this._tabGroups = new QueryList();
280
+ this._buttons = new QueryList();
281
+ this._dialogBackdropEscape = false;
282
+ this._snapshot = {};
283
+ this._status$ = new BehaviorSubject(FormStatus.Valid);
284
+ this._destroy$ = new Subject();
285
+ }
286
+ get submitting() {
287
+ return this._status$.getValue() === FormStatus.Submitting;
288
+ }
289
+ get validating() {
290
+ return this._status$.getValue() === FormStatus.Validating;
291
+ }
292
+ get completing() {
293
+ return this._status$.getValue() === FormStatus.Completing;
294
+ }
295
+ get _submitEvent() {
296
+ return {
297
+ ngForm: this.ngForm,
298
+ submitter: this._submitter,
299
+ };
300
+ }
301
+ get _formValidState$() {
302
+ this._form.broadcast('valid', this._submitEvent);
303
+ this.submitEvent.emit(this._submitEvent);
304
+ this.valid.emit(this._submitEvent);
305
+ const submittedEvent = {
306
+ ngForm: this.ngForm,
307
+ submitter: this._submitter,
308
+ response: null
309
+ };
310
+ if (!this.submit) {
311
+ return of(submittedEvent);
312
+ }
313
+ const result = this.submit(this._submitEvent);
314
+ if (!isObservable(result)) {
315
+ return of(submittedEvent);
316
+ }
317
+ return result
318
+ .pipe(map((response) => {
319
+ submittedEvent.response = response;
320
+ return submittedEvent;
321
+ }));
322
+ }
323
+ get _formInvalidState$() {
324
+ this._form.broadcast('invalid', this._submitEvent);
325
+ if (this.invalid) {
326
+ this.invalid.emit(this._submitEvent);
327
+ }
328
+ const message = 'Changes not saved. Please review errors highlighted in red.';
329
+ this._message.error(message, { mode: MessageMode.Toast });
330
+ const el = this._element.nativeElement.querySelector('.ng-invalid');
331
+ if (el) {
332
+ el.scrollIntoView({ behavior: 'smooth', block: 'center' });
333
+ }
334
+ return throwError('Form validation error');
335
+ }
336
+ get _submitter() {
337
+ return this._activeSubmitButton
338
+ ? this._activeSubmitButton.name
339
+ : null;
340
+ }
341
+ ngOnInit() {
342
+ if (this.deactivationGuard) {
343
+ this._registerCanDeactivateGuard();
344
+ }
345
+ this._registerConfirmDialogBackdropEscape();
346
+ this._listenHotKeys();
347
+ this._listenWindowClose();
348
+ this._listenSubmit();
349
+ this._listenFormStatus();
350
+ if (!this.autocomplete) {
351
+ this._registerAutocomplete();
352
+ }
353
+ }
354
+ ngOnChanges(changes) {
355
+ if (changes.confirm) {
356
+ this._updateDirtySubmitButtons();
357
+ }
358
+ }
359
+ ngAfterContentInit() {
360
+ this._registerConfirm();
361
+ this._registerConfirmDialogClose();
362
+ this._registerConfirmDrawerClose();
363
+ this._registerConfirmTabs();
364
+ this._registerDrawerClose();
365
+ this._registerDirtySubmitButton();
366
+ }
367
+ ngOnDestroy() {
368
+ this._cleanupCanDeactivate();
369
+ this._destroy$.next();
370
+ this._destroy$.complete();
371
+ }
372
+ createSnapshot() {
373
+ this._snapshot = this.ngForm.value;
374
+ }
375
+ getSnapshot() {
376
+ return this._snapshot || {};
377
+ }
378
+ reset() {
379
+ this.ngForm.resetForm();
380
+ Object.keys(this.ngForm.controls)
381
+ .forEach((name) => {
382
+ const control = this.ngForm.controls[name];
383
+ control.reset(this._snapshot[name]);
384
+ });
385
+ this.reseted.emit();
386
+ }
387
+ clear() {
388
+ this.ngForm.resetForm();
389
+ this.cleared.emit();
390
+ }
391
+ dirty() {
392
+ this.ngForm.form.markAsDirty();
393
+ this._updateDirtySubmitButtons();
394
+ }
395
+ triggerSubmit() {
396
+ this.ngForm.ngSubmit.next();
397
+ }
398
+ triggerConfirm() {
399
+ const submitted = this.submitting ? this.submitted.asObservable() : of({});
400
+ return submitted
401
+ .pipe(take(1), mergeMap(() => confirmUnsaved([this], this._prompt)));
402
+ }
403
+ enable() {
404
+ this.ngForm.control.enable();
405
+ this._updateDirtySubmitButtons();
406
+ }
407
+ disable() {
408
+ this.ngForm.control.disable();
409
+ this._buttons.forEach((button) => {
410
+ button.disable();
411
+ });
412
+ }
413
+ addButton(button) {
414
+ this._buttons.reset([
415
+ ...this._buttons.toArray(),
416
+ button,
417
+ ]);
418
+ }
419
+ removeButton(button) {
420
+ this._buttons.reset([
421
+ ...this._buttons.toArray()
422
+ .filter((item) => (button !== item)),
423
+ ]);
424
+ }
425
+ _listenSubmit() {
426
+ this.ngForm
427
+ .ngSubmit
428
+ .pipe(tap((event) => {
429
+ event === null || event === void 0 ? void 0 : event.preventDefault();
430
+ }), filter(() => {
431
+ return [FormStatus.Valid, FormStatus.Invalid]
432
+ .includes(this._status$.getValue());
433
+ }), tap(() => this._broadcasValidatingEvents()), tap(() => this._markControlsAsTouchedAndUpdateValidity()), tap(() => this._broadcastSubmittingEvents()), switchMap(() => this._waitUntilStatusPending()), tap(() => this._setupActiveSubmitButton()), tap(() => this._disableButtons()), mergeMap(() => {
434
+ return this.ngForm.status === 'INVALID'
435
+ ? this._formInvalidState$
436
+ : this._formValidState$;
437
+ }), catchError((e, source$) => {
438
+ this._handleError(e);
439
+ return source$;
440
+ }), tap((submittedEvent) => {
441
+ this._completeSubmit(true, submittedEvent);
442
+ }), takeUntil(this._destroy$))
443
+ .subscribe(() => { });
444
+ }
445
+ _listenFormStatus() {
446
+ this._status$
447
+ .pipe(takeUntil(this._destroy$))
448
+ .subscribe((formStatus) => {
449
+ const cls = [FormStatus.Submitting, FormStatus.Validating];
450
+ const classList = this._element.nativeElement.classList;
451
+ classList.remove(...cls);
452
+ if (cls.indexOf(formStatus) !== -1) {
453
+ classList.add(formStatus);
454
+ }
455
+ });
456
+ }
457
+ _listenWindowClose() {
458
+ fromEvent(window, 'beforeunload')
459
+ .pipe(takeUntil(this._destroy$))
460
+ .subscribe((event) => {
461
+ if (this.confirm && this.confirmBrowser && this.ngForm.dirty) {
462
+ event.returnValue = false;
463
+ }
464
+ });
465
+ }
466
+ _listenHotKeys() {
467
+ this._ngZone.runOutsideAngular(() => {
468
+ fromEvent(document, 'keydown')
469
+ .pipe(takeUntil(this._destroy$))
470
+ .subscribe((event) => {
471
+ if (this._dialogBackdropEscape && event.code === 'Escape') {
472
+ const dialog = document.getElementById(this._dialogRef.id);
473
+ const paths = event.composedPath();
474
+ if (paths) {
475
+ paths.forEach(item => {
476
+ if (dialog === item) {
477
+ this._ngZone.run(() => {
478
+ this._formClose();
479
+ });
480
+ }
481
+ });
482
+ }
483
+ }
484
+ if ((event.ctrlKey || event.metaKey) && event.code === 'KeyS') {
485
+ event.preventDefault();
486
+ if (this.shortcuts) {
487
+ if (this._elementInForm(document.activeElement)) {
488
+ this.ngForm.ngSubmit.next();
489
+ }
490
+ }
491
+ }
492
+ });
493
+ });
494
+ }
495
+ _formClose() {
496
+ if (this.confirm && this.confirmDialog) {
497
+ this.triggerConfirm()
498
+ .pipe(filter((result) => confirmResultContinue(result)), switchMap((result) => {
499
+ return result === ConfirmResult.Pristine || result === ConfirmResult.Discard
500
+ ? of(null)
501
+ : this.submitted.asObservable();
502
+ }), takeUntil(this._destroy$))
503
+ .subscribe((result) => {
504
+ this._dialogRef.close(result === null || result === void 0 ? void 0 : result.response);
505
+ });
506
+ }
507
+ else {
508
+ this._dialogRef.close(null);
509
+ }
510
+ }
511
+ _registerDialogClose(directive) {
512
+ if (!directive.registered) {
513
+ directive.registered = true;
514
+ directive.clicked$
515
+ .pipe(takeUntil(this._destroy$))
516
+ .subscribe(() => {
517
+ this._formClose();
518
+ });
519
+ }
520
+ }
521
+ _getActiveSubmitButton() {
522
+ const submitButtons = this._buttons
523
+ .filter((button) => button.submit);
524
+ const activeButton = submitButtons
525
+ .find(button => {
526
+ return button.active;
527
+ });
528
+ return activeButton ? activeButton : submitButtons[0];
529
+ }
530
+ _elementInForm(el) {
531
+ if (el.isSameNode(this._element.nativeElement)) {
532
+ return true;
533
+ }
534
+ else if (el.parentElement) {
535
+ return this._elementInForm(el.parentElement);
536
+ }
537
+ return false;
538
+ }
539
+ _completeSubmit(success, submitEvent) {
540
+ if (success) {
541
+ this.ngForm.control.markAsPristine();
542
+ this.createSnapshot();
543
+ this.submitted.emit(submitEvent);
544
+ }
545
+ else {
546
+ this._resetButtons();
547
+ }
548
+ if (this._activeSubmitButton) {
549
+ if (success) {
550
+ this._activeSubmitButton.success();
551
+ }
552
+ else {
553
+ this._activeSubmitButton.error();
554
+ }
555
+ }
556
+ this._status$.next(FormStatus.Submitted);
557
+ if (success) {
558
+ this._status$.next(FormStatus.Success);
559
+ }
560
+ else {
561
+ this._status$.next(FormStatus.Error);
562
+ }
563
+ this._status$.next(FormStatus.Completing);
564
+ const resetDelay = success ? this.successDelay : this.errorDelay;
565
+ of(true)
566
+ .pipe(delay(resetDelay), first(), takeUntil(this._destroy$)).subscribe(() => {
567
+ if (this.ngForm.form.status === 'VALID') {
568
+ this._status$.next(FormStatus.Valid);
569
+ }
570
+ else {
571
+ this._status$.next(FormStatus.Invalid);
572
+ }
573
+ this._resetButtons();
574
+ this._resetActiveButtons();
575
+ this._updateDirtySubmitButtons();
576
+ });
577
+ }
578
+ _resetButtons() {
579
+ this._buttons.forEach((button) => {
580
+ button.reset();
581
+ });
582
+ }
583
+ _resetActiveButtons() {
584
+ this._buttons.forEach((button) => {
585
+ button.resetActive();
586
+ });
587
+ }
588
+ _registerConfirm() {
589
+ this.ngForm.form.valueChanges
590
+ .pipe(takeUntil(this._destroy$))
591
+ .subscribe((changes) => {
592
+ if (this.confirm) {
593
+ const existing = Object.keys(this._snapshot);
594
+ Object.keys(changes)
595
+ .forEach((name) => {
596
+ if (existing.indexOf(name) === -1) {
597
+ this._snapshot[name] = changes[name];
598
+ }
599
+ });
600
+ }
601
+ });
602
+ }
603
+ _registerDrawerClose() {
604
+ if (this._drawerRef) {
605
+ this._drawerRef.closeStart$
606
+ .pipe(takeUntil(this._destroy$))
607
+ .subscribe((subscriber) => {
608
+ if (this.submitting) {
609
+ this._status$
610
+ .pipe(filter((status) => status === FormStatus.Success || status === FormStatus.Error), takeUntil(this._destroy$))
611
+ .subscribe((status) => {
612
+ if (status === FormStatus.Success) {
613
+ subscriber.next();
614
+ subscriber.complete();
615
+ }
616
+ else {
617
+ subscriber.error();
618
+ }
619
+ });
620
+ }
621
+ else {
622
+ subscriber.next();
623
+ subscriber.complete();
624
+ }
625
+ });
626
+ }
627
+ }
628
+ _registerConfirmDrawerClose() {
629
+ if (this._drawerRef) {
630
+ this._drawerRef.closeStart$
631
+ .pipe(switchMap((subscriber) => {
632
+ return iif(() => this.confirm && this.confirmDrawer, this.triggerConfirm()
633
+ .pipe(map((result) => confirmResultContinue(result)), tap((result) => {
634
+ if (result) {
635
+ subscriber.next();
636
+ subscriber.complete();
637
+ }
638
+ })), defer(() => {
639
+ subscriber.next();
640
+ subscriber.complete();
641
+ }));
642
+ }), takeUntil(this._destroy$))
643
+ .subscribe();
644
+ }
645
+ }
646
+ _registerConfirmTabs() {
647
+ if (this.tabGroup) {
648
+ this.registerConfirmTabGroup(this.tabGroup);
649
+ }
650
+ this.registerConfirmTabGroups(this._tabGroups.toArray());
651
+ this._tabGroups.changes
652
+ .pipe(takeUntil(this._destroy$))
653
+ .subscribe(() => {
654
+ this.registerConfirmTabGroups(this._tabGroups.toArray());
655
+ });
656
+ }
657
+ registerConfirmTabGroups(tabGroups) {
658
+ tabGroups.forEach((tabGroup) => {
659
+ this.registerConfirmTabGroup(tabGroup);
660
+ });
661
+ }
662
+ registerConfirmTabGroup(tabGroup) {
663
+ const confirmTabGroup = tabGroup;
664
+ if (!confirmTabGroup._originalHandleClick) {
665
+ confirmTabGroup._originalHandleClick = tabGroup._handleClick;
666
+ confirmTabGroup._handlClick$ = new Subject();
667
+ confirmTabGroup._handleClick = (tab, tabHeader, idx) => {
668
+ if (confirmTabGroup._handlClick$.observers.length) {
669
+ confirmTabGroup._handlClick$.next({ tab, tabHeader, idx });
670
+ }
671
+ else {
672
+ confirmTabGroup._originalHandleClick(tab, tabHeader, idx);
673
+ }
674
+ };
675
+ }
676
+ confirmTabGroup._handlClick$
677
+ .pipe(takeUntil(this._destroy$))
678
+ .subscribe((event) => {
679
+ if (!this.submitting) {
680
+ if (this.confirm && this.confirmTabs) {
681
+ this.triggerConfirm()
682
+ .pipe(takeUntil(this._destroy$))
683
+ .subscribe((result) => {
684
+ if (confirmResultContinue(result)) {
685
+ confirmTabGroup.selectedIndex = event.idx;
686
+ }
687
+ });
688
+ }
689
+ else {
690
+ confirmTabGroup._originalHandleClick(event.tab, event.tabHeader, event.idx);
691
+ }
692
+ }
693
+ });
694
+ }
695
+ _registerConfirmDialogClose() {
696
+ if (this._dialogRef) {
697
+ this.formDialogClose.forEach(item => {
698
+ this._registerDialogClose(item);
699
+ });
700
+ this.formDialogClose.changes
701
+ .pipe(takeUntil(this._destroy$))
702
+ .subscribe((e) => {
703
+ e.forEach(item => {
704
+ this._registerDialogClose(item);
705
+ });
706
+ });
707
+ }
708
+ }
709
+ _registerConfirmDialogBackdropEscape() {
710
+ this._dialogBackdropEscape = this._dialogRef && this._dialogRef.disableClose !== true;
711
+ if (this._dialogRef && !this._dialogRef.disableClose) {
712
+ this._dialogRef.disableClose = true;
713
+ this._dialogRef.backdropClick()
714
+ .pipe(takeUntil(this._destroy$))
715
+ .subscribe(() => {
716
+ this._formClose();
717
+ });
718
+ this._destroy$
719
+ .subscribe(() => {
720
+ this._dialogRef.disableClose = false;
721
+ });
722
+ }
723
+ }
724
+ _registerAutocomplete() {
725
+ this._registerControl = this.ngForm.form.registerControl.bind(this.ngForm.form);
726
+ this.ngForm.form.registerControl = (name, control) => {
727
+ const el = this._element.nativeElement.querySelector(`input[name='${name}']`);
728
+ if (el) {
729
+ el.setAttribute('name', name + '_' + guid());
730
+ if (!el.getAttribute('autocomplete')) {
731
+ el.setAttribute('autocomplete', 'none');
732
+ }
733
+ }
734
+ return this._registerControl(name, control);
735
+ };
736
+ }
737
+ _registerDirtySubmitButton() {
738
+ if (!this.ngForm) {
739
+ return;
740
+ }
741
+ this.ngForm.form.valueChanges
742
+ .pipe(takeUntil(this._destroy$))
743
+ .subscribe(() => {
744
+ this._updateDirtySubmitButtons();
745
+ });
746
+ this._buttons.changes
747
+ .pipe(takeUntil(this._destroy$))
748
+ .subscribe(() => {
749
+ this._updateDirtySubmitButtons();
750
+ });
751
+ }
752
+ _updateDirtySubmitButtons() {
753
+ this._buttons
754
+ .filter((button) => button.submit)
755
+ .forEach((submitButton) => {
756
+ if (!this.confirm || !this.dirtySubmitButton || this.ngForm.dirty || !submitButton.dirtySubmit) {
757
+ submitButton.enable();
758
+ }
759
+ else {
760
+ submitButton.disable();
761
+ }
762
+ });
763
+ }
764
+ _broadcastSubmittingEvents() {
765
+ this._status$.next(FormStatus.Submitting);
766
+ this._form.broadcast('submit', this.ngForm);
767
+ }
768
+ _broadcasValidatingEvents() {
769
+ this._status$.next(FormStatus.Validating);
770
+ }
771
+ _markControlsAsTouchedAndUpdateValidity() {
772
+ Object.values(this.ngForm.controls)
773
+ .forEach(control => {
774
+ control.markAsDirty();
775
+ control.markAsTouched();
776
+ control.updateValueAndValidity();
777
+ });
778
+ }
779
+ _setupActiveSubmitButton() {
780
+ this._activeSubmitButton = this._getActiveSubmitButton();
781
+ this._resetButtons();
782
+ if (this._activeSubmitButton) {
783
+ this._activeSubmitButton.process();
784
+ }
785
+ }
786
+ _disableButtons() {
787
+ this._buttons.forEach((button) => {
788
+ button.disable();
789
+ });
790
+ }
791
+ _waitUntilStatusPending() {
792
+ return this.ngForm.statusChanges
793
+ .pipe(startWith(this.ngForm.status), first((state) => state !== 'PENDING'));
794
+ }
795
+ _handleError(e) {
796
+ console.log('%c Form Submit ', 'color: white; background-color: #D33F49', 'Error occured');
797
+ console.group('Error Details:');
798
+ console.log('Message: ', e);
799
+ console.log('FormRef: ', this);
800
+ if (this.ngForm.invalid) {
801
+ const errors = getFormErrors(this.ngForm.control, null);
802
+ console.log('Validation Errors: ', errors);
803
+ }
804
+ console.groupEnd();
805
+ this._completeSubmit(false, null);
806
+ }
807
+ _registerCanDeactivateGuard() {
808
+ this._activatedRouteConfig = getActiveRoute(this._route).routeConfig;
809
+ if (!this._activatedRouteConfig) {
810
+ return;
811
+ }
812
+ this._form.registerFormDirective(this._activatedRouteConfig.component, this);
813
+ if (!Array.isArray(this._activatedRouteConfig.canDeactivate)) {
814
+ this._activatedRouteConfig.canDeactivate = [];
815
+ }
816
+ if (this._activatedRouteConfig.canDeactivate.indexOf(FormDeactivateGuard) == -1) {
817
+ this._activatedRouteConfig.canDeactivate.push(FormDeactivateGuard);
818
+ }
819
+ }
820
+ _cleanupCanDeactivate() {
821
+ if (!this._activatedRouteConfig) {
822
+ return;
823
+ }
824
+ this._form.removeFormDirective(this._activatedRouteConfig.component);
825
+ }
826
+ }
827
+ 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: i1.FsPrompt }, { token: i0.NgZone }, { token: MatDialogRef, optional: true }, { token: DrawerRef, optional: true }, { token: i3.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Directive });
828
+ 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", deactivationGuard: "deactivationGuard" }, 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 });
829
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, decorators: [{
830
+ type: Directive,
831
+ args: [{
832
+ selector: '[fsForm]',
833
+ }]
834
+ }], ctorParameters: function () { return [{ type: i1$1.NgForm, decorators: [{
835
+ type: Inject,
836
+ args: [NgForm]
837
+ }] }, { type: FsForm }, { type: i0.ElementRef }, { type: i2.FsMessage }, { type: i1.FsPrompt }, { type: i0.NgZone }, { type: i2$1.MatDialogRef, decorators: [{
838
+ type: Optional
839
+ }, {
840
+ type: Inject,
841
+ args: [MatDialogRef]
842
+ }] }, { type: i7.DrawerRef, decorators: [{
843
+ type: Optional
844
+ }, {
845
+ type: Inject,
846
+ args: [DrawerRef]
847
+ }] }, { type: i3.ActivatedRoute }]; }, propDecorators: { wrapperSelector: [{
848
+ type: Input
849
+ }], messageSelector: [{
850
+ type: Input
851
+ }], hintSelector: [{
852
+ type: Input
853
+ }], labelSelector: [{
854
+ type: Input
855
+ }], autocomplete: [{
856
+ type: Input
857
+ }], shortcuts: [{
858
+ type: Input
859
+ }], confirm: [{
860
+ type: Input
861
+ }], confirmDialog: [{
862
+ type: Input
863
+ }], confirmDrawer: [{
864
+ type: Input
865
+ }], confirmBrowser: [{
866
+ type: Input
867
+ }], confirmTabs: [{
868
+ type: Input
869
+ }], dirtySubmitButton: [{
870
+ type: Input
871
+ }], submit: [{
872
+ type: Input
873
+ }], successDelay: [{
874
+ type: Input
875
+ }], errorDelay: [{
876
+ type: Input
877
+ }], tabGroup: [{
878
+ type: Input
879
+ }], deactivationGuard: [{
880
+ type: Input
881
+ }], submitEvent: [{
882
+ type: Output,
883
+ args: ['fsForm']
884
+ }], invalid: [{
885
+ type: Output
886
+ }], valid: [{
887
+ type: Output
888
+ }], submitted: [{
889
+ type: Output
890
+ }], reseted: [{
891
+ type: Output
892
+ }], cleared: [{
893
+ type: Output
894
+ }], fsFormClass: [{
895
+ type: HostBinding,
896
+ args: ['class.fs-form']
897
+ }], formDialogClose: [{
898
+ type: ContentChildren,
899
+ args: [FsFormDialogCloseDirective, { descendants: true }]
900
+ }], _tabGroups: [{
901
+ type: ContentChildren,
902
+ args: [MatTabGroup, { descendants: true }]
819
903
  }] } });
820
904
 
821
- const ERROR_MESSAGES = {
822
- required: 'This field is required',
823
- email: 'This is not a valid email address',
824
- emails: 'Input valid email addresses, comma separated',
825
- phone: 'Invalid phone number',
826
- numeric: 'Value should be numeric',
827
- integer: 'Value should be an integer',
828
- min: 'Value should not be less than $(1)',
829
- max: 'Value should not be greater than $(1)',
830
- minlength: 'Should not be shorter than $(1) characters',
831
- maxlength: 'Should not be longer than $(1) characters',
832
- compare: 'Inputs do not match',
833
- pattern: 'Value should match pattern $(1)',
834
- dateRange: 'Invalid date range',
835
- url: 'This is not a valid url',
836
- urlProtocol: 'Invalid URL. Proper http protocol is required. eg. https://google.com',
837
- greater: 'Value must be greater than $(1)',
838
- lesser: 'Value must be less than $(1)',
905
+ const ERROR_MESSAGES = {
906
+ required: 'This field is required',
907
+ email: 'This is not a valid email address',
908
+ emails: 'Input valid email addresses, comma separated',
909
+ phone: 'Invalid phone number',
910
+ numeric: 'Value should be numeric',
911
+ integer: 'Value should be an integer',
912
+ min: 'Value should not be less than $(1)',
913
+ max: 'Value should not be greater than $(1)',
914
+ minlength: 'Should not be shorter than $(1) characters',
915
+ maxlength: 'Should not be longer than $(1) characters',
916
+ compare: 'Inputs do not match',
917
+ pattern: 'Value should match pattern $(1)',
918
+ dateRange: 'Invalid date range',
919
+ url: 'This is not a valid url',
920
+ urlProtocol: 'Invalid URL. Proper http protocol is required. eg. https://google.com',
921
+ greater: 'Value must be greater than $(1)',
922
+ lesser: 'Value must be less than $(1)',
839
923
  };
840
924
 
841
- const VALIDATE_MESSAGES = new InjectionToken('fs.form.validate-messages');
842
- const VALIDATE_MESSAGE_PROVIDER = {
843
- provide: VALIDATE_MESSAGES,
844
- useFactory: messageProviderFactory,
845
- };
846
- function messageProviderFactory() {
847
- return Object.assign({}, ERROR_MESSAGES);
925
+ const VALIDATE_MESSAGES = new InjectionToken('fs.form.validate-messages');
926
+ const VALIDATE_MESSAGE_PROVIDER = {
927
+ provide: VALIDATE_MESSAGES,
928
+ useFactory: messageProviderFactory,
929
+ };
930
+ function messageProviderFactory() {
931
+ return Object.assign({}, ERROR_MESSAGES);
848
932
  }
849
933
 
850
- class FsControlDirective {
851
- constructor(elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
852
- this.elementRef = elementRef;
853
- this.renderer2 = renderer2;
854
- this.injector = injector;
855
- this._validateMessages = _validateMessages;
856
- this.ngControl = ngControl;
857
- this.formDirective = formDirective;
858
- this.appendMessageClass = 'fs-form-message';
859
- this.appendLabelClass = 'fs-form-label';
860
- this.appendErrorClass = 'fs-form-error';
861
- this.appendHintClass = 'fs-form-hint';
862
- this.errors = [];
863
- // protected _validateMessages = { ...ERROR_MESSAGES };
864
- this._destroy$ = new Subject();
865
- if (ngControl) {
866
- this._control = ngControl.control;
867
- }
868
- else {
869
- console.error('The element does not have a valid ngModel', this.elementRef.nativeElement);
870
- }
871
- }
872
- set validateMessages(messages) {
873
- this._validateMessages = Object.assign(Object.assign({}, this._validateMessages), messages);
874
- }
875
- ngOnInit() {
876
- this._setupValidators();
877
- }
878
- ngOnDestroy() {
879
- this._destroy$.next();
880
- this._destroy$.complete();
881
- }
882
- ngAfterContentInit() {
883
- if (this._control) {
884
- /*
885
- Ensure that statusChanges has one subscription per control. Multiple can happen
886
- when multiple fsForm validation directives are applied to the same element
887
- */
888
- if (!this._control.statusChangesSubscribe) {
889
- this._control.statusChanges
890
- .pipe(takeUntil(this._destroy$))
891
- .subscribe(this.render.bind(this));
892
- this._control.statusChangesSubscribe = true;
893
- }
894
- }
895
- }
896
- getMessageSelector() {
897
- if (this.messageSelector === false) {
898
- return '';
899
- }
900
- if (this.messageSelector) {
901
- return this.messageSelector;
902
- }
903
- else if (this.formDirective && this.formDirective.messageSelector) {
904
- return this.formDirective.messageSelector;
905
- }
906
- }
907
- getHintWrapperSelector() {
908
- if (this.hintSelector === false) {
909
- return '';
910
- }
911
- if (this.hintSelector) {
912
- return this.hintSelector;
913
- }
914
- else if (this.formDirective && this.formDirective.hintSelector) {
915
- return this.formDirective.hintSelector;
916
- }
917
- }
918
- getWrapperSelector() {
919
- if (this.wrapperSelector === false) {
920
- return '';
921
- }
922
- if (this.wrapperSelector) {
923
- return this.wrapperSelector;
924
- }
925
- else if (this.formDirective && this.formDirective.wrapperSelector) {
926
- return this.formDirective.wrapperSelector;
927
- }
928
- }
929
- getlabelSelector() {
930
- if (this.labelSelector === false) {
931
- return '';
932
- }
933
- if (this.labelSelector) {
934
- return this.labelSelector;
935
- }
936
- else if (this.formDirective && this.formDirective.labelSelector) {
937
- return this.formDirective.labelSelector;
938
- }
939
- }
940
- getWrapperElement() {
941
- const wrapper = this.getWrapper(this.elementRef.nativeElement);
942
- if (wrapper) {
943
- return wrapper;
944
- }
945
- return this.elementRef.nativeElement;
946
- }
947
- /*
948
- <mat-form-field class="mat-form-field"> <-- Field Wrapper Class. Look for parents from the native element with the matching wrapperSelector. If not found defaults to native element.
949
- <input>
950
- <div class="fs-form-message"> <-- Message Selector. Look for the element with class .fs-form-message or messageSelector
951
- <div class="fs-form-message"></div>
952
- <div class="fs-form-hint"></div> <-- Hint Selector. Look for the element with class .fs-form-hint or hintSelector
953
- </div>
954
- </mat-form-field>
955
- */
956
- render() {
957
- var _a;
958
- if (this.ngControl) {
959
- const renderer = this.renderer2;
960
- const wrapper = this.getWrapperElement();
961
- const error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
962
- if (!this.getMessageSelector()) {
963
- return;
964
- }
965
- const messageWrapper = wrapper.querySelector(this.getMessageSelector());
966
- if (!messageWrapper) {
967
- return console.warn('Failed to locate ' + this.getMessageSelector(), this.elementRef.nativeElement);
968
- }
969
- if (this.getlabelSelector()) {
970
- const labelWrapper = wrapper.querySelector(this.getlabelSelector());
971
- if (labelWrapper) {
972
- if (this.appendLabelClass) {
973
- this.renderer2.addClass(labelWrapper, this.appendLabelClass);
974
- }
975
- }
976
- }
977
- if (this.appendMessageClass) {
978
- renderer.addClass(messageWrapper, this.appendMessageClass);
979
- }
980
- if (this.getHintWrapperSelector()) {
981
- const hint = messageWrapper.querySelector(this.getHintWrapperSelector());
982
- if (hint) {
983
- renderer.setStyle(hint, 'display', error ? 'none' : 'block');
984
- if (this.appendHintClass) {
985
- renderer.addClass(hint, this.appendHintClass);
986
- }
987
- }
988
- }
989
- let errorWrapper = wrapper.querySelector('.fs-form-error-target');
990
- if (errorWrapper) {
991
- errorWrapper.remove();
992
- }
993
- wrapper.classList.remove('ng-invalid');
994
- const shouldErrorBeRendered = this.ngControl.invalid
995
- && (this.ngControl.dirty || ((_a = this.formDirective.ngForm) === null || _a === void 0 ? void 0 : _a.submitted));
996
- if (!shouldErrorBeRendered || !error) {
997
- return;
998
- }
999
- wrapper.classList.add('ng-invalid', 'ng-dirty');
1000
- errorWrapper = renderer.createElement('div');
1001
- renderer.addClass(errorWrapper, 'fs-form-error-target');
1002
- renderer.addClass(errorWrapper, this.appendErrorClass);
1003
- renderer.addClass(errorWrapper, this.appendErrorClass + '-' + error.name);
1004
- const errorText = renderer.createText(error.message);
1005
- renderer.appendChild(errorWrapper, errorText);
1006
- messageWrapper.appendChild(errorWrapper);
1007
- }
1008
- }
1009
- getWrapper(node, count = 0) {
1010
- if (!node || count > 10) {
1011
- return null;
1012
- }
1013
- if (node.parentNode && node.parentNode.querySelector(this.getWrapperSelector())) {
1014
- return node;
1015
- }
1016
- return this.getWrapper(node.parentNode, ++count);
1017
- }
1018
- parseErrorMessage(message, args) {
1019
- values(args)
1020
- .forEach((name) => {
1021
- message = message.replace(/\$\(\d\)/, name);
1022
- });
1023
- return message;
1024
- }
1025
- getError(controlRef) {
1026
- const name = keys(controlRef.control.errors)[0];
1027
- if (!name) {
1028
- return null;
1029
- }
1030
- let message = controlRef.control.errors[name];
1031
- if (this._validateMessages[name]) {
1032
- message = this.parseErrorMessage(this._validateMessages[name], message);
1033
- }
1034
- return { name: name, message: message };
1035
- }
1036
- _setupValidators() {
1037
- const control = this._control;
1038
- if (this.validate) {
1039
- const validators = control.validator
1040
- ? [control.validator, this.validate.bind(this)]
1041
- : this.validate.bind(this);
1042
- control.setValidators(validators);
1043
- }
1044
- if (this.validateAsync) {
1045
- const asyncValidators = control.asyncValidator
1046
- ? [control.asyncValidator, this.validateAsync.bind(this)]
1047
- : this.validateAsync.bind(this);
1048
- control.setAsyncValidators(asyncValidators);
1049
- }
1050
- control.updateValueAndValidity();
1051
- }
1052
- }
1053
- FsControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsControlDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.Injector }, { token: VALIDATE_MESSAGES, self: true }, { token: i1.NgControl, optional: true }, { token: FsFormDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1054
- FsControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsControlDirective, selector: "[fsFormControl]", inputs: { wrapperSelector: "wrapperSelector", messageSelector: "messageSelector", hintSelector: "hintSelector", labelSelector: "labelSelector", appendMessageClass: "appendMessageClass", appendLabelClass: "appendLabelClass", appendErrorClass: "appendErrorClass", appendHintClass: "appendHintClass", validateMessages: "validateMessages" }, providers: [
1055
- VALIDATE_MESSAGE_PROVIDER
1056
- ], ngImport: i0 });
1057
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsControlDirective, decorators: [{
1058
- type: Directive,
1059
- args: [{
1060
- selector: '[fsFormControl]',
1061
- providers: [
1062
- VALIDATE_MESSAGE_PROVIDER
1063
- ],
1064
- }]
1065
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.Injector }, { type: undefined, decorators: [{
1066
- type: Self
1067
- }, {
1068
- type: Inject,
1069
- args: [VALIDATE_MESSAGES]
1070
- }] }, { type: i1.NgControl, decorators: [{
1071
- type: Optional
1072
- }] }, { type: FsFormDirective, decorators: [{
1073
- type: Optional
1074
- }, {
1075
- type: Inject,
1076
- args: [FsFormDirective]
1077
- }] }]; }, propDecorators: { wrapperSelector: [{
1078
- type: Input
1079
- }], messageSelector: [{
1080
- type: Input
1081
- }], hintSelector: [{
1082
- type: Input
1083
- }], labelSelector: [{
1084
- type: Input
1085
- }], appendMessageClass: [{
1086
- type: Input
1087
- }], appendLabelClass: [{
1088
- type: Input
1089
- }], appendErrorClass: [{
1090
- type: Input
1091
- }], appendHintClass: [{
1092
- type: Input
1093
- }], validateMessages: [{
1094
- type: Input
934
+ class FsControlDirective {
935
+ constructor(elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
936
+ this.elementRef = elementRef;
937
+ this.renderer2 = renderer2;
938
+ this.injector = injector;
939
+ this._validateMessages = _validateMessages;
940
+ this.ngControl = ngControl;
941
+ this.formDirective = formDirective;
942
+ this.appendMessageClass = 'fs-form-message';
943
+ this.appendLabelClass = 'fs-form-label';
944
+ this.appendErrorClass = 'fs-form-error';
945
+ this.appendHintClass = 'fs-form-hint';
946
+ this.errors = [];
947
+ // protected _validateMessages = { ...ERROR_MESSAGES };
948
+ this._destroy$ = new Subject();
949
+ if (ngControl) {
950
+ this._control = ngControl.control;
951
+ }
952
+ else {
953
+ console.error('The element does not have a valid ngModel', this.elementRef.nativeElement);
954
+ }
955
+ }
956
+ set validateMessages(messages) {
957
+ this._validateMessages = Object.assign(Object.assign({}, this._validateMessages), messages);
958
+ }
959
+ ngOnInit() {
960
+ this._setupValidators();
961
+ }
962
+ ngOnDestroy() {
963
+ this._destroy$.next();
964
+ this._destroy$.complete();
965
+ }
966
+ ngAfterContentInit() {
967
+ if (this._control) {
968
+ /*
969
+ Ensure that statusChanges has one subscription per control. Multiple can happen
970
+ when multiple fsForm validation directives are applied to the same element
971
+ */
972
+ if (!this._control.statusChangesSubscribe) {
973
+ this._control.statusChanges
974
+ .pipe(takeUntil(this._destroy$))
975
+ .subscribe(this.render.bind(this));
976
+ this._control.statusChangesSubscribe = true;
977
+ }
978
+ }
979
+ }
980
+ getMessageSelector() {
981
+ if (this.messageSelector === false) {
982
+ return '';
983
+ }
984
+ if (this.messageSelector) {
985
+ return this.messageSelector;
986
+ }
987
+ else if (this.formDirective && this.formDirective.messageSelector) {
988
+ return this.formDirective.messageSelector;
989
+ }
990
+ }
991
+ getHintWrapperSelector() {
992
+ if (this.hintSelector === false) {
993
+ return '';
994
+ }
995
+ if (this.hintSelector) {
996
+ return this.hintSelector;
997
+ }
998
+ else if (this.formDirective && this.formDirective.hintSelector) {
999
+ return this.formDirective.hintSelector;
1000
+ }
1001
+ }
1002
+ getWrapperSelector() {
1003
+ if (this.wrapperSelector === false) {
1004
+ return '';
1005
+ }
1006
+ if (this.wrapperSelector) {
1007
+ return this.wrapperSelector;
1008
+ }
1009
+ else if (this.formDirective && this.formDirective.wrapperSelector) {
1010
+ return this.formDirective.wrapperSelector;
1011
+ }
1012
+ }
1013
+ getlabelSelector() {
1014
+ if (this.labelSelector === false) {
1015
+ return '';
1016
+ }
1017
+ if (this.labelSelector) {
1018
+ return this.labelSelector;
1019
+ }
1020
+ else if (this.formDirective && this.formDirective.labelSelector) {
1021
+ return this.formDirective.labelSelector;
1022
+ }
1023
+ }
1024
+ getWrapperElement() {
1025
+ const wrapper = this.getWrapper(this.elementRef.nativeElement);
1026
+ if (wrapper) {
1027
+ return wrapper;
1028
+ }
1029
+ return this.elementRef.nativeElement;
1030
+ }
1031
+ /*
1032
+ <mat-form-field class="mat-form-field"> <-- Field Wrapper Class. Look for parents from the native element with the matching wrapperSelector. If not found defaults to native element.
1033
+ <input>
1034
+ <div class="fs-form-message"> <-- Message Selector. Look for the element with class .fs-form-message or messageSelector
1035
+ <div class="fs-form-message"></div>
1036
+ <div class="fs-form-hint"></div> <-- Hint Selector. Look for the element with class .fs-form-hint or hintSelector
1037
+ </div>
1038
+ </mat-form-field>
1039
+ */
1040
+ render() {
1041
+ var _a;
1042
+ if (this.ngControl) {
1043
+ const renderer = this.renderer2;
1044
+ const wrapper = this.getWrapperElement();
1045
+ const error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
1046
+ if (!this.getMessageSelector()) {
1047
+ return;
1048
+ }
1049
+ const messageWrapper = wrapper.querySelector(this.getMessageSelector());
1050
+ if (!messageWrapper) {
1051
+ return console.warn('Failed to locate ' + this.getMessageSelector(), this.elementRef.nativeElement);
1052
+ }
1053
+ if (this.getlabelSelector()) {
1054
+ const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1055
+ if (labelWrapper) {
1056
+ if (this.appendLabelClass) {
1057
+ this.renderer2.addClass(labelWrapper, this.appendLabelClass);
1058
+ }
1059
+ }
1060
+ }
1061
+ if (this.appendMessageClass) {
1062
+ renderer.addClass(messageWrapper, this.appendMessageClass);
1063
+ }
1064
+ if (this.getHintWrapperSelector()) {
1065
+ const hint = messageWrapper.querySelector(this.getHintWrapperSelector());
1066
+ if (hint) {
1067
+ renderer.setStyle(hint, 'display', error ? 'none' : 'block');
1068
+ if (this.appendHintClass) {
1069
+ renderer.addClass(hint, this.appendHintClass);
1070
+ }
1071
+ }
1072
+ }
1073
+ let errorWrapper = wrapper.querySelector('.fs-form-error-target');
1074
+ if (errorWrapper) {
1075
+ errorWrapper.remove();
1076
+ }
1077
+ wrapper.classList.remove('ng-invalid');
1078
+ const shouldErrorBeRendered = this.ngControl.invalid
1079
+ && (this.ngControl.dirty || ((_a = this.formDirective.ngForm) === null || _a === void 0 ? void 0 : _a.submitted));
1080
+ if (!shouldErrorBeRendered || !error) {
1081
+ return;
1082
+ }
1083
+ wrapper.classList.add('ng-invalid', 'ng-dirty');
1084
+ errorWrapper = renderer.createElement('div');
1085
+ renderer.addClass(errorWrapper, 'fs-form-error-target');
1086
+ renderer.addClass(errorWrapper, this.appendErrorClass);
1087
+ renderer.addClass(errorWrapper, this.appendErrorClass + '-' + error.name);
1088
+ const errorText = renderer.createText(error.message);
1089
+ renderer.appendChild(errorWrapper, errorText);
1090
+ messageWrapper.appendChild(errorWrapper);
1091
+ }
1092
+ }
1093
+ getWrapper(node, count = 0) {
1094
+ if (!node || count > 10) {
1095
+ return null;
1096
+ }
1097
+ if (node.parentNode && node.parentNode.querySelector(this.getWrapperSelector())) {
1098
+ return node;
1099
+ }
1100
+ return this.getWrapper(node.parentNode, ++count);
1101
+ }
1102
+ parseErrorMessage(message, args) {
1103
+ values(args)
1104
+ .forEach((name) => {
1105
+ message = message.replace(/\$\(\d\)/, name);
1106
+ });
1107
+ return message;
1108
+ }
1109
+ getError(controlRef) {
1110
+ const name = keys(controlRef.control.errors)[0];
1111
+ if (!name) {
1112
+ return null;
1113
+ }
1114
+ let message = controlRef.control.errors[name];
1115
+ if (this._validateMessages[name]) {
1116
+ message = this.parseErrorMessage(this._validateMessages[name], message);
1117
+ }
1118
+ return { name: name, message: message };
1119
+ }
1120
+ _setupValidators() {
1121
+ const control = this._control;
1122
+ if (this.validate) {
1123
+ const validators = control.validator
1124
+ ? [control.validator, this.validate.bind(this)]
1125
+ : this.validate.bind(this);
1126
+ control.setValidators(validators);
1127
+ }
1128
+ if (this.validateAsync) {
1129
+ const asyncValidators = control.asyncValidator
1130
+ ? [control.asyncValidator, this.validateAsync.bind(this)]
1131
+ : this.validateAsync.bind(this);
1132
+ control.setAsyncValidators(asyncValidators);
1133
+ }
1134
+ control.updateValueAndValidity();
1135
+ }
1136
+ }
1137
+ FsControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsControlDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.Injector }, { token: VALIDATE_MESSAGES, self: true }, { token: i1$1.NgControl, optional: true }, { token: FsFormDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1138
+ FsControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsControlDirective, selector: "[fsFormControl]", inputs: { wrapperSelector: "wrapperSelector", messageSelector: "messageSelector", hintSelector: "hintSelector", labelSelector: "labelSelector", appendMessageClass: "appendMessageClass", appendLabelClass: "appendLabelClass", appendErrorClass: "appendErrorClass", appendHintClass: "appendHintClass", validateMessages: "validateMessages" }, providers: [
1139
+ VALIDATE_MESSAGE_PROVIDER
1140
+ ], ngImport: i0 });
1141
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsControlDirective, decorators: [{
1142
+ type: Directive,
1143
+ args: [{
1144
+ selector: '[fsFormControl]',
1145
+ providers: [
1146
+ VALIDATE_MESSAGE_PROVIDER
1147
+ ],
1148
+ }]
1149
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.Injector }, { type: undefined, decorators: [{
1150
+ type: Self
1151
+ }, {
1152
+ type: Inject,
1153
+ args: [VALIDATE_MESSAGES]
1154
+ }] }, { type: i1$1.NgControl, decorators: [{
1155
+ type: Optional
1156
+ }] }, { type: FsFormDirective, decorators: [{
1157
+ type: Optional
1158
+ }, {
1159
+ type: Inject,
1160
+ args: [FsFormDirective]
1161
+ }] }]; }, propDecorators: { wrapperSelector: [{
1162
+ type: Input
1163
+ }], messageSelector: [{
1164
+ type: Input
1165
+ }], hintSelector: [{
1166
+ type: Input
1167
+ }], labelSelector: [{
1168
+ type: Input
1169
+ }], appendMessageClass: [{
1170
+ type: Input
1171
+ }], appendLabelClass: [{
1172
+ type: Input
1173
+ }], appendErrorClass: [{
1174
+ type: Input
1175
+ }], appendHintClass: [{
1176
+ type: Input
1177
+ }], validateMessages: [{
1178
+ type: Input
1095
1179
  }] } });
1096
1180
 
1097
- function isEnabled(value) {
1098
- return value !== 'false' && (value || value === '');
1181
+ function isEnabled(value) {
1182
+ return value !== 'false' && (value || value === '');
1099
1183
  }
1100
1184
 
1101
- class FsFormRequiredDirective extends FsControlDirective {
1102
- constructor() {
1103
- super(...arguments);
1104
- this.required = false;
1105
- }
1106
- set setFsFormRequired(value) {
1107
- this.required = isEnabled(value);
1108
- }
1109
- set setRequired(value) {
1110
- this.required = isEnabled(value);
1111
- }
1112
- set validationMessage(value) {
1113
- this._validateMessages.required = value;
1114
- }
1115
- ngOnChanges() {
1116
- this._control.updateValueAndValidity();
1117
- }
1118
- validate(control) {
1119
- if (this.required) {
1120
- return Validators.required(this._control);
1121
- }
1122
- else {
1123
- return null;
1124
- }
1125
- }
1126
- render() {
1127
- const wrapper = this.getWrapperElement();
1128
- if (wrapper && this.getlabelSelector()) {
1129
- const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1130
- // Adding class fs-form-label-requried adds the * to the label
1131
- if (labelWrapper) {
1132
- if (this.required) {
1133
- this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
1134
- }
1135
- else {
1136
- this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
1137
- }
1138
- }
1139
- }
1140
- super.render();
1141
- }
1142
- }
1143
- FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1144
- FsFormRequiredDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormRequiredDirective, selector: "[fsFormRequired],[ngModel][required]", inputs: { setFsFormRequired: ["fsFormRequired", "setFsFormRequired"], setRequired: ["required", "setRequired"], validationMessage: ["fsFormRequiredMessage", "validationMessage"] }, providers: [
1145
- VALIDATE_MESSAGE_PROVIDER
1146
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1147
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
1148
- type: Directive,
1149
- args: [{
1150
- selector: '[fsFormRequired],[ngModel][required]',
1151
- providers: [
1152
- VALIDATE_MESSAGE_PROVIDER
1153
- ],
1154
- }]
1155
- }], propDecorators: { setFsFormRequired: [{
1156
- type: Input,
1157
- args: ['fsFormRequired']
1158
- }], setRequired: [{
1159
- type: Input,
1160
- args: ['required']
1161
- }], validationMessage: [{
1162
- type: Input,
1163
- args: ['fsFormRequiredMessage']
1185
+ class FsFormRequiredDirective extends FsControlDirective {
1186
+ constructor() {
1187
+ super(...arguments);
1188
+ this.required = false;
1189
+ }
1190
+ set setFsFormRequired(value) {
1191
+ this.required = isEnabled(value);
1192
+ }
1193
+ set setRequired(value) {
1194
+ this.required = isEnabled(value);
1195
+ }
1196
+ set validationMessage(value) {
1197
+ this._validateMessages.required = value;
1198
+ }
1199
+ ngOnChanges() {
1200
+ this._control.updateValueAndValidity();
1201
+ }
1202
+ validate(control) {
1203
+ if (this.required) {
1204
+ return Validators.required(this._control);
1205
+ }
1206
+ else {
1207
+ return null;
1208
+ }
1209
+ }
1210
+ render() {
1211
+ const wrapper = this.getWrapperElement();
1212
+ if (wrapper && this.getlabelSelector()) {
1213
+ const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1214
+ // Adding class fs-form-label-requried adds the * to the label
1215
+ if (labelWrapper) {
1216
+ if (this.required) {
1217
+ this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
1218
+ }
1219
+ else {
1220
+ this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
1221
+ }
1222
+ }
1223
+ }
1224
+ super.render();
1225
+ }
1226
+ }
1227
+ FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1228
+ FsFormRequiredDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormRequiredDirective, selector: "[fsFormRequired],[ngModel][required]", inputs: { setFsFormRequired: ["fsFormRequired", "setFsFormRequired"], setRequired: ["required", "setRequired"], validationMessage: ["fsFormRequiredMessage", "validationMessage"] }, providers: [
1229
+ VALIDATE_MESSAGE_PROVIDER
1230
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1231
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
1232
+ type: Directive,
1233
+ args: [{
1234
+ selector: '[fsFormRequired],[ngModel][required]',
1235
+ providers: [
1236
+ VALIDATE_MESSAGE_PROVIDER
1237
+ ],
1238
+ }]
1239
+ }], propDecorators: { setFsFormRequired: [{
1240
+ type: Input,
1241
+ args: ['fsFormRequired']
1242
+ }], setRequired: [{
1243
+ type: Input,
1244
+ args: ['required']
1245
+ }], validationMessage: [{
1246
+ type: Input,
1247
+ args: ['fsFormRequiredMessage']
1164
1248
  }] } });
1165
1249
 
1166
- class FsValidators {
1167
- static email(control) {
1168
- if (!control.value || email(control.value)) {
1169
- return null;
1170
- }
1171
- return { email: true };
1172
- }
1173
- static emails(control) {
1174
- const model = control.value || '';
1175
- const hasInvalidEmails = model
1176
- .split(',')
1177
- .some((part) => !email(part));
1178
- return hasInvalidEmails ? { email: true } : null;
1179
- }
1180
- static numeric(control) {
1181
- if (isEmpty(control.value) || isNumeric(control.value)) {
1182
- return null;
1183
- }
1184
- else {
1185
- return { numeric: true };
1186
- }
1187
- }
1188
- static integer(control) {
1189
- if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1190
- return null;
1191
- }
1192
- else {
1193
- return { integer: true };
1194
- }
1195
- }
1196
- static phone(control) {
1197
- if (!control.value || phone(control.value)) {
1198
- return null;
1199
- }
1200
- return { phone: true };
1201
- }
1202
- static url(control, protocolRequired = false) {
1203
- if (!control.value) {
1204
- return null;
1205
- }
1206
- if (!url(control.value)) {
1207
- return { url: true };
1208
- }
1209
- if (protocolRequired) {
1210
- const pattern = new RegExp(/^http(s)?:\/\//gm);
1211
- if (!String(control.value).match(pattern)) {
1212
- return { urlProtocol: true };
1213
- }
1214
- }
1215
- return null;
1216
- }
1217
- static dateRange(control) {
1218
- if (!control.value) {
1219
- return null;
1220
- }
1221
- if (isObject(control.value)) {
1222
- const start = control.value.start;
1223
- const end = control.value.end;
1224
- if ((!start && !end) || (isValid(start) && isValid(end))) {
1225
- return null;
1226
- }
1227
- }
1228
- return { dateRange: true };
1229
- }
1230
- static func(control, formFunction, data) {
1231
- let result;
1232
- let stream$;
1233
- try {
1234
- result = formFunction(control, data);
1235
- }
1236
- catch (err) {
1237
- err = err instanceof Error ? err.message : err;
1238
- stream$ = throwError(err);
1239
- }
1240
- if (!stream$) {
1241
- if (result instanceof Promise) {
1242
- stream$ = from(result);
1243
- }
1244
- else if (isObservable(result)) {
1245
- stream$ = result;
1246
- }
1247
- else {
1248
- stream$ = of(null);
1249
- }
1250
- }
1251
- return stream$
1252
- .pipe(map(() => null), catchError((err) => {
1253
- return of({ validationError: err });
1254
- }), take(1));
1255
- }
1250
+ class FsValidators {
1251
+ static email(control) {
1252
+ if (!control.value || email(control.value)) {
1253
+ return null;
1254
+ }
1255
+ return { email: true };
1256
+ }
1257
+ static emails(control) {
1258
+ const model = control.value || '';
1259
+ const hasInvalidEmails = model
1260
+ .split(',')
1261
+ .some((part) => !email(part));
1262
+ return hasInvalidEmails ? { email: true } : null;
1263
+ }
1264
+ static numeric(control) {
1265
+ if (isEmpty(control.value) || isNumeric(control.value)) {
1266
+ return null;
1267
+ }
1268
+ else {
1269
+ return { numeric: true };
1270
+ }
1271
+ }
1272
+ static integer(control) {
1273
+ if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1274
+ return null;
1275
+ }
1276
+ else {
1277
+ return { integer: true };
1278
+ }
1279
+ }
1280
+ static phone(control) {
1281
+ if (!control.value || phone(control.value)) {
1282
+ return null;
1283
+ }
1284
+ return { phone: true };
1285
+ }
1286
+ static url(control, protocolRequired = false) {
1287
+ if (!control.value) {
1288
+ return null;
1289
+ }
1290
+ if (!url(control.value)) {
1291
+ return { url: true };
1292
+ }
1293
+ if (protocolRequired) {
1294
+ const pattern = new RegExp(/^http(s)?:\/\//gm);
1295
+ if (!String(control.value).match(pattern)) {
1296
+ return { urlProtocol: true };
1297
+ }
1298
+ }
1299
+ return null;
1300
+ }
1301
+ static dateRange(control) {
1302
+ if (!control.value) {
1303
+ return null;
1304
+ }
1305
+ if (isObject(control.value)) {
1306
+ const start = control.value.start;
1307
+ const end = control.value.end;
1308
+ if ((!start && !end) || (isValid(start) && isValid(end))) {
1309
+ return null;
1310
+ }
1311
+ }
1312
+ return { dateRange: true };
1313
+ }
1314
+ static func(control, formFunction, data) {
1315
+ let result;
1316
+ let stream$;
1317
+ try {
1318
+ result = formFunction(control, data);
1319
+ }
1320
+ catch (err) {
1321
+ err = err instanceof Error ? err.message : err;
1322
+ stream$ = throwError(err);
1323
+ }
1324
+ if (!stream$) {
1325
+ if (result instanceof Promise) {
1326
+ stream$ = from(result);
1327
+ }
1328
+ else if (isObservable(result)) {
1329
+ stream$ = result;
1330
+ }
1331
+ else {
1332
+ stream$ = of(null);
1333
+ }
1334
+ }
1335
+ return stream$
1336
+ .pipe(map(() => null), catchError((err) => {
1337
+ return of({ validationError: err });
1338
+ }), take(1));
1339
+ }
1256
1340
  }
1257
1341
 
1258
- class FsFormMinDirective extends FsControlDirective {
1259
- set validationMessage(value) {
1260
- this._validateMessages.min = value;
1261
- }
1262
- ngOnChanges() {
1263
- this._control.updateValueAndValidity();
1264
- }
1265
- validate(control) {
1266
- return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
1267
- }
1268
- }
1269
- FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1270
- FsFormMinDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
1271
- VALIDATE_MESSAGE_PROVIDER
1272
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinDirective, decorators: [{
1274
- type: Directive,
1275
- args: [{
1276
- selector: '[fsFormMin]',
1277
- providers: [
1278
- VALIDATE_MESSAGE_PROVIDER
1279
- ],
1280
- }]
1281
- }], propDecorators: { fsFormMin: [{
1282
- type: Input
1283
- }], validationMessage: [{
1284
- type: Input,
1285
- args: ['fsFormMinMessage']
1342
+ class FsFormMinDirective extends FsControlDirective {
1343
+ set validationMessage(value) {
1344
+ this._validateMessages.min = value;
1345
+ }
1346
+ ngOnChanges() {
1347
+ this._control.updateValueAndValidity();
1348
+ }
1349
+ validate(control) {
1350
+ return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
1351
+ }
1352
+ }
1353
+ FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1354
+ FsFormMinDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
1355
+ VALIDATE_MESSAGE_PROVIDER
1356
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinDirective, decorators: [{
1358
+ type: Directive,
1359
+ args: [{
1360
+ selector: '[fsFormMin]',
1361
+ providers: [
1362
+ VALIDATE_MESSAGE_PROVIDER
1363
+ ],
1364
+ }]
1365
+ }], propDecorators: { fsFormMin: [{
1366
+ type: Input
1367
+ }], validationMessage: [{
1368
+ type: Input,
1369
+ args: ['fsFormMinMessage']
1286
1370
  }] } });
1287
1371
 
1288
- class FsFormMaxDirective extends FsControlDirective {
1289
- set validationMessage(value) {
1290
- this._validateMessages.max = value;
1291
- }
1292
- ngOnChanges() {
1293
- this._control.updateValueAndValidity();
1294
- }
1295
- validate(control) {
1296
- return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1297
- }
1298
- }
1299
- FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1300
- FsFormMaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
1301
- VALIDATE_MESSAGE_PROVIDER
1302
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1303
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxDirective, decorators: [{
1304
- type: Directive,
1305
- args: [{
1306
- selector: '[fsFormMax]',
1307
- providers: [
1308
- VALIDATE_MESSAGE_PROVIDER
1309
- ],
1310
- }]
1311
- }], propDecorators: { fsFormMax: [{
1312
- type: Input
1313
- }], validationMessage: [{
1314
- type: Input,
1315
- args: ['fsFormMaxMessage']
1372
+ class FsFormMaxDirective extends FsControlDirective {
1373
+ set validationMessage(value) {
1374
+ this._validateMessages.max = value;
1375
+ }
1376
+ ngOnChanges() {
1377
+ this._control.updateValueAndValidity();
1378
+ }
1379
+ validate(control) {
1380
+ return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1381
+ }
1382
+ }
1383
+ FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1384
+ FsFormMaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
1385
+ VALIDATE_MESSAGE_PROVIDER
1386
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1387
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxDirective, decorators: [{
1388
+ type: Directive,
1389
+ args: [{
1390
+ selector: '[fsFormMax]',
1391
+ providers: [
1392
+ VALIDATE_MESSAGE_PROVIDER
1393
+ ],
1394
+ }]
1395
+ }], propDecorators: { fsFormMax: [{
1396
+ type: Input
1397
+ }], validationMessage: [{
1398
+ type: Input,
1399
+ args: ['fsFormMaxMessage']
1316
1400
  }] } });
1317
1401
 
1318
- class FsFormMinLengthDirective extends FsControlDirective {
1319
- set validationMessage(value) {
1320
- this._validateMessages.minlength = value;
1321
- }
1322
- ngOnChanges() {
1323
- this._control.updateValueAndValidity();
1324
- }
1325
- validate(control) {
1326
- return Validators.minLength(this.fsFormMinLength)(this._control);
1327
- }
1328
- }
1329
- FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1330
- FsFormMinLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
1331
- VALIDATE_MESSAGE_PROVIDER
1332
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1333
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
1334
- type: Directive,
1335
- args: [{
1336
- selector: '[fsFormMinLength]',
1337
- providers: [
1338
- VALIDATE_MESSAGE_PROVIDER
1339
- ],
1340
- }]
1341
- }], propDecorators: { fsFormMinLength: [{
1342
- type: Input
1343
- }], validationMessage: [{
1344
- type: Input,
1345
- args: ['fsFormMinLengthMessage']
1402
+ class FsFormMinLengthDirective extends FsControlDirective {
1403
+ set validationMessage(value) {
1404
+ this._validateMessages.minlength = value;
1405
+ }
1406
+ ngOnChanges() {
1407
+ this._control.updateValueAndValidity();
1408
+ }
1409
+ validate(control) {
1410
+ return Validators.minLength(this.fsFormMinLength)(this._control);
1411
+ }
1412
+ }
1413
+ FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1414
+ FsFormMinLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
1415
+ VALIDATE_MESSAGE_PROVIDER
1416
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1417
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
1418
+ type: Directive,
1419
+ args: [{
1420
+ selector: '[fsFormMinLength]',
1421
+ providers: [
1422
+ VALIDATE_MESSAGE_PROVIDER
1423
+ ],
1424
+ }]
1425
+ }], propDecorators: { fsFormMinLength: [{
1426
+ type: Input
1427
+ }], validationMessage: [{
1428
+ type: Input,
1429
+ args: ['fsFormMinLengthMessage']
1346
1430
  }] } });
1347
1431
 
1348
- class FsFormMaxLengthDirective extends FsControlDirective {
1349
- set validationMessage(value) {
1350
- this._validateMessages.maxlength = value;
1351
- }
1352
- ngOnChanges() {
1353
- this._control.updateValueAndValidity();
1354
- }
1355
- validate(control) {
1356
- return Validators.maxLength(this.fsFormMaxLength)(this._control);
1357
- }
1358
- }
1359
- FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1360
- FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
1361
- VALIDATE_MESSAGE_PROVIDER
1362
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1363
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
1364
- type: Directive,
1365
- args: [{
1366
- selector: '[fsFormMaxLength]',
1367
- providers: [
1368
- VALIDATE_MESSAGE_PROVIDER
1369
- ],
1370
- }]
1371
- }], propDecorators: { fsFormMaxLength: [{
1372
- type: Input
1373
- }], validationMessage: [{
1374
- type: Input,
1375
- args: ['fsFormMaxLengthMessage']
1432
+ class FsFormMaxLengthDirective extends FsControlDirective {
1433
+ set validationMessage(value) {
1434
+ this._validateMessages.maxlength = value;
1435
+ }
1436
+ ngOnChanges() {
1437
+ this._control.updateValueAndValidity();
1438
+ }
1439
+ validate(control) {
1440
+ return Validators.maxLength(this.fsFormMaxLength)(this._control);
1441
+ }
1442
+ }
1443
+ FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1444
+ FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
1445
+ VALIDATE_MESSAGE_PROVIDER
1446
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1447
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
1448
+ type: Directive,
1449
+ args: [{
1450
+ selector: '[fsFormMaxLength]',
1451
+ providers: [
1452
+ VALIDATE_MESSAGE_PROVIDER
1453
+ ],
1454
+ }]
1455
+ }], propDecorators: { fsFormMaxLength: [{
1456
+ type: Input
1457
+ }], validationMessage: [{
1458
+ type: Input,
1459
+ args: ['fsFormMaxLengthMessage']
1376
1460
  }] } });
1377
1461
 
1378
- class FsFormEmailDirective extends FsControlDirective {
1379
- set validationMessage(value) {
1380
- this._validateMessages.email = value;
1381
- }
1382
- ngOnChanges() {
1383
- this._control.updateValueAndValidity();
1384
- }
1385
- validate(control) {
1386
- if (isEnabled(this.fsFormEmail)) {
1387
- return FsValidators.email(this._control);
1388
- }
1389
- else {
1390
- return null;
1391
- }
1392
- }
1393
- }
1394
- FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1395
- FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
1396
- VALIDATE_MESSAGE_PROVIDER
1397
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1398
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1399
- type: Directive,
1400
- args: [{
1401
- selector: '[fsFormEmail]',
1402
- providers: [
1403
- VALIDATE_MESSAGE_PROVIDER
1404
- ],
1405
- }]
1406
- }], propDecorators: { fsFormEmail: [{
1407
- type: Input
1408
- }], validationMessage: [{
1409
- type: Input,
1410
- args: ['fsFormEmailMessage']
1462
+ class FsFormEmailDirective extends FsControlDirective {
1463
+ set validationMessage(value) {
1464
+ this._validateMessages.email = value;
1465
+ }
1466
+ ngOnChanges() {
1467
+ this._control.updateValueAndValidity();
1468
+ }
1469
+ validate(control) {
1470
+ if (isEnabled(this.fsFormEmail)) {
1471
+ return FsValidators.email(this._control);
1472
+ }
1473
+ else {
1474
+ return null;
1475
+ }
1476
+ }
1477
+ }
1478
+ FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1479
+ FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
1480
+ VALIDATE_MESSAGE_PROVIDER
1481
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1483
+ type: Directive,
1484
+ args: [{
1485
+ selector: '[fsFormEmail]',
1486
+ providers: [
1487
+ VALIDATE_MESSAGE_PROVIDER
1488
+ ],
1489
+ }]
1490
+ }], propDecorators: { fsFormEmail: [{
1491
+ type: Input
1492
+ }], validationMessage: [{
1493
+ type: Input,
1494
+ args: ['fsFormEmailMessage']
1411
1495
  }] } });
1412
1496
 
1413
- class FsFormEmailsDirective extends FsControlDirective {
1414
- set validationMessage(value) {
1415
- this._validateMessages.emails = value;
1416
- }
1417
- ngOnChanges() {
1418
- this._control.updateValueAndValidity();
1419
- }
1420
- validate(control) {
1421
- if (isEnabled(this.fsFormEmails)) {
1422
- return FsValidators.emails(this._control);
1423
- }
1424
- else {
1425
- return null;
1426
- }
1427
- }
1428
- }
1429
- FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1430
- FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
1431
- VALIDATE_MESSAGE_PROVIDER
1432
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1433
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1434
- type: Directive,
1435
- args: [{
1436
- selector: '[fsFormEmails]',
1437
- providers: [
1438
- VALIDATE_MESSAGE_PROVIDER
1439
- ],
1440
- }]
1441
- }], propDecorators: { fsFormEmails: [{
1442
- type: Input
1443
- }], validationMessage: [{
1444
- type: Input,
1445
- args: ['fsFormEmailsMessage']
1497
+ class FsFormEmailsDirective extends FsControlDirective {
1498
+ set validationMessage(value) {
1499
+ this._validateMessages.emails = value;
1500
+ }
1501
+ ngOnChanges() {
1502
+ this._control.updateValueAndValidity();
1503
+ }
1504
+ validate(control) {
1505
+ if (isEnabled(this.fsFormEmails)) {
1506
+ return FsValidators.emails(this._control);
1507
+ }
1508
+ else {
1509
+ return null;
1510
+ }
1511
+ }
1512
+ }
1513
+ FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1514
+ FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
1515
+ VALIDATE_MESSAGE_PROVIDER
1516
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1517
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1518
+ type: Directive,
1519
+ args: [{
1520
+ selector: '[fsFormEmails]',
1521
+ providers: [
1522
+ VALIDATE_MESSAGE_PROVIDER
1523
+ ],
1524
+ }]
1525
+ }], propDecorators: { fsFormEmails: [{
1526
+ type: Input
1527
+ }], validationMessage: [{
1528
+ type: Input,
1529
+ args: ['fsFormEmailsMessage']
1446
1530
  }] } });
1447
1531
 
1448
- class FsFormPhoneDirective extends FsControlDirective {
1449
- set validationMessage(value) {
1450
- this._validateMessages.phone = value;
1451
- }
1452
- ngOnChanges() {
1453
- this._control.updateValueAndValidity();
1454
- }
1455
- validate(control) {
1456
- if (isEnabled(this.fsFormPhone)) {
1457
- return FsValidators.phone(this._control);
1458
- }
1459
- else {
1460
- return null;
1461
- }
1462
- }
1463
- }
1464
- FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1465
- FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
1466
- VALIDATE_MESSAGE_PROVIDER
1467
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1468
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
1469
- type: Directive,
1470
- args: [{
1471
- selector: '[fsFormPhone]',
1472
- providers: [
1473
- VALIDATE_MESSAGE_PROVIDER
1474
- ],
1475
- }]
1476
- }], propDecorators: { fsFormPhone: [{
1477
- type: Input
1478
- }], validationMessage: [{
1479
- type: Input,
1480
- args: ['fsFormPhoneMessage']
1532
+ class FsFormPhoneDirective extends FsControlDirective {
1533
+ set validationMessage(value) {
1534
+ this._validateMessages.phone = value;
1535
+ }
1536
+ ngOnChanges() {
1537
+ this._control.updateValueAndValidity();
1538
+ }
1539
+ validate(control) {
1540
+ if (isEnabled(this.fsFormPhone)) {
1541
+ return FsValidators.phone(this._control);
1542
+ }
1543
+ else {
1544
+ return null;
1545
+ }
1546
+ }
1547
+ }
1548
+ FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1549
+ FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
1550
+ VALIDATE_MESSAGE_PROVIDER
1551
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1552
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
1553
+ type: Directive,
1554
+ args: [{
1555
+ selector: '[fsFormPhone]',
1556
+ providers: [
1557
+ VALIDATE_MESSAGE_PROVIDER
1558
+ ],
1559
+ }]
1560
+ }], propDecorators: { fsFormPhone: [{
1561
+ type: Input
1562
+ }], validationMessage: [{
1563
+ type: Input,
1564
+ args: ['fsFormPhoneMessage']
1481
1565
  }] } });
1482
1566
 
1483
- class FsFormCompareDirective extends FsControlDirective {
1484
- set validationMessage(value) {
1485
- this._validateMessages.compare = value;
1486
- }
1487
- ngOnChanges() {
1488
- this._control.updateValueAndValidity();
1489
- }
1490
- validate(control) {
1491
- if (this.fsFormCompare.value === this.elementRef.nativeElement.value) {
1492
- return null;
1493
- }
1494
- else {
1495
- return { compare: true };
1496
- }
1497
- }
1498
- ngAfterViewInit() {
1499
- this.fsFormCompare.addEventListener('keyup', () => {
1500
- this._control.updateValueAndValidity();
1501
- }, false);
1502
- }
1503
- ngOnDestroy() {
1504
- this.fsFormCompare.removeEventListener('keyup', () => {
1505
- this._control.updateValueAndValidity();
1506
- }, false);
1507
- }
1508
- }
1509
- FsFormCompareDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormCompareDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1510
- FsFormCompareDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormCompareDirective, selector: "[fsFormCompare]", inputs: { fsFormCompare: "fsFormCompare", validationMessage: ["fsFormCompareMessage", "validationMessage"] }, providers: [
1511
- VALIDATE_MESSAGE_PROVIDER,
1512
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1513
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormCompareDirective, decorators: [{
1514
- type: Directive,
1515
- args: [{
1516
- selector: '[fsFormCompare]',
1517
- providers: [
1518
- VALIDATE_MESSAGE_PROVIDER,
1519
- ],
1520
- }]
1521
- }], propDecorators: { fsFormCompare: [{
1522
- type: Input
1523
- }], validationMessage: [{
1524
- type: Input,
1525
- args: ['fsFormCompareMessage']
1567
+ class FsFormCompareDirective extends FsControlDirective {
1568
+ set validationMessage(value) {
1569
+ this._validateMessages.compare = value;
1570
+ }
1571
+ ngOnChanges() {
1572
+ this._control.updateValueAndValidity();
1573
+ }
1574
+ validate(control) {
1575
+ if (this.fsFormCompare.value === this.elementRef.nativeElement.value) {
1576
+ return null;
1577
+ }
1578
+ else {
1579
+ return { compare: true };
1580
+ }
1581
+ }
1582
+ ngAfterViewInit() {
1583
+ this.fsFormCompare.addEventListener('keyup', () => {
1584
+ this._control.updateValueAndValidity();
1585
+ }, false);
1586
+ }
1587
+ ngOnDestroy() {
1588
+ this.fsFormCompare.removeEventListener('keyup', () => {
1589
+ this._control.updateValueAndValidity();
1590
+ }, false);
1591
+ }
1592
+ }
1593
+ FsFormCompareDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormCompareDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1594
+ FsFormCompareDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormCompareDirective, selector: "[fsFormCompare]", inputs: { fsFormCompare: "fsFormCompare", validationMessage: ["fsFormCompareMessage", "validationMessage"] }, providers: [
1595
+ VALIDATE_MESSAGE_PROVIDER,
1596
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1597
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormCompareDirective, decorators: [{
1598
+ type: Directive,
1599
+ args: [{
1600
+ selector: '[fsFormCompare]',
1601
+ providers: [
1602
+ VALIDATE_MESSAGE_PROVIDER,
1603
+ ],
1604
+ }]
1605
+ }], propDecorators: { fsFormCompare: [{
1606
+ type: Input
1607
+ }], validationMessage: [{
1608
+ type: Input,
1609
+ args: ['fsFormCompareMessage']
1526
1610
  }] } });
1527
1611
 
1528
- class FsFormIntegerDirective extends FsControlDirective {
1529
- set validationMessage(value) {
1530
- this._validateMessages.integer = value;
1531
- }
1532
- ngOnChanges() {
1533
- this._control.updateValueAndValidity();
1534
- }
1535
- validate(control) {
1536
- if (isEnabled(this.fsFormInteger)) {
1537
- return FsValidators.integer(this._control);
1538
- }
1539
- else {
1540
- return null;
1541
- }
1542
- }
1543
- }
1544
- FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1545
- FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "validationMessage"] }, providers: [
1546
- VALIDATE_MESSAGE_PROVIDER
1547
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1548
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1549
- type: Directive,
1550
- args: [{
1551
- selector: '[fsFormInteger]',
1552
- providers: [
1553
- VALIDATE_MESSAGE_PROVIDER
1554
- ],
1555
- }]
1556
- }], propDecorators: { fsFormInteger: [{
1557
- type: Input
1558
- }], validationMessage: [{
1559
- type: Input,
1560
- args: ['fsFormIntegerMessage']
1612
+ class FsFormIntegerDirective extends FsControlDirective {
1613
+ set validationMessage(value) {
1614
+ this._validateMessages.integer = value;
1615
+ }
1616
+ ngOnChanges() {
1617
+ this._control.updateValueAndValidity();
1618
+ }
1619
+ validate(control) {
1620
+ if (isEnabled(this.fsFormInteger)) {
1621
+ return FsValidators.integer(this._control);
1622
+ }
1623
+ else {
1624
+ return null;
1625
+ }
1626
+ }
1627
+ }
1628
+ FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1629
+ FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "validationMessage"] }, providers: [
1630
+ VALIDATE_MESSAGE_PROVIDER
1631
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1632
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1633
+ type: Directive,
1634
+ args: [{
1635
+ selector: '[fsFormInteger]',
1636
+ providers: [
1637
+ VALIDATE_MESSAGE_PROVIDER
1638
+ ],
1639
+ }]
1640
+ }], propDecorators: { fsFormInteger: [{
1641
+ type: Input
1642
+ }], validationMessage: [{
1643
+ type: Input,
1644
+ args: ['fsFormIntegerMessage']
1561
1645
  }] } });
1562
1646
 
1563
- class FsFormNumericDirective extends FsControlDirective {
1564
- set validationMessage(value) {
1565
- this._validateMessages.numeric = value;
1566
- }
1567
- ngOnChanges() {
1568
- this._control.updateValueAndValidity();
1569
- }
1570
- validate(control) {
1571
- if (isEnabled(this.fsFormNumeric)) {
1572
- return FsValidators.numeric(this._control);
1573
- }
1574
- else {
1575
- return null;
1576
- }
1577
- }
1578
- }
1579
- FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1580
- FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "validationMessage"] }, providers: [
1581
- VALIDATE_MESSAGE_PROVIDER
1582
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1583
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNumericDirective, decorators: [{
1584
- type: Directive,
1585
- args: [{
1586
- selector: '[fsFormNumeric]',
1587
- providers: [
1588
- VALIDATE_MESSAGE_PROVIDER
1589
- ],
1590
- }]
1591
- }], propDecorators: { fsFormNumeric: [{
1592
- type: Input
1593
- }], validationMessage: [{
1594
- type: Input,
1595
- args: ['fsFormNumericMessage']
1647
+ class FsFormNumericDirective extends FsControlDirective {
1648
+ set validationMessage(value) {
1649
+ this._validateMessages.numeric = value;
1650
+ }
1651
+ ngOnChanges() {
1652
+ this._control.updateValueAndValidity();
1653
+ }
1654
+ validate(control) {
1655
+ if (isEnabled(this.fsFormNumeric)) {
1656
+ return FsValidators.numeric(this._control);
1657
+ }
1658
+ else {
1659
+ return null;
1660
+ }
1661
+ }
1662
+ }
1663
+ FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1664
+ FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "validationMessage"] }, providers: [
1665
+ VALIDATE_MESSAGE_PROVIDER
1666
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNumericDirective, decorators: [{
1668
+ type: Directive,
1669
+ args: [{
1670
+ selector: '[fsFormNumeric]',
1671
+ providers: [
1672
+ VALIDATE_MESSAGE_PROVIDER
1673
+ ],
1674
+ }]
1675
+ }], propDecorators: { fsFormNumeric: [{
1676
+ type: Input
1677
+ }], validationMessage: [{
1678
+ type: Input,
1679
+ args: ['fsFormNumericMessage']
1596
1680
  }] } });
1597
1681
 
1598
- class FsFormPatternDirective extends FsControlDirective {
1599
- set validationMessage(value) {
1600
- this._validateMessages.pattern = value;
1601
- }
1602
- ngOnChanges() {
1603
- this._control.updateValueAndValidity();
1604
- }
1605
- validate(control) {
1606
- return Validators.pattern(this.fsFormPattern)(this._control);
1607
- }
1608
- }
1609
- FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1610
- FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "validationMessage"] }, providers: [
1611
- VALIDATE_MESSAGE_PROVIDER
1612
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1613
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPatternDirective, decorators: [{
1614
- type: Directive,
1615
- args: [{
1616
- selector: '[fsFormPattern]',
1617
- providers: [
1618
- VALIDATE_MESSAGE_PROVIDER
1619
- ],
1620
- }]
1621
- }], propDecorators: { fsFormPattern: [{
1622
- type: Input
1623
- }], validationMessage: [{
1624
- type: Input,
1625
- args: ['fsFormPatternMessage']
1682
+ class FsFormPatternDirective extends FsControlDirective {
1683
+ set validationMessage(value) {
1684
+ this._validateMessages.pattern = value;
1685
+ }
1686
+ ngOnChanges() {
1687
+ this._control.updateValueAndValidity();
1688
+ }
1689
+ validate(control) {
1690
+ return Validators.pattern(this.fsFormPattern)(this._control);
1691
+ }
1692
+ }
1693
+ FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1694
+ FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "validationMessage"] }, providers: [
1695
+ VALIDATE_MESSAGE_PROVIDER
1696
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1697
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormPatternDirective, decorators: [{
1698
+ type: Directive,
1699
+ args: [{
1700
+ selector: '[fsFormPattern]',
1701
+ providers: [
1702
+ VALIDATE_MESSAGE_PROVIDER
1703
+ ],
1704
+ }]
1705
+ }], propDecorators: { fsFormPattern: [{
1706
+ type: Input
1707
+ }], validationMessage: [{
1708
+ type: Input,
1709
+ args: ['fsFormPatternMessage']
1626
1710
  }] } });
1627
1711
 
1628
- class FsFormFunctionDirective extends FsControlDirective {
1629
- constructor() {
1630
- super(...arguments);
1631
- this.validateOnSubmit = false;
1632
- }
1633
- ngOnChanges() {
1634
- this._control.updateValueAndValidity();
1635
- }
1636
- validateAsync(control) {
1637
- if (this.validateOnSubmit && !this.formDirective.validating) {
1638
- return of(null);
1639
- }
1640
- return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
1641
- }
1642
- }
1643
- FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
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: [
1645
- VALIDATE_MESSAGE_PROVIDER
1646
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1647
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
1648
- type: Directive,
1649
- args: [{
1650
- selector: '[fsFormFunction]',
1651
- providers: [
1652
- VALIDATE_MESSAGE_PROVIDER
1653
- ],
1654
- }]
1655
- }], propDecorators: { fsFormFunction: [{
1656
- type: Input
1657
- }], fsFormFunctionData: [{
1658
- type: Input
1659
- }], validateOnSubmit: [{
1660
- type: Input
1712
+ class FsFormFunctionDirective extends FsControlDirective {
1713
+ constructor() {
1714
+ super(...arguments);
1715
+ this.validateOnSubmit = false;
1716
+ }
1717
+ ngOnChanges() {
1718
+ this._control.updateValueAndValidity();
1719
+ }
1720
+ validateAsync(control) {
1721
+ if (this.validateOnSubmit && !this.formDirective.validating) {
1722
+ return of(null);
1723
+ }
1724
+ return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
1725
+ }
1726
+ }
1727
+ FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1728
+ FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
1729
+ VALIDATE_MESSAGE_PROVIDER
1730
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1731
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
1732
+ type: Directive,
1733
+ args: [{
1734
+ selector: '[fsFormFunction]',
1735
+ providers: [
1736
+ VALIDATE_MESSAGE_PROVIDER
1737
+ ],
1738
+ }]
1739
+ }], propDecorators: { fsFormFunction: [{
1740
+ type: Input
1741
+ }], fsFormFunctionData: [{
1742
+ type: Input
1743
+ }], validateOnSubmit: [{
1744
+ type: Input
1661
1745
  }] } });
1662
1746
 
1663
- class FsFormGreaterDirective extends FsControlDirective {
1664
- set validationMessage(value) {
1665
- this._validateMessages.greater = value;
1666
- }
1667
- ngOnChanges() {
1668
- this._control.updateValueAndValidity();
1669
- }
1670
- validate(control) {
1671
- const greater = parseFloat(this.fsFormGreater);
1672
- const value = parseFloat(this._control.value);
1673
- if (!isNaN(greater) && !isNaN(value) && value <= greater) {
1674
- return { greater: { greater, actual: value } };
1675
- }
1676
- return FsValidators.numeric(this._control);
1677
- }
1678
- }
1679
- FsFormGreaterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormGreaterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1680
- FsFormGreaterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormGreaterDirective, selector: "[fsFormGreater]", inputs: { fsFormGreater: "fsFormGreater", validationMessage: ["fsFormGreaterMessage", "validationMessage"] }, providers: [
1681
- VALIDATE_MESSAGE_PROVIDER
1682
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1683
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
1684
- type: Directive,
1685
- args: [{
1686
- selector: '[fsFormGreater]',
1687
- providers: [
1688
- VALIDATE_MESSAGE_PROVIDER
1689
- ],
1690
- }]
1691
- }], propDecorators: { fsFormGreater: [{
1692
- type: Input
1693
- }], validationMessage: [{
1694
- type: Input,
1695
- args: ['fsFormGreaterMessage']
1747
+ class FsFormGreaterDirective extends FsControlDirective {
1748
+ set validationMessage(value) {
1749
+ this._validateMessages.greater = value;
1750
+ }
1751
+ ngOnChanges() {
1752
+ this._control.updateValueAndValidity();
1753
+ }
1754
+ validate(control) {
1755
+ const greater = parseFloat(this.fsFormGreater);
1756
+ const value = parseFloat(this._control.value);
1757
+ if (!isNaN(greater) && !isNaN(value) && value <= greater) {
1758
+ return { greater: { greater, actual: value } };
1759
+ }
1760
+ return FsValidators.numeric(this._control);
1761
+ }
1762
+ }
1763
+ FsFormGreaterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormGreaterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1764
+ FsFormGreaterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormGreaterDirective, selector: "[fsFormGreater]", inputs: { fsFormGreater: "fsFormGreater", validationMessage: ["fsFormGreaterMessage", "validationMessage"] }, providers: [
1765
+ VALIDATE_MESSAGE_PROVIDER
1766
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1767
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
1768
+ type: Directive,
1769
+ args: [{
1770
+ selector: '[fsFormGreater]',
1771
+ providers: [
1772
+ VALIDATE_MESSAGE_PROVIDER
1773
+ ],
1774
+ }]
1775
+ }], propDecorators: { fsFormGreater: [{
1776
+ type: Input
1777
+ }], validationMessage: [{
1778
+ type: Input,
1779
+ args: ['fsFormGreaterMessage']
1696
1780
  }] } });
1697
1781
 
1698
- class FsFormDateRangeDirective extends FsControlDirective {
1699
- set validationMessage(value) {
1700
- this._validateMessages.dateRange = value;
1701
- }
1702
- ngOnChanges() {
1703
- this._control.updateValueAndValidity();
1704
- }
1705
- validate(control) {
1706
- if (isEnabled(this.fsFormDateRange)) {
1707
- return FsValidators.dateRange(this._control);
1708
- }
1709
- else {
1710
- return null;
1711
- }
1712
- }
1713
- }
1714
- FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1715
- FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "validationMessage"] }, providers: [
1716
- VALIDATE_MESSAGE_PROVIDER
1717
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1718
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1719
- type: Directive,
1720
- args: [{
1721
- selector: '[fsFormDateRange]',
1722
- providers: [
1723
- VALIDATE_MESSAGE_PROVIDER
1724
- ],
1725
- }]
1726
- }], propDecorators: { fsFormDateRange: [{
1727
- type: Input
1728
- }], validationMessage: [{
1729
- type: Input,
1730
- args: ['fsFormDateRangeMessage']
1782
+ class FsFormDateRangeDirective extends FsControlDirective {
1783
+ set validationMessage(value) {
1784
+ this._validateMessages.dateRange = value;
1785
+ }
1786
+ ngOnChanges() {
1787
+ this._control.updateValueAndValidity();
1788
+ }
1789
+ validate(control) {
1790
+ if (isEnabled(this.fsFormDateRange)) {
1791
+ return FsValidators.dateRange(this._control);
1792
+ }
1793
+ else {
1794
+ return null;
1795
+ }
1796
+ }
1797
+ }
1798
+ FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1799
+ FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "validationMessage"] }, providers: [
1800
+ VALIDATE_MESSAGE_PROVIDER
1801
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1802
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1803
+ type: Directive,
1804
+ args: [{
1805
+ selector: '[fsFormDateRange]',
1806
+ providers: [
1807
+ VALIDATE_MESSAGE_PROVIDER
1808
+ ],
1809
+ }]
1810
+ }], propDecorators: { fsFormDateRange: [{
1811
+ type: Input
1812
+ }], validationMessage: [{
1813
+ type: Input,
1814
+ args: ['fsFormDateRangeMessage']
1731
1815
  }] } });
1732
1816
 
1733
- class FsFormLesserDirective extends FsControlDirective {
1734
- set validationMessage(value) {
1735
- this._validateMessages.lesser = value;
1736
- }
1737
- ngOnChanges() {
1738
- this._control.updateValueAndValidity();
1739
- }
1740
- validate(control) {
1741
- const lesser = parseFloat(this.fsFormLesser);
1742
- const value = parseFloat(this._control.value);
1743
- if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1744
- return { lesser: { lesser, actual: value } };
1745
- }
1746
- return FsValidators.numeric(this._control);
1747
- }
1748
- }
1749
- FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1750
- FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
1751
- VALIDATE_MESSAGE_PROVIDER
1752
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1753
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1754
- type: Directive,
1755
- args: [{
1756
- selector: '[fsFormLesser]',
1757
- providers: [
1758
- VALIDATE_MESSAGE_PROVIDER
1759
- ],
1760
- }]
1761
- }], propDecorators: { fsFormLesser: [{
1762
- type: Input
1763
- }], validationMessage: [{
1764
- type: Input,
1765
- args: ['fsFormLesserMessage']
1817
+ class FsFormLesserDirective extends FsControlDirective {
1818
+ set validationMessage(value) {
1819
+ this._validateMessages.lesser = value;
1820
+ }
1821
+ ngOnChanges() {
1822
+ this._control.updateValueAndValidity();
1823
+ }
1824
+ validate(control) {
1825
+ const lesser = parseFloat(this.fsFormLesser);
1826
+ const value = parseFloat(this._control.value);
1827
+ if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1828
+ return { lesser: { lesser, actual: value } };
1829
+ }
1830
+ return FsValidators.numeric(this._control);
1831
+ }
1832
+ }
1833
+ FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1834
+ FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
1835
+ VALIDATE_MESSAGE_PROVIDER
1836
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1837
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1838
+ type: Directive,
1839
+ args: [{
1840
+ selector: '[fsFormLesser]',
1841
+ providers: [
1842
+ VALIDATE_MESSAGE_PROVIDER
1843
+ ],
1844
+ }]
1845
+ }], propDecorators: { fsFormLesser: [{
1846
+ type: Input
1847
+ }], validationMessage: [{
1848
+ type: Input,
1849
+ args: ['fsFormLesserMessage']
1766
1850
  }] } });
1767
1851
 
1768
- class FsFormUrlDirective extends FsControlDirective {
1769
- constructor() {
1770
- super(...arguments);
1771
- this.fsFormUrlProtocol = false;
1772
- }
1773
- set validationMessage(value) {
1774
- this._validateMessages.url = value;
1775
- }
1776
- ngOnChanges() {
1777
- this._control.updateValueAndValidity();
1778
- }
1779
- validate(control) {
1780
- if (isEnabled(this.fsFormUrl)) {
1781
- return FsValidators.url(this._control, this.fsFormUrlProtocol);
1782
- }
1783
- else {
1784
- return null;
1785
- }
1786
- }
1787
- }
1788
- FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1789
- FsFormUrlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormUrlDirective, selector: "[fsFormUrl]", inputs: { fsFormUrl: "fsFormUrl", fsFormUrlProtocol: "fsFormUrlProtocol", validationMessage: ["fsFormUrlMessage", "validationMessage"] }, providers: [
1790
- VALIDATE_MESSAGE_PROVIDER
1791
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1792
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormUrlDirective, decorators: [{
1793
- type: Directive,
1794
- args: [{
1795
- selector: '[fsFormUrl]',
1796
- providers: [
1797
- VALIDATE_MESSAGE_PROVIDER
1798
- ],
1799
- }]
1800
- }], propDecorators: { fsFormUrl: [{
1801
- type: Input
1802
- }], fsFormUrlProtocol: [{
1803
- type: Input
1804
- }], validationMessage: [{
1805
- type: Input,
1806
- args: ['fsFormUrlMessage']
1852
+ class FsFormUrlDirective extends FsControlDirective {
1853
+ constructor() {
1854
+ super(...arguments);
1855
+ this.fsFormUrlProtocol = false;
1856
+ }
1857
+ set validationMessage(value) {
1858
+ this._validateMessages.url = value;
1859
+ }
1860
+ ngOnChanges() {
1861
+ this._control.updateValueAndValidity();
1862
+ }
1863
+ validate(control) {
1864
+ if (isEnabled(this.fsFormUrl)) {
1865
+ return FsValidators.url(this._control, this.fsFormUrlProtocol);
1866
+ }
1867
+ else {
1868
+ return null;
1869
+ }
1870
+ }
1871
+ }
1872
+ FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1873
+ FsFormUrlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormUrlDirective, selector: "[fsFormUrl]", inputs: { fsFormUrl: "fsFormUrl", fsFormUrlProtocol: "fsFormUrlProtocol", validationMessage: ["fsFormUrlMessage", "validationMessage"] }, providers: [
1874
+ VALIDATE_MESSAGE_PROVIDER
1875
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1876
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormUrlDirective, decorators: [{
1877
+ type: Directive,
1878
+ args: [{
1879
+ selector: '[fsFormUrl]',
1880
+ providers: [
1881
+ VALIDATE_MESSAGE_PROVIDER
1882
+ ],
1883
+ }]
1884
+ }], propDecorators: { fsFormUrl: [{
1885
+ type: Input
1886
+ }], fsFormUrlProtocol: [{
1887
+ type: Input
1888
+ }], validationMessage: [{
1889
+ type: Input,
1890
+ args: ['fsFormUrlMessage']
1807
1891
  }] } });
1808
1892
 
1809
- class FsButtonDirective {
1810
- constructor(_matButton, _form, _elementRef, _cdRef) {
1811
- this._matButton = _matButton;
1812
- this._form = _form;
1813
- this._elementRef = _elementRef;
1814
- this._cdRef = _cdRef;
1815
- this.dirtySubmit = true;
1816
- this.transitionStyle = null;
1817
- this.active = false;
1818
- this.submit = false;
1819
- this._previousDisabled = false;
1820
- this._destroy$ = new Subject();
1821
- }
1822
- ngOnInit() {
1823
- this.submit = this._elementRef.nativeElement.getAttribute('type') === 'submit';
1824
- if (this._form) {
1825
- this._form.addButton(this);
1826
- if (this.submit) {
1827
- fromEvent(this.element, 'click')
1828
- .pipe(takeUntil(this._destroy$))
1829
- .subscribe(() => {
1830
- this.active = true;
1831
- });
1832
- if (this.dirtySubmit) {
1833
- if (this._form.dirtySubmitButton) {
1834
- if (!this._form.ngForm.dirty) {
1835
- this.disable();
1836
- }
1837
- }
1838
- }
1839
- this.transitionStyle = 'none';
1840
- setTimeout(() => {
1841
- this.transitionStyle = null;
1842
- }, 500);
1843
- }
1844
- }
1845
- }
1846
- disable() {
1847
- if (this._matButton && !this.active) {
1848
- this._previousDisabled = this._matButton.disabled;
1849
- this._matButton.disabled = true;
1850
- this._cdRef.markForCheck();
1851
- }
1852
- }
1853
- enable() {
1854
- if (this._matButton) {
1855
- this._matButton.disabled = false;
1856
- this._matButton.disableRipple = true;
1857
- this._cdRef.markForCheck();
1858
- }
1859
- }
1860
- process() {
1861
- this.setClass('process');
1862
- this._matButton.disableRipple = true;
1863
- }
1864
- success() {
1865
- this.setClass('success');
1866
- this._matButton.disableRipple = false;
1867
- }
1868
- error() {
1869
- this.setClass('error');
1870
- this._matButton.disableRipple = false;
1871
- }
1872
- setClass(cls) {
1873
- const svg = this._getSvg(cls);
1874
- this._resetClass();
1875
- this._disableShadowAnimation();
1876
- this.element.classList.add(`submit-${cls}`);
1877
- this.element.append(svg);
1878
- }
1879
- get element() {
1880
- return this._elementRef.nativeElement;
1881
- }
1882
- resetActive() {
1883
- this.active = false;
1884
- }
1885
- reset() {
1886
- if (!this._previousDisabled) {
1887
- this.enable();
1888
- }
1889
- this.element.querySelectorAll('.svg-icon')
1890
- .forEach((el) => {
1891
- el.remove();
1892
- });
1893
- this._matButton.disableRipple = false;
1894
- this._resetClass();
1895
- }
1896
- ngOnDestroy() {
1897
- var _a;
1898
- this._destroy$.next();
1899
- this._destroy$.complete();
1900
- (_a = this._form) === null || _a === void 0 ? void 0 : _a.removeButton(this);
1901
- }
1902
- _disableShadowAnimation() {
1903
- // .mat-elevation-z2 removes the click shadow animation
1904
- //this.element.classList.add('mat-elevation-z2');
1905
- }
1906
- _resetClass() {
1907
- this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
1908
- }
1909
- _getSvg(type) {
1910
- if (type === 'success') {
1893
+ class FsButtonDirective {
1894
+ constructor(_matButton, _form, _elementRef, _cdRef) {
1895
+ this._matButton = _matButton;
1896
+ this._form = _form;
1897
+ this._elementRef = _elementRef;
1898
+ this._cdRef = _cdRef;
1899
+ this.dirtySubmit = true;
1900
+ this.transitionStyle = null;
1901
+ this.active = false;
1902
+ this.submit = false;
1903
+ this._previousDisabled = false;
1904
+ this._destroy$ = new Subject();
1905
+ }
1906
+ ngOnInit() {
1907
+ this.submit = this._elementRef.nativeElement.getAttribute('type') === 'submit';
1908
+ if (this._form) {
1909
+ this._form.addButton(this);
1910
+ if (this.submit) {
1911
+ fromEvent(this.element, 'click')
1912
+ .pipe(takeUntil(this._destroy$))
1913
+ .subscribe(() => {
1914
+ this.active = true;
1915
+ });
1916
+ if (this.dirtySubmit) {
1917
+ if (this._form.dirtySubmitButton) {
1918
+ if (!this._form.ngForm.dirty) {
1919
+ this.disable();
1920
+ }
1921
+ }
1922
+ }
1923
+ this.transitionStyle = 'none';
1924
+ setTimeout(() => {
1925
+ this.transitionStyle = null;
1926
+ }, 500);
1927
+ }
1928
+ }
1929
+ }
1930
+ disable() {
1931
+ if (this._matButton && !this.active) {
1932
+ this._previousDisabled = this._matButton.disabled;
1933
+ this._matButton.disabled = true;
1934
+ this._cdRef.markForCheck();
1935
+ }
1936
+ }
1937
+ enable() {
1938
+ if (this._matButton) {
1939
+ this._matButton.disabled = false;
1940
+ this._matButton.disableRipple = true;
1941
+ this._cdRef.markForCheck();
1942
+ }
1943
+ }
1944
+ process() {
1945
+ this.setClass('process');
1946
+ if (this._matButton) {
1947
+ this._matButton.disableRipple = true;
1948
+ }
1949
+ }
1950
+ success() {
1951
+ this.setClass('success');
1952
+ if (this._matButton) {
1953
+ this._matButton.disableRipple = false;
1954
+ }
1955
+ }
1956
+ error() {
1957
+ this.setClass('error');
1958
+ if (this._matButton) {
1959
+ this._matButton.disableRipple = false;
1960
+ }
1961
+ }
1962
+ setClass(cls) {
1963
+ const svg = this._getSvg(cls);
1964
+ this._resetClass();
1965
+ this._disableShadowAnimation();
1966
+ this.element.classList.add(`submit-${cls}`);
1967
+ this.element.append(svg);
1968
+ }
1969
+ get element() {
1970
+ return this._elementRef.nativeElement;
1971
+ }
1972
+ resetActive() {
1973
+ this.active = false;
1974
+ }
1975
+ reset() {
1976
+ if (!this._previousDisabled) {
1977
+ this.enable();
1978
+ }
1979
+ this.element.querySelectorAll('.svg-icon')
1980
+ .forEach((el) => {
1981
+ el.remove();
1982
+ });
1983
+ if (this._matButton) {
1984
+ this._matButton.disableRipple = false;
1985
+ }
1986
+ this._resetClass();
1987
+ }
1988
+ ngOnDestroy() {
1989
+ var _a;
1990
+ this._destroy$.next();
1991
+ this._destroy$.complete();
1992
+ (_a = this._form) === null || _a === void 0 ? void 0 : _a.removeButton(this);
1993
+ }
1994
+ _disableShadowAnimation() {
1995
+ // .mat-elevation-z2 removes the click shadow animation
1996
+ //this.element.classList.add('mat-elevation-z2');
1997
+ }
1998
+ _resetClass() {
1999
+ this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
2000
+ }
2001
+ _getSvg(type) {
2002
+ if (type === 'success') {
1911
2003
  return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-success" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 38 38" style="enable-background:new 0 0 38 38;" xml:space="preserve" width="38px" height="38px">
1912
2004
  <g>
1913
2005
  <g class="check">
@@ -1916,396 +2008,365 @@ class FsButtonDirective {
1916
2008
  </g>
1917
2009
  </g>
1918
2010
  </g>
1919
- </svg>`, 'text/xml').firstChild;
1920
- }
1921
- if (type === 'process') {
2011
+ </svg>`, 'text/xml').firstChild;
2012
+ }
2013
+ if (type === 'process') {
1922
2014
  return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-process" width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
1923
2015
  <g fill="none" fill-rule="evenodd">
1924
2016
  <g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
1925
2017
  <path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur=".7s" repeatCount="indefinite"/></path>
1926
2018
  </g>
1927
2019
  </g>
1928
- </svg>`, 'text/xml').firstChild;
1929
- }
1930
- if (type === 'error') {
1931
- return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-error" xmlns="http://www.w3.org/2000/svg" width="38px" height="38px" viewBox="0 0 16 16"><g><path d="M8 1c3.9 0 7 3.1 7 7s-3.1 7-7 7-7-3.1-7-7 3.1-7 7-7zM8 0c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8v0z" data-original="#444444" data-old_color="#444444"/><path d="M12.2 10.8l-2.8-2.8 2.8-2.8-1.4-1.4-2.8 2.8-2.8-2.8-1.4 1.4 2.8 2.8-2.8 2.8 1.4 1.4 2.8-2.8 2.8 2.8z"/></g> </svg>`, 'text/xml').firstChild;
1932
- }
1933
- }
1934
- }
1935
- FsButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsButtonDirective, deps: [{ token: i1$1.MatButton, host: true, optional: true }, { token: FsFormDirective, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1936
- FsButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: { name: "name", dirtySubmit: "dirtySubmit" }, host: { properties: { "style.transition": "this.transitionStyle" } }, ngImport: i0 });
1937
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsButtonDirective, decorators: [{
1938
- type: Directive,
1939
- args: [{
1940
- selector: '[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]',
1941
- }]
1942
- }], ctorParameters: function () { return [{ type: i1$1.MatButton, decorators: [{
1943
- type: Optional
1944
- }, {
1945
- type: Host
1946
- }] }, { type: FsFormDirective, decorators: [{
1947
- type: Optional
1948
- }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
1949
- type: Input
1950
- }], dirtySubmit: [{
1951
- type: Input
1952
- }], transitionStyle: [{
1953
- type: HostBinding,
1954
- args: ['style.transition']
2020
+ </svg>`, 'text/xml').firstChild;
2021
+ }
2022
+ if (type === 'error') {
2023
+ return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-error" xmlns="http://www.w3.org/2000/svg" width="38px" height="38px" viewBox="0 0 16 16"><g><path d="M8 1c3.9 0 7 3.1 7 7s-3.1 7-7 7-7-3.1-7-7 3.1-7 7-7zM8 0c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8v0z" data-original="#444444" data-old_color="#444444"/><path d="M12.2 10.8l-2.8-2.8 2.8-2.8-1.4-1.4-2.8 2.8-2.8-2.8-1.4 1.4 2.8 2.8-2.8 2.8 1.4 1.4 2.8-2.8 2.8 2.8z"/></g> </svg>`, 'text/xml').firstChild;
2024
+ }
2025
+ }
2026
+ }
2027
+ FsButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsButtonDirective, deps: [{ token: i1$2.MatButton, host: true, optional: true }, { token: FsFormDirective, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2028
+ FsButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: { name: "name", dirtySubmit: "dirtySubmit" }, host: { properties: { "style.transition": "this.transitionStyle" } }, ngImport: i0 });
2029
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsButtonDirective, decorators: [{
2030
+ type: Directive,
2031
+ args: [{
2032
+ selector: '[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]',
2033
+ }]
2034
+ }], ctorParameters: function () { return [{ type: i1$2.MatButton, decorators: [{
2035
+ type: Optional
2036
+ }, {
2037
+ type: Host
2038
+ }] }, { type: FsFormDirective, decorators: [{
2039
+ type: Optional
2040
+ }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
2041
+ type: Input
2042
+ }], dirtySubmit: [{
2043
+ type: Input
2044
+ }], transitionStyle: [{
2045
+ type: HostBinding,
2046
+ args: ['style.transition']
1955
2047
  }] } });
1956
2048
 
1957
- class FsFormValidateDirective extends FsControlDirective {
1958
- constructor() {
1959
- super(...arguments);
1960
- this.validateOnSubmit = false;
1961
- }
1962
- ngOnChanges() {
1963
- this._control.updateValueAndValidity();
1964
- }
1965
- validateAsync(control) {
1966
- if (this.validateOnSubmit && !this.formDirective.validating) {
1967
- return of(null);
1968
- }
1969
- return FsValidators.func(this._control, this.validateFn, this.validateFnData);
1970
- }
1971
- }
1972
- FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
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: [
1974
- VALIDATE_MESSAGE_PROVIDER
1975
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1976
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormValidateDirective, decorators: [{
1977
- type: Directive,
1978
- args: [{
1979
- selector: '[validate]',
1980
- providers: [
1981
- VALIDATE_MESSAGE_PROVIDER
1982
- ],
1983
- }]
1984
- }], propDecorators: { validateFn: [{
1985
- type: Input,
1986
- args: ['validate']
1987
- }], validateFnData: [{
1988
- type: Input,
1989
- args: ['validateData']
1990
- }], validateOnSubmit: [{
1991
- type: Input
2049
+ class FsFormValidateDirective extends FsControlDirective {
2050
+ constructor() {
2051
+ super(...arguments);
2052
+ this.validateOnSubmit = false;
2053
+ }
2054
+ ngOnChanges() {
2055
+ this._control.updateValueAndValidity();
2056
+ }
2057
+ validateAsync(control) {
2058
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2059
+ return of(null);
2060
+ }
2061
+ return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2062
+ }
2063
+ }
2064
+ FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2065
+ 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: [
2066
+ VALIDATE_MESSAGE_PROVIDER
2067
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2068
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormValidateDirective, decorators: [{
2069
+ type: Directive,
2070
+ args: [{
2071
+ selector: '[validate]',
2072
+ providers: [
2073
+ VALIDATE_MESSAGE_PROVIDER
2074
+ ],
2075
+ }]
2076
+ }], propDecorators: { validateFn: [{
2077
+ type: Input,
2078
+ args: ['validate']
2079
+ }], validateFnData: [{
2080
+ type: Input,
2081
+ args: ['validateData']
2082
+ }], validateOnSubmit: [{
2083
+ type: Input
1992
2084
  }] } });
1993
2085
 
1994
- class FsFormDialogActionsComponent {
1995
- constructor(_form, _dialogRef, _cdRef) {
1996
- this._form = _form;
1997
- this._dialogRef = _dialogRef;
1998
- this._cdRef = _cdRef;
1999
- this.save = true;
2000
- this.create = false;
2001
- this.close = false;
2002
- this.closeData = null;
2003
- this.dirty = false;
2004
- this._destroy$ = new Subject();
2005
- }
2006
- ngOnInit() {
2007
- if (this._form) {
2008
- this._form.ngForm.valueChanges
2009
- .pipe(filter(() => (!this.dirty)), takeUntil(this._destroy$))
2010
- .subscribe(() => {
2011
- this.dirty = this._form.ngForm.dirty;
2012
- this._cdRef.markForCheck();
2013
- });
2014
- this._form.submitted
2015
- .pipe(delay(50), takeUntil(this._destroy$))
2016
- .subscribe(() => {
2017
- this.dirty = false;
2018
- this._cdRef.markForCheck();
2019
- });
2020
- this._form.reseted
2021
- .pipe(takeUntil(this._destroy$))
2022
- .subscribe(() => {
2023
- this.dirty = false;
2024
- this._cdRef.markForCheck();
2025
- });
2026
- }
2027
- }
2028
- closeClick() {
2029
- if (this._form) {
2030
- this._form.triggerConfirm()
2031
- .pipe(filter((confirmResult) => (confirmResult !== ConfirmResult.Review)), takeUntil(this._destroy$))
2032
- .subscribe(() => {
2033
- this._dialogRef.close(this.closeData);
2034
- });
2035
- }
2036
- else {
2037
- this._dialogRef.close(this.closeData);
2038
- }
2039
- }
2040
- ngOnDestroy() {
2041
- this._destroy$.next();
2042
- this._destroy$.complete();
2043
- }
2044
- }
2045
- FsFormDialogActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, deps: [{ token: FsFormDirective, optional: true }, { token: i2$1.MatDialogRef, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2046
- FsFormDialogActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDialogActionsComponent, selector: "fs-form-dialog-actions", inputs: { save: "save", create: "create", close: "close", closeData: "closeData", name: "name" }, ngImport: i0, template: "<div class=\"buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save\">\n <button\n mat-button\n type=\"submit\"\n color=\"primary\"\n [name]=\"name\">\n {{create ? 'Create' : 'Save'}}\n </button>\n <button\n mat-button\n type=\"button\"\n [disabled]=\"close && !dirty && !create\"\n [matDialogClose]=\"null\">\n Cancel\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"save || create\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n\n <div class=\"close\" *ngIf=\"close\">\n <button\n mat-button\n type=\"button\"\n [color]=\"dirty ? 'basic' : 'primary'\"\n (click)=\"closeClick()\">\n Close\n </button>\n </div>\n\n <ng-container *ngIf=\"!(save || create)\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n</div>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n", styles: [".buttons{display:flex;flex-grow:1;align-items:center}.buttons.save-create .close{display:flex;flex-grow:1;justify-content:flex-end}:host{display:flex;flex-grow:1}@media only screen and (max-width: 599px){.buttons{flex-direction:column}}\n"], components: [{ type: i1$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: ["name", "dirtySubmit"] }, { type: i2$1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2047
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
2048
- type: Component,
2049
- args: [{
2050
- selector: 'fs-form-dialog-actions',
2051
- templateUrl: './form-dialog-actions.component.html',
2052
- styleUrls: ['./form-dialog-actions.component.scss'],
2053
- changeDetection: ChangeDetectionStrategy.OnPush,
2054
- }]
2055
- }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
2056
- type: Optional
2057
- }] }, { type: i2$1.MatDialogRef, decorators: [{
2058
- type: Optional
2059
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { save: [{
2060
- type: Input
2061
- }], create: [{
2062
- type: Input
2063
- }], close: [{
2064
- type: Input
2065
- }], closeData: [{
2066
- type: Input
2067
- }], name: [{
2068
- type: Input
2086
+ class FsFormDialogActionsComponent {
2087
+ constructor(_form, _dialogRef, _cdRef) {
2088
+ this._form = _form;
2089
+ this._dialogRef = _dialogRef;
2090
+ this._cdRef = _cdRef;
2091
+ this.save = true;
2092
+ this.create = false;
2093
+ this.close = false;
2094
+ this.closeData = null;
2095
+ this.dirty = false;
2096
+ this._destroy$ = new Subject();
2097
+ }
2098
+ ngOnInit() {
2099
+ if (this._form) {
2100
+ this._form.ngForm.valueChanges
2101
+ .pipe(filter(() => (!this.dirty)), takeUntil(this._destroy$))
2102
+ .subscribe(() => {
2103
+ this.dirty = this._form.ngForm.dirty;
2104
+ this._cdRef.markForCheck();
2105
+ });
2106
+ this._form.submitted
2107
+ .pipe(delay(50), takeUntil(this._destroy$))
2108
+ .subscribe(() => {
2109
+ this.dirty = false;
2110
+ this._cdRef.markForCheck();
2111
+ });
2112
+ this._form.reseted
2113
+ .pipe(takeUntil(this._destroy$))
2114
+ .subscribe(() => {
2115
+ this.dirty = false;
2116
+ this._cdRef.markForCheck();
2117
+ });
2118
+ }
2119
+ }
2120
+ closeClick() {
2121
+ if (this._form) {
2122
+ this._form.triggerConfirm()
2123
+ .pipe(filter((confirmResult) => (confirmResult !== ConfirmResult.Review)), takeUntil(this._destroy$))
2124
+ .subscribe(() => {
2125
+ this._dialogRef.close(this.closeData);
2126
+ });
2127
+ }
2128
+ else {
2129
+ this._dialogRef.close(this.closeData);
2130
+ }
2131
+ }
2132
+ ngOnDestroy() {
2133
+ this._destroy$.next();
2134
+ this._destroy$.complete();
2135
+ }
2136
+ }
2137
+ FsFormDialogActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, deps: [{ token: FsFormDirective, optional: true }, { token: i2$1.MatDialogRef, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2138
+ FsFormDialogActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDialogActionsComponent, selector: "fs-form-dialog-actions", inputs: { save: "save", create: "create", close: "close", closeData: "closeData", name: "name" }, ngImport: i0, template: "<div class=\"buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save\">\n <button\n mat-button\n type=\"submit\"\n color=\"primary\"\n [name]=\"name\">\n {{create ? 'Create' : 'Save'}}\n </button>\n <button\n mat-button\n type=\"button\"\n [disabled]=\"close && !dirty && !create\"\n [matDialogClose]=\"null\">\n Cancel\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"save || create\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n\n <div class=\"close\" *ngIf=\"close\">\n <button\n mat-button\n type=\"button\"\n [color]=\"dirty ? 'basic' : 'primary'\"\n (click)=\"closeClick()\">\n Close\n </button>\n </div>\n\n <ng-container *ngIf=\"!(save || create)\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n</div>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n", styles: [".buttons{display:flex;flex-grow:1;align-items:center}.buttons.save-create .close{display:flex;flex-grow:1;justify-content:flex-end}:host{display:flex;flex-grow:1}@media only screen and (max-width: 599px){.buttons{flex-direction:column}}\n"], components: [{ type: i1$2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: ["name", "dirtySubmit"] }, { type: i2$1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2139
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
2140
+ type: Component,
2141
+ args: [{
2142
+ selector: 'fs-form-dialog-actions',
2143
+ templateUrl: './form-dialog-actions.component.html',
2144
+ styleUrls: ['./form-dialog-actions.component.scss'],
2145
+ changeDetection: ChangeDetectionStrategy.OnPush,
2146
+ }]
2147
+ }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
2148
+ type: Optional
2149
+ }] }, { type: i2$1.MatDialogRef, decorators: [{
2150
+ type: Optional
2151
+ }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { save: [{
2152
+ type: Input
2153
+ }], create: [{
2154
+ type: Input
2155
+ }], close: [{
2156
+ type: Input
2157
+ }], closeData: [{
2158
+ type: Input
2159
+ }], name: [{
2160
+ type: Input
2069
2161
  }] } });
2070
2162
 
2071
- /**
2072
- * This directive required for cases when we have custom Control like <fs-phone-field> but without any of our validators applied
2073
- *
2074
- * This directive required for automatic validation messages
2075
- */
2076
- class FsFormNoFsValidatorsDirective extends FsControlDirective {
2077
- ngOnChanges() {
2078
- this._control.updateValueAndValidity();
2079
- }
2080
- }
2081
- FsFormNoFsValidatorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNoFsValidatorsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2082
- FsFormNoFsValidatorsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])", providers: [
2083
- VALIDATE_MESSAGE_PROVIDER
2084
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2085
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNoFsValidatorsDirective, decorators: [{
2086
- type: Directive,
2087
- args: [{
2088
- selector: '[ngModel]' +
2089
- ':not([required])' +
2090
- ':not([fsFormRequired])' +
2091
- ':not([fsFormCompare])' +
2092
- ':not([fsFormDateRange])' +
2093
- ':not([fsFormEmail])' +
2094
- ':not([fsFormEmails])' +
2095
- ':not([fsFormFunction])' +
2096
- ':not([fsFormGreater])' +
2097
- ':not([fsFormInteger])' +
2098
- ':not([fsFormLesser])' +
2099
- ':not([fsFormMax])' +
2100
- ':not([fsFormMaxLength])' +
2101
- ':not([fsFormMin])' +
2102
- ':not([fsFormMinLength])' +
2103
- ':not([fsFormNumeric])' +
2104
- ':not([fsFormPattern])' +
2105
- ':not([fsFormPhone])' +
2106
- ':not([fsFormUrl])' +
2107
- ':not([validate])',
2108
- providers: [
2109
- VALIDATE_MESSAGE_PROVIDER
2110
- ],
2111
- }]
2163
+ /**
2164
+ * This directive required for cases when we have custom Control like <fs-phone-field> but without any of our validators applied
2165
+ *
2166
+ * This directive required for automatic validation messages
2167
+ */
2168
+ class FsFormNoFsValidatorsDirective extends FsControlDirective {
2169
+ ngOnChanges() {
2170
+ this._control.updateValueAndValidity();
2171
+ }
2172
+ }
2173
+ FsFormNoFsValidatorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNoFsValidatorsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2174
+ FsFormNoFsValidatorsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])", providers: [
2175
+ VALIDATE_MESSAGE_PROVIDER
2176
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2177
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormNoFsValidatorsDirective, decorators: [{
2178
+ type: Directive,
2179
+ args: [{
2180
+ selector: '[ngModel]' +
2181
+ ':not([required])' +
2182
+ ':not([fsFormRequired])' +
2183
+ ':not([fsFormCompare])' +
2184
+ ':not([fsFormDateRange])' +
2185
+ ':not([fsFormEmail])' +
2186
+ ':not([fsFormEmails])' +
2187
+ ':not([fsFormFunction])' +
2188
+ ':not([fsFormGreater])' +
2189
+ ':not([fsFormInteger])' +
2190
+ ':not([fsFormLesser])' +
2191
+ ':not([fsFormMax])' +
2192
+ ':not([fsFormMaxLength])' +
2193
+ ':not([fsFormMin])' +
2194
+ ':not([fsFormMinLength])' +
2195
+ ':not([fsFormNumeric])' +
2196
+ ':not([fsFormPattern])' +
2197
+ ':not([fsFormPhone])' +
2198
+ ':not([fsFormUrl])' +
2199
+ ':not([validate])',
2200
+ providers: [
2201
+ VALIDATE_MESSAGE_PROVIDER
2202
+ ],
2203
+ }]
2112
2204
  }] });
2113
2205
 
2114
- class FsSubmitButtonDirective extends FsButtonDirective {
2115
- }
2116
- FsSubmitButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsSubmitButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2117
- FsSubmitButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsSubmitButtonDirective, selector: "dummy-selector", usesInheritance: true, ngImport: i0 });
2118
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsSubmitButtonDirective, decorators: [{
2119
- type: Directive,
2120
- args: [{
2121
- selector: 'dummy-selector',
2122
- }]
2206
+ class FsSubmitButtonDirective extends FsButtonDirective {
2207
+ }
2208
+ FsSubmitButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsSubmitButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2209
+ FsSubmitButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsSubmitButtonDirective, selector: "dummy-selector", usesInheritance: true, ngImport: i0 });
2210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsSubmitButtonDirective, decorators: [{
2211
+ type: Directive,
2212
+ args: [{
2213
+ selector: 'dummy-selector',
2214
+ }]
2123
2215
  }] });
2124
2216
 
2125
- class FsFormModule {
2126
- static forRoot() {
2127
- /**
2128
- * Hack: https://github.com/angular/components/issues/20097
2129
- */
2130
- ErrorStateMatcher.prototype.isErrorState = (control, form) => {
2131
- return (control === null || control === void 0 ? void 0 : control.invalid) && (control === null || control === void 0 ? void 0 : control.touched) && (control === null || control === void 0 ? void 0 : control.dirty);
2132
- };
2133
- return {
2134
- ngModule: FsFormModule,
2135
- };
2136
- }
2137
- }
2138
- FsFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2139
- FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, declarations: [FsFormDirective,
2140
- FsControlDirective,
2141
- FsFormRequiredDirective,
2142
- FsFormMinDirective,
2143
- FsFormMaxDirective,
2144
- FsFormMinLengthDirective,
2145
- FsFormMaxLengthDirective,
2146
- FsFormEmailDirective,
2147
- FsFormEmailsDirective,
2148
- FsFormPhoneDirective,
2149
- FsFormCompareDirective,
2150
- FsFormIntegerDirective,
2151
- FsFormNumericDirective,
2152
- FsFormPatternDirective,
2153
- FsFormFunctionDirective,
2154
- FsFormDateRangeDirective,
2155
- FsFormGreaterDirective,
2156
- FsFormLesserDirective,
2157
- FsFormUrlDirective,
2158
- FsFormDialogCloseDirective,
2159
- FsFormValidateDirective,
2160
- FsFormDialogActionsComponent,
2161
- FsFormNoFsValidatorsDirective,
2162
- FsButtonDirective,
2163
- FsSubmitButtonDirective], imports: [CommonModule,
2164
- FormsModule,
2165
- MatButtonModule,
2166
- MatDialogModule], exports: [FsFormDirective,
2167
- FsControlDirective,
2168
- FsFormRequiredDirective,
2169
- FsFormMinDirective,
2170
- FsFormMaxDirective,
2171
- FsFormMinLengthDirective,
2172
- FsFormMaxLengthDirective,
2173
- FsFormEmailDirective,
2174
- FsFormEmailsDirective,
2175
- FsFormPhoneDirective,
2176
- FsFormCompareDirective,
2177
- FsFormIntegerDirective,
2178
- FsFormNumericDirective,
2179
- FsFormPatternDirective,
2180
- FsFormFunctionDirective,
2181
- FsFormDateRangeDirective,
2182
- FsFormGreaterDirective,
2183
- FsFormLesserDirective,
2184
- FsFormUrlDirective,
2185
- FsFormDialogCloseDirective,
2186
- FsFormValidateDirective,
2187
- FsFormDialogActionsComponent,
2188
- FsFormNoFsValidatorsDirective,
2189
- FsButtonDirective,
2190
- FsSubmitButtonDirective] });
2191
- FsFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, providers: [
2192
- {
2193
- provide: ErrorStateMatcher,
2194
- useClass: ShowOnDirtyErrorStateMatcher,
2195
- },
2196
- ], imports: [[
2197
- CommonModule,
2198
- FormsModule,
2199
- MatButtonModule,
2200
- MatDialogModule,
2201
- ]] });
2202
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, decorators: [{
2203
- type: NgModule,
2204
- args: [{
2205
- imports: [
2206
- CommonModule,
2207
- FormsModule,
2208
- MatButtonModule,
2209
- MatDialogModule,
2210
- ],
2211
- declarations: [
2212
- FsFormDirective,
2213
- FsControlDirective,
2214
- FsFormRequiredDirective,
2215
- FsFormMinDirective,
2216
- FsFormMaxDirective,
2217
- FsFormMinLengthDirective,
2218
- FsFormMaxLengthDirective,
2219
- FsFormEmailDirective,
2220
- FsFormEmailsDirective,
2221
- FsFormPhoneDirective,
2222
- FsFormCompareDirective,
2223
- FsFormIntegerDirective,
2224
- FsFormNumericDirective,
2225
- FsFormPatternDirective,
2226
- FsFormFunctionDirective,
2227
- FsFormDateRangeDirective,
2228
- FsFormGreaterDirective,
2229
- FsFormLesserDirective,
2230
- FsFormUrlDirective,
2231
- FsFormDialogCloseDirective,
2232
- FsFormValidateDirective,
2233
- FsFormDialogActionsComponent,
2234
- FsFormNoFsValidatorsDirective,
2235
- FsButtonDirective,
2236
- FsSubmitButtonDirective,
2237
- ],
2238
- exports: [
2239
- FsFormDirective,
2240
- FsControlDirective,
2241
- FsFormRequiredDirective,
2242
- FsFormMinDirective,
2243
- FsFormMaxDirective,
2244
- FsFormMinLengthDirective,
2245
- FsFormMaxLengthDirective,
2246
- FsFormEmailDirective,
2247
- FsFormEmailsDirective,
2248
- FsFormPhoneDirective,
2249
- FsFormCompareDirective,
2250
- FsFormIntegerDirective,
2251
- FsFormNumericDirective,
2252
- FsFormPatternDirective,
2253
- FsFormFunctionDirective,
2254
- FsFormDateRangeDirective,
2255
- FsFormGreaterDirective,
2256
- FsFormLesserDirective,
2257
- FsFormUrlDirective,
2258
- FsFormDialogCloseDirective,
2259
- FsFormValidateDirective,
2260
- FsFormDialogActionsComponent,
2261
- FsFormNoFsValidatorsDirective,
2262
- FsButtonDirective,
2263
- FsSubmitButtonDirective,
2264
- ],
2265
- providers: [
2266
- {
2267
- provide: ErrorStateMatcher,
2268
- useClass: ShowOnDirtyErrorStateMatcher,
2269
- },
2270
- ],
2271
- }]
2217
+ class FsFormModule {
2218
+ static forRoot() {
2219
+ /**
2220
+ * Hack: https://github.com/angular/components/issues/20097
2221
+ */
2222
+ ErrorStateMatcher.prototype.isErrorState = (control, form) => {
2223
+ return (control === null || control === void 0 ? void 0 : control.invalid) && (control === null || control === void 0 ? void 0 : control.touched) && (control === null || control === void 0 ? void 0 : control.dirty);
2224
+ };
2225
+ return {
2226
+ ngModule: FsFormModule,
2227
+ };
2228
+ }
2229
+ }
2230
+ FsFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2231
+ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, declarations: [FsFormDirective,
2232
+ FsControlDirective,
2233
+ FsFormRequiredDirective,
2234
+ FsFormMinDirective,
2235
+ FsFormMaxDirective,
2236
+ FsFormMinLengthDirective,
2237
+ FsFormMaxLengthDirective,
2238
+ FsFormEmailDirective,
2239
+ FsFormEmailsDirective,
2240
+ FsFormPhoneDirective,
2241
+ FsFormCompareDirective,
2242
+ FsFormIntegerDirective,
2243
+ FsFormNumericDirective,
2244
+ FsFormPatternDirective,
2245
+ FsFormFunctionDirective,
2246
+ FsFormDateRangeDirective,
2247
+ FsFormGreaterDirective,
2248
+ FsFormLesserDirective,
2249
+ FsFormUrlDirective,
2250
+ FsFormDialogCloseDirective,
2251
+ FsFormValidateDirective,
2252
+ FsFormDialogActionsComponent,
2253
+ FsFormNoFsValidatorsDirective,
2254
+ FsButtonDirective,
2255
+ FsSubmitButtonDirective], imports: [CommonModule,
2256
+ FormsModule,
2257
+ MatButtonModule,
2258
+ MatDialogModule], exports: [FsFormDirective,
2259
+ FsControlDirective,
2260
+ FsFormRequiredDirective,
2261
+ FsFormMinDirective,
2262
+ FsFormMaxDirective,
2263
+ FsFormMinLengthDirective,
2264
+ FsFormMaxLengthDirective,
2265
+ FsFormEmailDirective,
2266
+ FsFormEmailsDirective,
2267
+ FsFormPhoneDirective,
2268
+ FsFormCompareDirective,
2269
+ FsFormIntegerDirective,
2270
+ FsFormNumericDirective,
2271
+ FsFormPatternDirective,
2272
+ FsFormFunctionDirective,
2273
+ FsFormDateRangeDirective,
2274
+ FsFormGreaterDirective,
2275
+ FsFormLesserDirective,
2276
+ FsFormUrlDirective,
2277
+ FsFormDialogCloseDirective,
2278
+ FsFormValidateDirective,
2279
+ FsFormDialogActionsComponent,
2280
+ FsFormNoFsValidatorsDirective,
2281
+ FsButtonDirective,
2282
+ FsSubmitButtonDirective] });
2283
+ FsFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, providers: [
2284
+ {
2285
+ provide: ErrorStateMatcher,
2286
+ useClass: ShowOnDirtyErrorStateMatcher,
2287
+ },
2288
+ ], imports: [[
2289
+ CommonModule,
2290
+ FormsModule,
2291
+ MatButtonModule,
2292
+ MatDialogModule,
2293
+ ]] });
2294
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormModule, decorators: [{
2295
+ type: NgModule,
2296
+ args: [{
2297
+ imports: [
2298
+ CommonModule,
2299
+ FormsModule,
2300
+ MatButtonModule,
2301
+ MatDialogModule,
2302
+ ],
2303
+ declarations: [
2304
+ FsFormDirective,
2305
+ FsControlDirective,
2306
+ FsFormRequiredDirective,
2307
+ FsFormMinDirective,
2308
+ FsFormMaxDirective,
2309
+ FsFormMinLengthDirective,
2310
+ FsFormMaxLengthDirective,
2311
+ FsFormEmailDirective,
2312
+ FsFormEmailsDirective,
2313
+ FsFormPhoneDirective,
2314
+ FsFormCompareDirective,
2315
+ FsFormIntegerDirective,
2316
+ FsFormNumericDirective,
2317
+ FsFormPatternDirective,
2318
+ FsFormFunctionDirective,
2319
+ FsFormDateRangeDirective,
2320
+ FsFormGreaterDirective,
2321
+ FsFormLesserDirective,
2322
+ FsFormUrlDirective,
2323
+ FsFormDialogCloseDirective,
2324
+ FsFormValidateDirective,
2325
+ FsFormDialogActionsComponent,
2326
+ FsFormNoFsValidatorsDirective,
2327
+ FsButtonDirective,
2328
+ FsSubmitButtonDirective,
2329
+ ],
2330
+ exports: [
2331
+ FsFormDirective,
2332
+ FsControlDirective,
2333
+ FsFormRequiredDirective,
2334
+ FsFormMinDirective,
2335
+ FsFormMaxDirective,
2336
+ FsFormMinLengthDirective,
2337
+ FsFormMaxLengthDirective,
2338
+ FsFormEmailDirective,
2339
+ FsFormEmailsDirective,
2340
+ FsFormPhoneDirective,
2341
+ FsFormCompareDirective,
2342
+ FsFormIntegerDirective,
2343
+ FsFormNumericDirective,
2344
+ FsFormPatternDirective,
2345
+ FsFormFunctionDirective,
2346
+ FsFormDateRangeDirective,
2347
+ FsFormGreaterDirective,
2348
+ FsFormLesserDirective,
2349
+ FsFormUrlDirective,
2350
+ FsFormDialogCloseDirective,
2351
+ FsFormValidateDirective,
2352
+ FsFormDialogActionsComponent,
2353
+ FsFormNoFsValidatorsDirective,
2354
+ FsButtonDirective,
2355
+ FsSubmitButtonDirective,
2356
+ ],
2357
+ providers: [
2358
+ {
2359
+ provide: ErrorStateMatcher,
2360
+ useClass: ShowOnDirtyErrorStateMatcher,
2361
+ },
2362
+ ],
2363
+ }]
2272
2364
  }] });
2273
2365
 
2274
- class FormDeactivateGuard {
2275
- constructor(_prompt) {
2276
- this._prompt = _prompt;
2277
- }
2278
- canDeactivate(directive) {
2279
- if (!('getForm' in directive)) {
2280
- const error = `Directive ${directive.constructor.name} does not property implement interface FormDeactivate`;
2281
- console.error(error);
2282
- return of(true);
2283
- }
2284
- const form = directive.getForm();
2285
- if (!(form instanceof FsFormDirective)) {
2286
- const error = `Directive ${directive.constructor.name}.getForm() does not return a valid FsFormDirective`;
2287
- console.error(error);
2288
- return of(true);
2289
- }
2290
- return confirmUnsaved(form, this._prompt)
2291
- .pipe(map((result) => {
2292
- return confirmResultContinue(result);
2293
- }));
2294
- }
2295
- }
2296
- FormDeactivateGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormDeactivateGuard, deps: [{ token: i3.FsPrompt }], target: i0.ɵɵFactoryTarget.Injectable });
2297
- FormDeactivateGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormDeactivateGuard, providedIn: 'root' });
2298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormDeactivateGuard, decorators: [{
2299
- type: Injectable,
2300
- args: [{
2301
- providedIn: 'root'
2302
- }]
2303
- }], ctorParameters: function () { return [{ type: i3.FsPrompt }]; } });
2304
-
2305
2366
  // Modules
2306
2367
 
2307
- /**
2308
- * Generated bundle index. Do not edit.
2368
+ /**
2369
+ * Generated bundle index. Do not edit.
2309
2370
  */
2310
2371
 
2311
2372
  export { ConfirmResult, FormDeactivateGuard, FormStatus, FsButtonDirective, FsControlDirective, FsForm, FsFormCompareDirective, FsFormDateRangeDirective, FsFormDialogActionsComponent, FsFormDialogCloseDirective, FsFormDirective, FsFormEmailDirective, FsFormEmailsDirective, FsFormFunctionDirective, FsFormGreaterDirective, FsFormIntegerDirective, FsFormLesserDirective, FsFormMaxDirective, FsFormMaxLengthDirective, FsFormMinDirective, FsFormMinLengthDirective, FsFormModule, FsFormNoFsValidatorsDirective, FsFormNumericDirective, FsFormPatternDirective, FsFormPhoneDirective, FsFormRequiredDirective, FsFormUrlDirective, FsFormValidateDirective, FsSubmitButtonDirective, FsValidators };