@firestitch/form 12.2.6 → 12.3.0

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