@firestitch/form 9.7.7 → 12.0.2

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