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