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