@firestitch/form 12.0.1 → 12.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +105 -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 +2613 -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 +618 -618
  50. package/esm2015/app/directives/form-dialog-close.directive.js +30 -30
  51. package/esm2015/app/directives/submit-button.directive.js +130 -130
  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 +35 -35
  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 +164 -164
  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 +2061 -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,1835 @@ 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
+ 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 }]
781
781
  }] } });
782
782
 
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)',
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)',
801
801
  };
802
802
 
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);
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);
810
810
  }
811
811
 
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
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
1057
1057
  }] } });
1058
1058
 
1059
- function isEnabled(value) {
1060
- return value !== 'false' && (value || value === '');
1059
+ function isEnabled(value) {
1060
+ return value !== 'false' && (value || value === '');
1061
1061
  }
1062
1062
 
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']
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']
1126
1126
  }] } });
1127
1127
 
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
- }
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
+ }
1218
1218
  }
1219
1219
 
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']
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']
1248
1248
  }] } });
1249
1249
 
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']
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']
1278
1278
  }] } });
1279
1279
 
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']
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']
1308
1308
  }] } });
1309
1309
 
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']
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']
1338
1338
  }] } });
1339
1339
 
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']
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']
1373
1373
  }] } });
1374
1374
 
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']
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']
1408
1408
  }] } });
1409
1409
 
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']
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']
1443
1443
  }] } });
1444
1444
 
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']
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']
1488
1488
  }] } });
1489
1489
 
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']
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']
1523
1523
  }] } });
1524
1524
 
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']
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']
1558
1558
  }] } });
1559
1559
 
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']
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']
1588
1588
  }] } });
1589
1589
 
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
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
1614
1614
  }] } });
1615
1615
 
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']
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']
1649
1649
  }] } });
1650
1650
 
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']
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']
1684
1684
  }] } });
1685
1685
 
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']
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']
1719
1719
  }] } });
1720
1720
 
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']
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']
1760
1760
  }] } });
1761
1761
 
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') {
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') {
1853
1853
  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
1854
  <g>
1855
1855
  <g class="check">
@@ -1858,316 +1858,316 @@ class FsSubmitButtonDirective {
1858
1858
  </g>
1859
1859
  </g>
1860
1860
  </g>
1861
- </svg>`, 'text/xml').firstChild;
1862
- }
1863
- if (type === 'process') {
1861
+ </svg>`, 'text/xml').firstChild;
1862
+ }
1863
+ if (type === 'process') {
1864
1864
  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
1865
  <g fill="none" fill-rule="evenodd">
1866
1866
  <g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
1867
1867
  <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
1868
  </g>
1869
1869
  </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']
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']
1897
1897
  }] } });
1898
1898
 
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']
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']
1925
1925
  }] } });
1926
1926
 
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
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
1999
1999
  }] } });
2000
2000
 
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
- }]
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
+ }]
2134
2134
  }] });
2135
2135
 
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
- }]
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
+ }]
2165
2165
  }], ctorParameters: function () { return [{ type: i3.FsPrompt }]; } });
2166
2166
 
2167
2167
  // Modules
2168
2168
 
2169
- /**
2170
- * Generated bundle index. Do not edit.
2169
+ /**
2170
+ * Generated bundle index. Do not edit.
2171
2171
  */
2172
2172
 
2173
2173
  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 };