@firestitch/form 12.2.1 → 12.2.3

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