@firestitch/form 12.5.0 → 12.5.2

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