@firestitch/form 12.5.2 → 13.1.1

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