@firestitch/form 12.0.2 → 12.1.0

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