@firestitch/form 12.2.6 → 12.3.1

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