@firestitch/form 9.7.6 → 9.7.7

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