@firestitch/form 13.1.2 → 13.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/app/components/confirm-unsaved/confirm-unsaved.component.d.ts +21 -0
  2. package/app/components/confirm-unsaved/index.d.ts +1 -0
  3. package/app/components/form-dialog-actions/form-dialog-actions.component.d.ts +1 -1
  4. package/app/components/index.d.ts +1 -0
  5. package/app/consts/error-messages.const.d.ts +2 -0
  6. package/app/directives/button.directive.d.ts +2 -2
  7. package/app/directives/form/form.directive.d.ts +5 -7
  8. package/app/directives/form-dialog-close.directive.d.ts +2 -2
  9. package/app/directives/index.d.ts +2 -2
  10. package/app/directives/validators/compare.directive.d.ts +2 -2
  11. package/app/directives/validators/control.directive.d.ts +12 -12
  12. package/app/directives/validators/function.directive.d.ts +1 -1
  13. package/app/directives/validators/greater-equal.directive.d.ts +13 -0
  14. package/app/directives/validators/index.d.ts +2 -0
  15. package/app/directives/validators/integer.directive.d.ts +1 -1
  16. package/app/directives/validators/lesser-equal.directive.d.ts +13 -0
  17. package/app/directives/validators/no-fs-validators.directive.d.ts +1 -1
  18. package/app/directives/validators/required.directive.d.ts +1 -1
  19. package/app/enums/index.d.ts +2 -0
  20. package/app/fs-form.module.d.ts +20 -16
  21. package/app/guards/form-deactivate.guard.d.ts +2 -4
  22. package/app/helpers/index.d.ts +0 -1
  23. package/app/providers/validate-messages.provider.d.ts +2 -0
  24. package/app/services/fsform.service.d.ts +5 -1
  25. package/esm2020/app/components/confirm-unsaved/confirm-unsaved.component.mjs +44 -0
  26. package/esm2020/app/components/confirm-unsaved/index.mjs +2 -0
  27. package/esm2020/app/components/form-dialog-actions/form-dialog-actions.component.mjs +3 -3
  28. package/esm2020/app/components/form-dialog-actions/index.mjs +1 -1
  29. package/esm2020/app/components/index.mjs +2 -1
  30. package/esm2020/app/consts/error-messages.const.mjs +3 -1
  31. package/esm2020/app/directives/button.directive.mjs +6 -6
  32. package/esm2020/app/directives/form/form.directive.mjs +28 -32
  33. package/esm2020/app/directives/form/index.mjs +1 -1
  34. package/esm2020/app/directives/form-dialog-close.directive.mjs +6 -6
  35. package/esm2020/app/directives/index.mjs +3 -3
  36. package/esm2020/app/directives/validators/compare.directive.mjs +4 -6
  37. package/esm2020/app/directives/validators/control.directive.mjs +20 -21
  38. package/esm2020/app/directives/validators/function.directive.mjs +5 -5
  39. package/esm2020/app/directives/validators/greater-equal.directive.mjs +40 -0
  40. package/esm2020/app/directives/validators/index.mjs +3 -1
  41. package/esm2020/app/directives/validators/integer.directive.mjs +7 -9
  42. package/esm2020/app/directives/validators/lesser-equal.directive.mjs +40 -0
  43. package/esm2020/app/directives/validators/no-fs-validators.directive.mjs +3 -2
  44. package/esm2020/app/directives/validators/required.directive.mjs +6 -8
  45. package/esm2020/app/enums/index.mjs +3 -0
  46. package/esm2020/app/fs-form.module.mjs +40 -23
  47. package/esm2020/app/guards/form-deactivate.guard.mjs +13 -16
  48. package/esm2020/app/helpers/get-form-errors.mjs +1 -1
  49. package/esm2020/app/helpers/index.mjs +1 -2
  50. package/esm2020/app/services/fsform.service.mjs +59 -7
  51. package/esm2020/public_api.mjs +16 -17
  52. package/fesm2015/firestitch-form.mjs +979 -878
  53. package/fesm2015/firestitch-form.mjs.map +1 -1
  54. package/fesm2020/firestitch-form.mjs +965 -866
  55. package/fesm2020/firestitch-form.mjs.map +1 -1
  56. package/package.json +1 -5
  57. package/public_api.d.ts +16 -17
  58. package/app/helpers/confirm-unsaved.d.ts +0 -5
  59. package/esm2020/app/helpers/confirm-unsaved.mjs +0 -72
@@ -1,27 +1,65 @@
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
1
  import * as i4 from '@angular/common';
4
2
  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';
3
+ import * as i0 from '@angular/core';
4
+ import { Component, ChangeDetectionStrategy, Inject, Injectable, EventEmitter, QueryList, Directive, Optional, Input, Output, HostBinding, ContentChildren, Host, HostListener, ViewChild, ViewChildren, InjectionToken, Self, NgModule } from '@angular/core';
5
+ import * as i1$2 from '@angular/forms';
6
+ import { FormGroup, NgForm, NgModel, Validators, FormsModule } from '@angular/forms';
7
+ import * as i1$1 from '@angular/material/button';
8
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
9
  import { ErrorStateMatcher, ShowOnDirtyErrorStateMatcher } from '@angular/material/core';
12
- import * as i3 from '@angular/router';
10
+ import * as i1 from '@angular/material/dialog';
11
+ import { MAT_DIALOG_DATA, MatDialogRef, MatDialogModule } from '@angular/material/dialog';
12
+ import * as i2 from '@firestitch/dialog';
13
+ import { FsDialogModule } from '@firestitch/dialog';
14
+ import { Subject, of, merge, BehaviorSubject, throwError, fromEvent, iif, defer, from, isObservable } from 'rxjs';
15
+ import { filter, map, switchMap, first, mapTo, take, takeUntil, mergeMap, tap, catchError, delay, startWith } from 'rxjs/operators';
16
+ import * as i2$1 from '@angular/router';
13
17
  import { MatTabGroup } from '@angular/material/tabs';
14
18
  import { guid, email, isEmpty, isNumeric, phone, url } from '@firestitch/common';
15
- import * as i7 from '@firestitch/drawer';
19
+ import * as i6 from '@firestitch/drawer';
16
20
  import { DrawerRef } from '@firestitch/drawer';
17
- import * as i2 from '@firestitch/message';
21
+ import * as i2$2 from '@firestitch/message';
18
22
  import { MessageMode } from '@firestitch/message';
19
- import * as i1 from '@firestitch/prompt';
20
- import { Observable, Subject, of, BehaviorSubject, throwError, fromEvent, iif, defer, from, isObservable } from 'rxjs';
21
- import { first, filter, map, takeUntil, take, mergeMap, tap, switchMap, mapTo, catchError, delay, startWith } from 'rxjs/operators';
22
23
  import { values, keys, isObject } from 'lodash-es';
23
24
  import { isValid } from 'date-fns';
24
25
 
26
+ class ConfirmUnsavedComponent {
27
+ constructor(_data, _dialogRef) {
28
+ this._data = _data;
29
+ this._dialogRef = _dialogRef;
30
+ this._destroy$ = new Subject();
31
+ }
32
+ ngOnInit() {
33
+ this.saveLabel = this._data.saveLabel;
34
+ this.discardLabel = this._data.discardLabel;
35
+ this.cancelLabel = this._data.cancelLabel;
36
+ this.message = this._data.message;
37
+ this.title = this._data.title;
38
+ }
39
+ save() {
40
+ this._dialogRef.close('save');
41
+ }
42
+ discard() {
43
+ this._dialogRef.close('discard');
44
+ }
45
+ cancel() {
46
+ this._dialogRef.close(null);
47
+ }
48
+ ngOnDestroy() {
49
+ this._destroy$.next();
50
+ this._destroy$.complete();
51
+ }
52
+ }
53
+ ConfirmUnsavedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ConfirmUnsavedComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
54
+ ConfirmUnsavedComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: ConfirmUnsavedComponent, selector: "ng-component", ngImport: i0, template: "<fs-dialog>\n <h1 mat-dialog-title>{{title}}</h1>\n <mat-dialog-content>\n {{message}}\n </mat-dialog-content> \n <mat-dialog-actions>\n <button\n type=\"button\"\n color=\"primary\"\n (click)=\"save()\"\n fsFormButtonStandalone\n mat-button>\n {{saveLabel}}\n </button>\n <button\n type=\"button\"\n (click)=\"discard()\"\n fsFormButtonStandalone\n mat-button>\n {{discardLabel}}\n </button> \n <button\n type=\"button\"\n (click)=\"cancel()\"\n fsFormButtonStandalone\n mat-button>\n {{cancelLabel}}\n </button> \n </mat-dialog-actions>\n</fs-dialog>\n", styles: [":host{width:100%}.form-buttons.save-create .close-button:not(.cancel-button){float:right}\n"], components: [{ type: i2.FsDialogComponent, selector: "fs-dialog", inputs: ["mobileMode", "mobileButtonPlacement", "mobileWidth", "mode", "buttonLayout"] }, { type: i1$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
55
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ConfirmUnsavedComponent, decorators: [{
56
+ type: Component,
57
+ args: [{ changeDetection: ChangeDetectionStrategy.OnPush, template: "<fs-dialog>\n <h1 mat-dialog-title>{{title}}</h1>\n <mat-dialog-content>\n {{message}}\n </mat-dialog-content> \n <mat-dialog-actions>\n <button\n type=\"button\"\n color=\"primary\"\n (click)=\"save()\"\n fsFormButtonStandalone\n mat-button>\n {{saveLabel}}\n </button>\n <button\n type=\"button\"\n (click)=\"discard()\"\n fsFormButtonStandalone\n mat-button>\n {{discardLabel}}\n </button> \n <button\n type=\"button\"\n (click)=\"cancel()\"\n fsFormButtonStandalone\n mat-button>\n {{cancelLabel}}\n </button> \n </mat-dialog-actions>\n</fs-dialog>\n", styles: [":host{width:100%}.form-buttons.save-create .close-button:not(.cancel-button){float:right}\n"] }]
58
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
59
+ type: Inject,
60
+ args: [MAT_DIALOG_DATA]
61
+ }] }, { type: i1.MatDialogRef }]; } });
62
+
25
63
  var ConfirmResult;
26
64
  (function (ConfirmResult) {
27
65
  ConfirmResult["Save"] = "save";
@@ -31,81 +69,32 @@ var ConfirmResult;
31
69
  ConfirmResult["Pristine"] = "pristine";
32
70
  })(ConfirmResult || (ConfirmResult = {}));
33
71
 
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
72
  function confirmResultContinue(result) {
104
73
  return result === ConfirmResult.Discard || result === ConfirmResult.Save || result === ConfirmResult.Pristine;
105
74
  }
106
75
 
76
+ function getActiveRoute(route) {
77
+ while (route.firstChild) {
78
+ route = route.firstChild;
79
+ }
80
+ return route;
81
+ }
82
+
83
+ var FormStatus;
84
+ (function (FormStatus) {
85
+ FormStatus["Valid"] = "valid";
86
+ FormStatus["Invalid"] = "invalid";
87
+ FormStatus["Validating"] = "validating";
88
+ FormStatus["Submitting"] = "submitting";
89
+ FormStatus["Submitted"] = "submitted";
90
+ FormStatus["Error"] = "error";
91
+ FormStatus["Success"] = "success";
92
+ FormStatus["Completing"] = "completing";
93
+ })(FormStatus || (FormStatus = {}));
94
+
107
95
  class FsForm {
108
- constructor() {
96
+ constructor(_dialog) {
97
+ this._dialog = _dialog;
109
98
  // value is array for future possibilities of extension
110
99
  this._formDirectiveStore = new WeakMap();
111
100
  this._eventBus = new Subject();
@@ -117,7 +106,7 @@ class FsForm {
117
106
  // @deprecated
118
107
  on(key) {
119
108
  return this._eventBus.asObservable()
120
- .pipe(filter(event => event.key === key), map(event => event.data));
109
+ .pipe(filter((event) => event.key === key), map((event) => event.data));
121
110
  }
122
111
  registerFormDirective(routeComponent, directive) {
123
112
  const directives = this.getFormDirectives(routeComponent) || [];
@@ -130,54 +119,94 @@ class FsForm {
130
119
  removeFormDirective(routeComponent) {
131
120
  this._formDirectiveStore.delete(routeComponent);
132
121
  }
122
+ confirmUnsaved(directives) {
123
+ // TODO support for multiple directives per page
124
+ const form = directives[0];
125
+ if (!form.confirm || !form.ngForm.dirty) {
126
+ return of(ConfirmResult.Pristine);
127
+ }
128
+ let title = 'You Have Unsaved Changes';
129
+ let message = 'What would you like to do with your changes?';
130
+ let saveLabel = 'Save & Continue';
131
+ let discardLabel = 'Discard Changes & Continue';
132
+ let cancelLabel = 'Review Changes';
133
+ if (typeof form.confirm === 'object') {
134
+ title = form.confirm.title || title;
135
+ message = form.confirm.message || message;
136
+ saveLabel = form.confirm.saveLabel || saveLabel;
137
+ discardLabel = form.confirm.discardLabel || discardLabel;
138
+ cancelLabel = form.confirm.cancelLabel || cancelLabel;
139
+ }
140
+ return this._dialog.open(ConfirmUnsavedComponent, {
141
+ data: {
142
+ title,
143
+ message,
144
+ saveLabel,
145
+ discardLabel,
146
+ cancelLabel,
147
+ },
148
+ width: 'auto',
149
+ })
150
+ .afterClosed()
151
+ .pipe(switchMap((result) => {
152
+ if (!result) {
153
+ return of(ConfirmResult.Review);
154
+ }
155
+ if (result === 'discard') {
156
+ form.reset();
157
+ return of(ConfirmResult.Discard);
158
+ }
159
+ if (result === 'save') {
160
+ form.ngForm.control.markAsPristine();
161
+ form.triggerSubmit({ confirmed: true });
162
+ return merge(form.submitted
163
+ .pipe(first(), mapTo(ConfirmResult.Save)), form.invalid
164
+ .pipe(first(), mapTo(ConfirmResult.Invalid)))
165
+ .pipe(take(1));
166
+ }
167
+ }));
168
+ }
133
169
  }
134
- FsForm.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsForm, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
170
+ FsForm.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsForm, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable });
135
171
  FsForm.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsForm, providedIn: 'root' });
136
172
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsForm, decorators: [{
137
173
  type: Injectable,
138
174
  args: [{
139
175
  providedIn: 'root',
140
176
  }]
141
- }], ctorParameters: function () { return []; } });
142
-
143
- function getActiveRoute(route) {
144
- while (route.firstChild) {
145
- route = route.firstChild;
146
- }
147
- return route;
148
- }
177
+ }], ctorParameters: function () { return [{ type: i1.MatDialog }]; } });
149
178
 
150
179
  class FormDeactivateGuard {
151
- constructor(_prompt, _fsForm, _route) {
152
- this._prompt = _prompt;
153
- this._fsForm = _fsForm;
180
+ constructor(_form, _route) {
181
+ this._form = _form;
154
182
  this._route = _route;
155
183
  }
156
184
  canDeactivate() {
157
185
  const route = getActiveRoute(this._route);
158
186
  if (!route) {
159
- console.error(`Can not find route for FormDeactivateGuard checks`);
187
+ console.error('Can not find route for FormDeactivateGuard checks');
160
188
  return of(true);
161
189
  }
162
- const directives = this._fsForm.getFormDirectives(route.routeConfig.component);
190
+ const directives = this._form
191
+ .getFormDirectives(route.routeConfig.component);
163
192
  if (!Array.isArray(directives) || directives.length === 0) {
164
- console.error(`Can not find a valid FsFormDirective`);
193
+ console.error('Can not find a valid FsFormDirective');
165
194
  return of(true);
166
195
  }
167
- return confirmUnsaved(directives, this._prompt)
196
+ return this._form.confirmUnsaved(directives)
168
197
  .pipe(map((result) => {
169
198
  return confirmResultContinue(result);
170
199
  }));
171
200
  }
172
201
  }
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 });
202
+ FormDeactivateGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormDeactivateGuard, deps: [{ token: FsForm }, { token: i2$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Injectable });
174
203
  FormDeactivateGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormDeactivateGuard, providedIn: 'root' });
175
204
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormDeactivateGuard, decorators: [{
176
205
  type: Injectable,
177
206
  args: [{
178
207
  providedIn: 'root',
179
208
  }]
180
- }], ctorParameters: function () { return [{ type: i1.FsPrompt }, { type: FsForm }, { type: i3.ActivatedRoute }]; } });
209
+ }], ctorParameters: function () { return [{ type: FsForm }, { type: i2$1.ActivatedRoute }]; } });
181
210
 
182
211
  function getFormErrors(control, key) {
183
212
  let errors = null;
@@ -203,25 +232,12 @@ function getFormErrors(control, key) {
203
232
  return errors;
204
233
  }
205
234
 
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
235
  class FsFormDirective {
219
- constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _cdRef, _dialogRef, _drawerRef, _route) {
236
+ constructor(ngForm, _form, _element, _message, _ngZone, _cdRef, _dialogRef, _drawerRef, _route) {
220
237
  this.ngForm = ngForm;
221
238
  this._form = _form;
222
239
  this._element = _element;
223
240
  this._message = _message;
224
- this._prompt = _prompt;
225
241
  this._ngZone = _ngZone;
226
242
  this._cdRef = _cdRef;
227
243
  this._dialogRef = _dialogRef;
@@ -386,7 +402,7 @@ class FsFormDirective {
386
402
  triggerConfirm() {
387
403
  const submitted = this.submitting ? this.submitted.asObservable() : of({});
388
404
  return submitted
389
- .pipe(take(1), mergeMap(() => confirmUnsaved([this], this._prompt)));
405
+ .pipe(take(1), mergeMap(() => this._form.confirmUnsaved([this])));
390
406
  }
391
407
  enable() {
392
408
  this.ngForm.control.enable();
@@ -410,6 +426,14 @@ class FsFormDirective {
410
426
  .filter((item) => (button !== item)),
411
427
  ]);
412
428
  }
429
+ validate() {
430
+ Object.values(this.ngForm.controls)
431
+ .forEach((control) => {
432
+ control.markAsDirty();
433
+ control.markAsTouched();
434
+ control.updateValueAndValidity();
435
+ });
436
+ }
413
437
  _listenSubmit() {
414
438
  this.ngForm
415
439
  .ngSubmit
@@ -436,15 +460,7 @@ class FsFormDirective {
436
460
  }), tap((submittedEvent) => {
437
461
  this._completeSubmit(true, submittedEvent);
438
462
  }), takeUntil(this._destroy$))
439
- .subscribe(() => { });
440
- }
441
- validate() {
442
- Object.values(this.ngForm.controls)
443
- .forEach((control) => {
444
- control.markAsDirty();
445
- control.markAsTouched();
446
- control.updateValueAndValidity();
447
- });
463
+ .subscribe();
448
464
  }
449
465
  _listenFormStatus() {
450
466
  this._status$
@@ -639,21 +655,21 @@ class FsFormDirective {
639
655
  }
640
656
  _registerConfirmTabs() {
641
657
  if (this.tabGroup) {
642
- this.registerConfirmTabGroup(this.tabGroup);
658
+ this._registerConfirmTabGroup(this.tabGroup);
643
659
  }
644
- this.registerConfirmTabGroups(this._tabGroups.toArray());
660
+ this._registerConfirmTabGroups(this._tabGroups.toArray());
645
661
  this._tabGroups.changes
646
662
  .pipe(takeUntil(this._destroy$))
647
663
  .subscribe(() => {
648
- this.registerConfirmTabGroups(this._tabGroups.toArray());
664
+ this._registerConfirmTabGroups(this._tabGroups.toArray());
649
665
  });
650
666
  }
651
- registerConfirmTabGroups(tabGroups) {
667
+ _registerConfirmTabGroups(tabGroups) {
652
668
  tabGroups.forEach((tabGroup) => {
653
- this.registerConfirmTabGroup(tabGroup);
669
+ this._registerConfirmTabGroup(tabGroup);
654
670
  });
655
671
  }
656
- registerConfirmTabGroup(tabGroup) {
672
+ _registerConfirmTabGroup(tabGroup) {
657
673
  const confirmTabGroup = tabGroup;
658
674
  if (!confirmTabGroup._originalHandleClick) {
659
675
  confirmTabGroup._originalHandleClick = tabGroup._handleClick;
@@ -785,7 +801,7 @@ class FsFormDirective {
785
801
  if (!Array.isArray(this._activatedRouteConfig.canDeactivate)) {
786
802
  this._activatedRouteConfig.canDeactivate = [];
787
803
  }
788
- if (this._activatedRouteConfig.canDeactivate.indexOf(FormDeactivateGuard) == -1) {
804
+ if (this._activatedRouteConfig.canDeactivate.indexOf(FormDeactivateGuard) === -1) {
789
805
  this._activatedRouteConfig.canDeactivate.push(FormDeactivateGuard);
790
806
  }
791
807
  }
@@ -798,7 +814,7 @@ class FsFormDirective {
798
814
  this._form.removeFormDirective(this._activatedRouteConfig.component);
799
815
  }
800
816
  }
801
- FsFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDirective, deps: [{ token: NgForm }, { token: FsForm }, { token: i0.ElementRef }, { token: i2.FsMessage }, { token: i1.FsPrompt }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: MatDialogRef, optional: true }, { token: DrawerRef, optional: true }, { token: i3.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Directive });
817
+ 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$2.FsMessage }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: MatDialogRef, optional: true }, { token: DrawerRef, optional: true }, { token: i2$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Directive });
802
818
  FsFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDirective, selector: "[fsForm]", inputs: { wrapperSelector: "wrapperSelector", messageSelector: "messageSelector", hintSelector: "hintSelector", labelSelector: "labelSelector", autocomplete: "autocomplete", shortcuts: "shortcuts", confirm: "confirm", confirmDialog: "confirmDialog", confirmDrawer: "confirmDrawer", confirmBrowser: "confirmBrowser", confirmTabs: "confirmTabs", dirtySubmitButton: "dirtySubmitButton", submit: "submit", successDelay: "successDelay", errorDelay: "errorDelay", tabGroup: "tabGroup", deactivationGuard: "deactivationGuard" }, outputs: { submitEvent: "fsForm", invalid: "invalid", valid: "valid", submitted: "submitted", reseted: "reseted", cleared: "cleared" }, host: { properties: { "class.fs-form": "this.fsFormClass" } }, queries: [{ propertyName: "_tabGroups", predicate: MatTabGroup, descendants: true }], exportAs: ["fsForm"], usesOnChanges: true, ngImport: i0 });
803
819
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDirective, decorators: [{
804
820
  type: Directive,
@@ -806,20 +822,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
806
822
  selector: '[fsForm]',
807
823
  exportAs: 'fsForm',
808
824
  }]
809
- }], ctorParameters: function () { return [{ type: i1$1.NgForm, decorators: [{
825
+ }], ctorParameters: function () { return [{ type: i1$2.NgForm, decorators: [{
810
826
  type: Inject,
811
827
  args: [NgForm]
812
- }] }, { type: FsForm }, { type: i0.ElementRef }, { type: i2.FsMessage }, { type: i1.FsPrompt }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i2$1.MatDialogRef, decorators: [{
828
+ }] }, { type: FsForm }, { type: i0.ElementRef }, { type: i2$2.FsMessage }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i1.MatDialogRef, decorators: [{
813
829
  type: Optional
814
830
  }, {
815
831
  type: Inject,
816
832
  args: [MatDialogRef]
817
- }] }, { type: i7.DrawerRef, decorators: [{
833
+ }] }, { type: i6.DrawerRef, decorators: [{
818
834
  type: Optional
819
835
  }, {
820
836
  type: Inject,
821
837
  args: [DrawerRef]
822
- }] }, { type: i3.ActivatedRoute }]; }, propDecorators: { wrapperSelector: [{
838
+ }] }, { type: i2$1.ActivatedRoute }]; }, propDecorators: { wrapperSelector: [{
823
839
  type: Input
824
840
  }], messageSelector: [{
825
841
  type: Input
@@ -874,94 +890,435 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
874
890
  args: [MatTabGroup, { descendants: true }]
875
891
  }] } });
876
892
 
877
- const ERROR_MESSAGES = {
878
- required: 'This field is required',
879
- email: 'This is not a valid email address',
880
- emails: 'Input valid email addresses, comma separated',
881
- phone: 'Invalid phone number',
882
- numeric: 'Value should be numeric',
883
- integer: 'Value should be an integer',
884
- min: 'Value should not be less than $(1)',
885
- max: 'Value should not be greater than $(1)',
886
- minlength: 'Should not be shorter than $(1) characters',
887
- maxlength: 'Should not be longer than $(1) characters',
888
- compare: 'Inputs do not match',
889
- pattern: 'Value should match pattern $(1)',
890
- dateRange: 'Invalid date range',
891
- url: 'This is not a valid url',
892
- urlProtocol: 'Invalid URL. Proper http protocol is required. eg. https://google.com',
893
- greater: 'Value must be greater than $(1)',
894
- lesser: 'Value must be less than $(1)',
895
- };
896
-
897
- const VALIDATE_MESSAGES = new InjectionToken('fs.form.validate-messages');
898
- const VALIDATE_MESSAGE_PROVIDER = {
899
- provide: VALIDATE_MESSAGES,
900
- useFactory: messageProviderFactory,
901
- };
902
- function messageProviderFactory() {
903
- return { ...ERROR_MESSAGES };
904
- }
905
-
906
- class FsControlDirective {
907
- constructor(elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
908
- this.elementRef = elementRef;
909
- this.renderer2 = renderer2;
910
- this.injector = injector;
911
- this._validateMessages = _validateMessages;
912
- this.ngControl = ngControl;
913
- this.formDirective = formDirective;
914
- this.appendMessageClass = 'fs-form-message';
915
- this.appendLabelClass = 'fs-form-label';
916
- this.appendErrorClass = 'fs-form-error';
917
- this.appendHintClass = 'fs-form-hint';
918
- this.errors = [];
919
- // protected _validateMessages = { ...ERROR_MESSAGES };
893
+ class FsButtonDirective {
894
+ constructor(_matButton, _form, _elementRef, _cdRef) {
895
+ this._matButton = _matButton;
896
+ this._form = _form;
897
+ this._elementRef = _elementRef;
898
+ this._cdRef = _cdRef;
899
+ this.dirtySubmit = true;
900
+ this.transitionStyle = null;
901
+ this.active = false;
902
+ this.submit = false;
903
+ this._previousDisabled = false;
920
904
  this._destroy$ = new Subject();
921
- if (ngControl) {
922
- this._control = ngControl.control;
923
- }
924
- else {
925
- console.error('The element does not have a valid ngModel', this.elementRef.nativeElement);
926
- }
927
- }
928
- set validateMessages(messages) {
929
- this._validateMessages = {
930
- ...this._validateMessages,
931
- ...messages,
932
- };
933
905
  }
934
906
  ngOnInit() {
935
- this._setupValidators();
936
- }
937
- ngOnDestroy() {
938
- this._destroy$.next();
939
- this._destroy$.complete();
940
- }
941
- ngAfterContentInit() {
942
- this._subscribeToStatusChagnes();
943
- }
944
- _subscribeToStatusChagnes() {
945
- if (this._control) {
946
- this._control.statusChanges
947
- .pipe(takeUntil(this._destroy$))
948
- .subscribe(this.render.bind(this));
907
+ this.submit = this._elementRef.nativeElement.getAttribute('type') === 'submit';
908
+ this.form = this.form || this._form;
909
+ if (this.form) {
910
+ this.form.addButton(this);
911
+ if (this.submit) {
912
+ fromEvent(this.element, 'click')
913
+ .pipe(takeUntil(this._destroy$))
914
+ .subscribe(() => {
915
+ this.active = true;
916
+ });
917
+ if (this.dirtySubmit) {
918
+ if (this.form.dirtySubmitButton) {
919
+ if (!this.form.ngForm.dirty) {
920
+ this.disable();
921
+ }
922
+ }
923
+ }
924
+ this.transitionStyle = 'none';
925
+ setTimeout(() => {
926
+ this.transitionStyle = null;
927
+ }, 500);
928
+ }
949
929
  }
950
930
  }
951
- getMessageSelector() {
952
- if (this.messageSelector === false) {
953
- return '';
931
+ disable() {
932
+ if (this._matButton && !this.active) {
933
+ this._previousDisabled = this._matButton.disabled;
934
+ this._matButton.disabled = true;
935
+ this._cdRef.markForCheck();
954
936
  }
955
- if (this.messageSelector) {
956
- return this.messageSelector;
937
+ }
938
+ enable() {
939
+ if (this._matButton) {
940
+ this._matButton.disabled = false;
941
+ this._matButton.disableRipple = true;
942
+ this._cdRef.markForCheck();
957
943
  }
958
- else if (this.formDirective?.messageSelector) {
959
- return this.formDirective.messageSelector;
944
+ }
945
+ process() {
946
+ this.setClass('process');
947
+ if (this._matButton) {
948
+ this._matButton.disableRipple = true;
960
949
  }
961
950
  }
962
- getHintWrapperSelector() {
963
- if (this.hintSelector === false) {
964
- return '';
951
+ success() {
952
+ this.setClass('success');
953
+ if (this._matButton) {
954
+ this._matButton.disableRipple = false;
955
+ }
956
+ }
957
+ error() {
958
+ this.setClass('error');
959
+ if (this._matButton) {
960
+ this._matButton.disableRipple = false;
961
+ }
962
+ }
963
+ setClass(cls) {
964
+ const svg = this._getSvg(cls);
965
+ this._resetClass();
966
+ this._disableShadowAnimation();
967
+ this.element.classList.add(`submit-${cls}`);
968
+ this.element.append(svg);
969
+ }
970
+ get element() {
971
+ return this._elementRef.nativeElement;
972
+ }
973
+ resetActive() {
974
+ this.active = false;
975
+ }
976
+ reset() {
977
+ if (!this._previousDisabled) {
978
+ this.enable();
979
+ }
980
+ this.element.querySelectorAll('.svg-icon')
981
+ .forEach((el) => {
982
+ el.remove();
983
+ });
984
+ if (this._matButton) {
985
+ this._matButton.disableRipple = false;
986
+ }
987
+ this._resetClass();
988
+ }
989
+ ngOnDestroy() {
990
+ this._destroy$.next();
991
+ this._destroy$.complete();
992
+ this.form?.removeButton(this);
993
+ }
994
+ _disableShadowAnimation() {
995
+ // .mat-elevation-z2 removes the click shadow animation
996
+ //this.element.classList.add('mat-elevation-z2');
997
+ }
998
+ _resetClass() {
999
+ this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
1000
+ }
1001
+ _getSvg(type) {
1002
+ if (type === 'success') {
1003
+ 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">
1004
+ <g>
1005
+ <g class="check">
1006
+ <g>
1007
+ <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"/>
1008
+ </g>
1009
+ </g>
1010
+ </g>
1011
+ </svg>`, 'text/xml').firstChild;
1012
+ }
1013
+ if (type === 'process') {
1014
+ 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">
1015
+ <g fill="none" fill-rule="evenodd">
1016
+ <g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
1017
+ <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>
1018
+ </g>
1019
+ </g>
1020
+ </svg>`, 'text/xml').firstChild;
1021
+ }
1022
+ if (type === 'error') {
1023
+ 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;
1024
+ }
1025
+ }
1026
+ }
1027
+ FsButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsButtonDirective, deps: [{ token: i1$1.MatButton, host: true, optional: true }, { token: FsFormDirective, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1028
+ FsButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsButtonDirective, selector: "[mat-raised-button]:not([fsFormButtonStandalone]),[mat-button]:not([fsFormButtonStandalone]),[mat-flat-button]:not([fsFormButtonStandalone]),[mat-stroked-button]:not([fsFormButtonStandalone])", inputs: { name: "name", dirtySubmit: "dirtySubmit", form: "form" }, host: { properties: { "style.transition": "this.transitionStyle" } }, ngImport: i0 });
1029
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsButtonDirective, decorators: [{
1030
+ type: Directive,
1031
+ args: [{
1032
+ selector: '[mat-raised-button]:not([fsFormButtonStandalone]),[mat-button]:not([fsFormButtonStandalone]),[mat-flat-button]:not([fsFormButtonStandalone]),[mat-stroked-button]:not([fsFormButtonStandalone])',
1033
+ }]
1034
+ }], ctorParameters: function () { return [{ type: i1$1.MatButton, decorators: [{
1035
+ type: Optional
1036
+ }, {
1037
+ type: Host
1038
+ }] }, { type: FsFormDirective, decorators: [{
1039
+ type: Optional
1040
+ }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
1041
+ type: Input
1042
+ }], dirtySubmit: [{
1043
+ type: Input
1044
+ }], form: [{
1045
+ type: Input
1046
+ }], transitionStyle: [{
1047
+ type: HostBinding,
1048
+ args: ['style.transition']
1049
+ }] } });
1050
+
1051
+ class FsFormDialogCloseDirective {
1052
+ constructor(_form, _dialogRef) {
1053
+ this._form = _form;
1054
+ this._dialogRef = _dialogRef;
1055
+ this.type = 'button';
1056
+ this._destroy$ = new Subject();
1057
+ }
1058
+ closeClick() {
1059
+ if (this._form) {
1060
+ this._form.triggerConfirm()
1061
+ .pipe(filter((confirmResult) => (confirmResult !== ConfirmResult.Review)), takeUntil(this._destroy$))
1062
+ .subscribe(() => {
1063
+ this._dialogRef.close(this.closeData);
1064
+ });
1065
+ }
1066
+ else {
1067
+ this._dialogRef.close(this.closeData);
1068
+ }
1069
+ }
1070
+ ngOnDestroy() {
1071
+ this._destroy$.next();
1072
+ this._destroy$.complete();
1073
+ }
1074
+ }
1075
+ FsFormDialogCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogCloseDirective, deps: [{ token: FsFormDirective, optional: true }, { token: i1.MatDialogRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1076
+ 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 });
1077
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
1078
+ type: Directive,
1079
+ args: [{
1080
+ selector: '[fsFormDialogClose],[fs-form-dialog-close]',
1081
+ }]
1082
+ }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
1083
+ type: Optional
1084
+ }] }, { type: i1.MatDialogRef, decorators: [{
1085
+ type: Optional
1086
+ }] }]; }, propDecorators: { closeData: [{
1087
+ type: Input
1088
+ }], type: [{
1089
+ type: HostBinding,
1090
+ args: ['attr.type']
1091
+ }], closeClick: [{
1092
+ type: HostListener,
1093
+ args: ['click', ['$event.target']]
1094
+ }] } });
1095
+
1096
+ class FsFormDialogActionsComponent {
1097
+ constructor(_form, _dialogRef, _cdRef) {
1098
+ this._form = _form;
1099
+ this._dialogRef = _dialogRef;
1100
+ this._cdRef = _cdRef;
1101
+ this.save = true;
1102
+ this.create = false;
1103
+ this.close = false;
1104
+ this.done = false;
1105
+ this.closeData = null;
1106
+ this.dirty = false;
1107
+ this._destroy$ = new Subject();
1108
+ }
1109
+ ngOnInit() {
1110
+ if (this._form) {
1111
+ this._form.ngForm.valueChanges
1112
+ .pipe(filter(() => (!this.dirty)), takeUntil(this._destroy$))
1113
+ .subscribe(() => {
1114
+ this.dirty = this._form.ngForm.dirty;
1115
+ this._cdRef.markForCheck();
1116
+ });
1117
+ this._form.submitted
1118
+ .pipe(delay(50), takeUntil(this._destroy$))
1119
+ .subscribe(() => {
1120
+ this.dirty = false;
1121
+ this._cdRef.markForCheck();
1122
+ });
1123
+ this._form.reseted
1124
+ .pipe(takeUntil(this._destroy$))
1125
+ .subscribe(() => {
1126
+ this.dirty = false;
1127
+ this._cdRef.markForCheck();
1128
+ });
1129
+ }
1130
+ }
1131
+ ngOnDestroy() {
1132
+ this._destroy$.next();
1133
+ this._destroy$.complete();
1134
+ }
1135
+ }
1136
+ FsFormDialogActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, deps: [{ token: FsFormDirective, optional: true }, { token: i1.MatDialogRef, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1137
+ 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 cancel-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$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FsButtonDirective, selector: "[mat-raised-button]:not([fsFormButtonStandalone]),[mat-button]:not([fsFormButtonStandalone]),[mat-flat-button]:not([fsFormButtonStandalone]),[mat-stroked-button]:not([fsFormButtonStandalone])", inputs: ["name", "dirtySubmit", "form"] }, { type: i1.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 });
1138
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
1139
+ type: Component,
1140
+ 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 cancel-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"] }]
1141
+ }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
1142
+ type: Optional
1143
+ }] }, { type: i1.MatDialogRef, decorators: [{
1144
+ type: Optional
1145
+ }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { save: [{
1146
+ type: Input
1147
+ }], create: [{
1148
+ type: Input
1149
+ }], close: [{
1150
+ type: Input
1151
+ }], done: [{
1152
+ type: Input
1153
+ }], closeData: [{
1154
+ type: Input
1155
+ }], name: [{
1156
+ type: Input
1157
+ }] } });
1158
+
1159
+ class FsFormTemplateComponent {
1160
+ constructor() { }
1161
+ ngAfterContentInit() {
1162
+ debugger;
1163
+ const x = this.models;
1164
+ this.models.changes.subscribe((x) => {
1165
+ debugger;
1166
+ });
1167
+ }
1168
+ ngOnInit() {
1169
+ debugger;
1170
+ }
1171
+ }
1172
+ FsFormTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1173
+ 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 });
1174
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, decorators: [{
1175
+ type: Component,
1176
+ args: [{ selector: 'fs-form-template', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #templateRef1>\n <ng-content></ng-content>\n</ng-template>" }]
1177
+ }], ctorParameters: function () { return []; }, propDecorators: { templateRef: [{
1178
+ type: ViewChild,
1179
+ args: ['templateRef1']
1180
+ }], formTemplate: [{
1181
+ type: Input
1182
+ }], models: [{
1183
+ type: ContentChildren,
1184
+ args: [NgModel, { descendants: true }]
1185
+ }] } });
1186
+
1187
+ class FsFormTemplateOutletComponent {
1188
+ constructor() { }
1189
+ ngOnChanges(changes) {
1190
+ if (changes.formTemplate?.currentValue) {
1191
+ }
1192
+ }
1193
+ ngAfterContentInit() {
1194
+ // const x = this.models;
1195
+ // this.models.changes.subscribe((x) => {
1196
+ // debugger;
1197
+ // });
1198
+ }
1199
+ }
1200
+ FsFormTemplateOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1201
+ 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 });
1202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, decorators: [{
1203
+ type: Component,
1204
+ 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>" }]
1205
+ }], ctorParameters: function () { return []; }, propDecorators: { formTemplate: [{
1206
+ type: Input
1207
+ }], models: [{
1208
+ type: ContentChildren,
1209
+ args: [NgModel, { descendants: true }]
1210
+ }] } });
1211
+
1212
+ class FsFormTemplateDirective {
1213
+ constructor() { }
1214
+ ngAfterContentInit() {
1215
+ }
1216
+ }
1217
+ FsFormTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1218
+ 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 });
1219
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateDirective, decorators: [{
1220
+ type: Directive,
1221
+ args: [{
1222
+ selector: '[fsFormTemplate]',
1223
+ }]
1224
+ }], ctorParameters: function () { return []; }, propDecorators: { models: [{
1225
+ type: ViewChildren,
1226
+ args: [NgModel]
1227
+ }] } });
1228
+
1229
+ class FsSubmitButtonDirective extends FsButtonDirective {
1230
+ }
1231
+ FsSubmitButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsSubmitButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1232
+ FsSubmitButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsSubmitButtonDirective, selector: "dummy-selector", usesInheritance: true, ngImport: i0 });
1233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsSubmitButtonDirective, decorators: [{
1234
+ type: Directive,
1235
+ args: [{
1236
+ selector: 'dummy-selector',
1237
+ }]
1238
+ }] });
1239
+
1240
+ const ERROR_MESSAGES = {
1241
+ required: 'This field is required',
1242
+ email: 'This is not a valid email address',
1243
+ emails: 'Input valid email addresses, comma separated',
1244
+ phone: 'Invalid phone number',
1245
+ numeric: 'Value should be numeric',
1246
+ integer: 'Value should be an integer',
1247
+ min: 'Value should not be less than $(1)',
1248
+ max: 'Value should not be greater than $(1)',
1249
+ minlength: 'Should not be shorter than $(1) characters',
1250
+ maxlength: 'Should not be longer than $(1) characters',
1251
+ compare: 'Inputs do not match',
1252
+ pattern: 'Value should match pattern $(1)',
1253
+ dateRange: 'Invalid date range',
1254
+ url: 'This is not a valid url',
1255
+ urlProtocol: 'Invalid URL. Proper http protocol is required. eg. https://google.com',
1256
+ greater: 'Value must be greater than $(1)',
1257
+ lesser: 'Value must be less than $(1)',
1258
+ greaterEqual: 'Value must be greater than or equal $(1)',
1259
+ lesserEqual: 'Value must be less than or equal $(1)',
1260
+ };
1261
+
1262
+ const VALIDATE_MESSAGES = new InjectionToken('fs.form.validate-messages');
1263
+ const VALIDATE_MESSAGE_PROVIDER = {
1264
+ provide: VALIDATE_MESSAGES,
1265
+ useFactory: messageProviderFactory,
1266
+ };
1267
+ function messageProviderFactory() {
1268
+ return { ...ERROR_MESSAGES };
1269
+ }
1270
+
1271
+ class FsControlDirective {
1272
+ constructor(_elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
1273
+ this._elementRef = _elementRef;
1274
+ this.renderer2 = renderer2;
1275
+ this.injector = injector;
1276
+ this._validateMessages = _validateMessages;
1277
+ this.ngControl = ngControl;
1278
+ this.formDirective = formDirective;
1279
+ this.appendMessageClass = 'fs-form-message';
1280
+ this.appendLabelClass = 'fs-form-label';
1281
+ this.appendErrorClass = 'fs-form-error';
1282
+ this.appendHintClass = 'fs-form-hint';
1283
+ this.errors = [];
1284
+ this._destroy$ = new Subject();
1285
+ if (ngControl) {
1286
+ this._control = ngControl.control;
1287
+ }
1288
+ else {
1289
+ console.error('The element does not have a valid ngModel', this._elementRef.nativeElement);
1290
+ }
1291
+ }
1292
+ set validateMessages(messages) {
1293
+ this._validateMessages = {
1294
+ ...this._validateMessages,
1295
+ ...messages,
1296
+ };
1297
+ }
1298
+ ngOnInit() {
1299
+ this._setupValidators();
1300
+ }
1301
+ ngOnDestroy() {
1302
+ this._destroy$.next();
1303
+ this._destroy$.complete();
1304
+ }
1305
+ ngAfterContentInit() {
1306
+ this._subscribeToStatusChagnes();
1307
+ }
1308
+ getMessageSelector() {
1309
+ if (this.messageSelector === false) {
1310
+ return '';
1311
+ }
1312
+ if (this.messageSelector) {
1313
+ return this.messageSelector;
1314
+ }
1315
+ else if (this.formDirective?.messageSelector) {
1316
+ return this.formDirective.messageSelector;
1317
+ }
1318
+ }
1319
+ getHintWrapperSelector() {
1320
+ if (this.hintSelector === false) {
1321
+ return '';
965
1322
  }
966
1323
  if (this.hintSelector) {
967
1324
  return this.hintSelector;
@@ -993,11 +1350,11 @@ class FsControlDirective {
993
1350
  }
994
1351
  }
995
1352
  getWrapperElement() {
996
- const wrapper = this.getWrapper(this.elementRef.nativeElement);
1353
+ const wrapper = this.getWrapper(this._elementRef.nativeElement);
997
1354
  if (wrapper) {
998
1355
  return wrapper;
999
1356
  }
1000
- return this.elementRef.nativeElement;
1357
+ return this._elementRef.nativeElement;
1001
1358
  }
1002
1359
  /*
1003
1360
  <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.
@@ -1026,7 +1383,7 @@ class FsControlDirective {
1026
1383
  }
1027
1384
  const messageWrapper = wrapper.querySelector(this.getMessageSelector());
1028
1385
  if (!messageWrapper) {
1029
- return console.warn('Failed to locate ' + this.getMessageSelector(), this.elementRef.nativeElement);
1386
+ return console.warn(`Failed to locate ${this.getMessageSelector()}`, this._elementRef.nativeElement);
1030
1387
  }
1031
1388
  if (this.getlabelSelector()) {
1032
1389
  const labelWrapper = wrapper.querySelector(this.getlabelSelector());
@@ -1058,12 +1415,19 @@ class FsControlDirective {
1058
1415
  errorWrapper = renderer.createElement('div');
1059
1416
  renderer.addClass(errorWrapper, 'fs-form-error-target');
1060
1417
  renderer.addClass(errorWrapper, this.appendErrorClass);
1061
- renderer.addClass(errorWrapper, this.appendErrorClass + '-' + error.name);
1418
+ renderer.addClass(errorWrapper, `${this.appendErrorClass}-${error.name}`);
1062
1419
  const errorText = renderer.createText(error.message);
1063
1420
  renderer.appendChild(errorWrapper, errorText);
1064
1421
  messageWrapper.appendChild(errorWrapper);
1065
1422
  }
1066
1423
  }
1424
+ _subscribeToStatusChagnes() {
1425
+ if (this._control) {
1426
+ this._control.statusChanges
1427
+ .pipe(takeUntil(this._destroy$))
1428
+ .subscribe(this.render.bind(this));
1429
+ }
1430
+ }
1067
1431
  getWrapper(node, count = 0) {
1068
1432
  if (!node || count > 10) {
1069
1433
  return null;
@@ -1108,16 +1472,16 @@ class FsControlDirective {
1108
1472
  control.updateValueAndValidity();
1109
1473
  }
1110
1474
  }
1111
- FsControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsControlDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.Injector }, { token: VALIDATE_MESSAGES, self: true }, { token: i1$1.NgControl, optional: true }, { token: FsFormDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1475
+ 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$2.NgControl, optional: true }, { token: FsFormDirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1112
1476
  FsControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsControlDirective, selector: "[fsFormControl]", inputs: { wrapperSelector: "wrapperSelector", messageSelector: "messageSelector", hintSelector: "hintSelector", labelSelector: "labelSelector", appendMessageClass: "appendMessageClass", appendLabelClass: "appendLabelClass", appendErrorClass: "appendErrorClass", appendHintClass: "appendHintClass", validateMessages: "validateMessages" }, providers: [
1113
- VALIDATE_MESSAGE_PROVIDER
1477
+ VALIDATE_MESSAGE_PROVIDER,
1114
1478
  ], ngImport: i0 });
1115
1479
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsControlDirective, decorators: [{
1116
1480
  type: Directive,
1117
1481
  args: [{
1118
1482
  selector: '[fsFormControl]',
1119
1483
  providers: [
1120
- VALIDATE_MESSAGE_PROVIDER
1484
+ VALIDATE_MESSAGE_PROVIDER,
1121
1485
  ],
1122
1486
  }]
1123
1487
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.Injector }, { type: undefined, decorators: [{
@@ -1125,7 +1489,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1125
1489
  }, {
1126
1490
  type: Inject,
1127
1491
  args: [VALIDATE_MESSAGES]
1128
- }] }, { type: i1$1.NgControl, decorators: [{
1492
+ }] }, { type: i1$2.NgControl, decorators: [{
1129
1493
  type: Optional
1130
1494
  }] }, { type: FsFormDirective, decorators: [{
1131
1495
  type: Optional
@@ -1152,73 +1516,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1152
1516
  type: Input
1153
1517
  }] } });
1154
1518
 
1155
- function isEnabled(value) {
1156
- return value !== 'false' && (value || value === '');
1157
- }
1158
-
1159
- class FsFormRequiredDirective extends FsControlDirective {
1160
- constructor() {
1161
- super(...arguments);
1162
- this.required = false;
1163
- }
1164
- set setFsFormRequired(value) {
1165
- this.required = isEnabled(value);
1166
- }
1167
- set setRequired(value) {
1168
- this.required = isEnabled(value);
1169
- }
1519
+ class FsFormCompareDirective extends FsControlDirective {
1170
1520
  set validationMessage(value) {
1171
- this._validateMessages.required = value;
1521
+ this._validateMessages.compare = value;
1172
1522
  }
1173
1523
  ngOnChanges() {
1174
1524
  this._control.updateValueAndValidity();
1175
1525
  }
1176
1526
  validate(control) {
1177
- if (this.required) {
1178
- return Validators.required(this._control);
1179
- }
1180
- else {
1527
+ if (this.fsFormCompare.value === this._elementRef.nativeElement.value) {
1181
1528
  return null;
1182
1529
  }
1530
+ return { compare: true };
1183
1531
  }
1184
- render() {
1185
- const wrapper = this.getWrapperElement();
1186
- if (wrapper && this.getlabelSelector()) {
1187
- const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1188
- // Adding class fs-form-label-requried adds the * to the label
1189
- if (labelWrapper) {
1190
- if (this.required) {
1191
- this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
1192
- }
1193
- else {
1194
- this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
1195
- }
1196
- }
1197
- }
1198
- super.render();
1532
+ ngAfterViewInit() {
1533
+ this.fsFormCompare.addEventListener('keyup', () => {
1534
+ this._control.updateValueAndValidity();
1535
+ }, false);
1536
+ }
1537
+ ngOnDestroy() {
1538
+ this.fsFormCompare.removeEventListener('keyup', () => {
1539
+ this._control.updateValueAndValidity();
1540
+ }, false);
1199
1541
  }
1200
1542
  }
1201
- FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1202
- FsFormRequiredDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormRequiredDirective, selector: "[fsFormRequired],[ngModel][required]", inputs: { setFsFormRequired: ["fsFormRequired", "setFsFormRequired"], setRequired: ["required", "setRequired"], validationMessage: ["fsFormRequiredMessage", "validationMessage"] }, providers: [
1203
- VALIDATE_MESSAGE_PROVIDER
1543
+ FsFormCompareDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormCompareDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1544
+ FsFormCompareDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormCompareDirective, selector: "[fsFormCompare]", inputs: { fsFormCompare: "fsFormCompare", validationMessage: ["fsFormCompareMessage", "validationMessage"] }, providers: [
1545
+ VALIDATE_MESSAGE_PROVIDER,
1204
1546
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
1547
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormCompareDirective, decorators: [{
1206
1548
  type: Directive,
1207
1549
  args: [{
1208
- selector: '[fsFormRequired],[ngModel][required]',
1550
+ selector: '[fsFormCompare]',
1209
1551
  providers: [
1210
- VALIDATE_MESSAGE_PROVIDER
1552
+ VALIDATE_MESSAGE_PROVIDER,
1211
1553
  ],
1212
1554
  }]
1213
- }], propDecorators: { setFsFormRequired: [{
1214
- type: Input,
1215
- args: ['fsFormRequired']
1216
- }], setRequired: [{
1217
- type: Input,
1218
- args: ['required']
1555
+ }], propDecorators: { fsFormCompare: [{
1556
+ type: Input
1219
1557
  }], validationMessage: [{
1220
1558
  type: Input,
1221
- args: ['fsFormRequiredMessage']
1559
+ args: ['fsFormCompareMessage']
1222
1560
  }] } });
1223
1561
 
1224
1562
  class FsValidators {
@@ -1313,758 +1651,694 @@ class FsValidators {
1313
1651
  }
1314
1652
  }
1315
1653
 
1316
- class FsFormMinDirective extends FsControlDirective {
1654
+ function isEnabled(value) {
1655
+ return value !== 'false' && (value || value === '');
1656
+ }
1657
+
1658
+ class FsFormDateRangeDirective extends FsControlDirective {
1317
1659
  set validationMessage(value) {
1318
- this._validateMessages.min = value;
1660
+ this._validateMessages.dateRange = value;
1319
1661
  }
1320
1662
  ngOnChanges() {
1321
1663
  this._control.updateValueAndValidity();
1322
1664
  }
1323
1665
  validate(control) {
1324
- return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
1666
+ if (isEnabled(this.fsFormDateRange)) {
1667
+ return FsValidators.dateRange(this._control);
1668
+ }
1669
+ else {
1670
+ return null;
1671
+ }
1325
1672
  }
1326
1673
  }
1327
- FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1328
- FsFormMinDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
1674
+ FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1675
+ FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "validationMessage"] }, providers: [
1329
1676
  VALIDATE_MESSAGE_PROVIDER
1330
1677
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1331
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, decorators: [{
1678
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1332
1679
  type: Directive,
1333
1680
  args: [{
1334
- selector: '[fsFormMin]',
1681
+ selector: '[fsFormDateRange]',
1335
1682
  providers: [
1336
1683
  VALIDATE_MESSAGE_PROVIDER
1337
1684
  ],
1338
1685
  }]
1339
- }], propDecorators: { fsFormMin: [{
1686
+ }], propDecorators: { fsFormDateRange: [{
1340
1687
  type: Input
1341
1688
  }], validationMessage: [{
1342
1689
  type: Input,
1343
- args: ['fsFormMinMessage']
1690
+ args: ['fsFormDateRangeMessage']
1344
1691
  }] } });
1345
1692
 
1346
- class FsFormMaxDirective extends FsControlDirective {
1693
+ class FsFormEmailDirective extends FsControlDirective {
1347
1694
  set validationMessage(value) {
1348
- this._validateMessages.max = value;
1695
+ this._validateMessages.email = value;
1349
1696
  }
1350
1697
  ngOnChanges() {
1351
1698
  this._control.updateValueAndValidity();
1352
1699
  }
1353
1700
  validate(control) {
1354
- return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1701
+ if (isEnabled(this.fsFormEmail)) {
1702
+ return FsValidators.email(this._control);
1703
+ }
1704
+ else {
1705
+ return null;
1706
+ }
1355
1707
  }
1356
1708
  }
1357
- FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1358
- FsFormMaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
1709
+ FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1710
+ FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
1359
1711
  VALIDATE_MESSAGE_PROVIDER
1360
1712
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1361
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, decorators: [{
1713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1362
1714
  type: Directive,
1363
1715
  args: [{
1364
- selector: '[fsFormMax]',
1716
+ selector: '[fsFormEmail]',
1365
1717
  providers: [
1366
1718
  VALIDATE_MESSAGE_PROVIDER
1367
1719
  ],
1368
1720
  }]
1369
- }], propDecorators: { fsFormMax: [{
1721
+ }], propDecorators: { fsFormEmail: [{
1370
1722
  type: Input
1371
1723
  }], validationMessage: [{
1372
1724
  type: Input,
1373
- args: ['fsFormMaxMessage']
1725
+ args: ['fsFormEmailMessage']
1374
1726
  }] } });
1375
1727
 
1376
- class FsFormMinLengthDirective extends FsControlDirective {
1728
+ class FsFormEmailsDirective extends FsControlDirective {
1377
1729
  set validationMessage(value) {
1378
- this._validateMessages.minlength = value;
1730
+ this._validateMessages.emails = value;
1379
1731
  }
1380
1732
  ngOnChanges() {
1381
1733
  this._control.updateValueAndValidity();
1382
1734
  }
1383
1735
  validate(control) {
1384
- return Validators.minLength(this.fsFormMinLength)(this._control);
1736
+ if (isEnabled(this.fsFormEmails)) {
1737
+ return FsValidators.emails(this._control);
1738
+ }
1739
+ else {
1740
+ return null;
1741
+ }
1385
1742
  }
1386
1743
  }
1387
- FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1388
- FsFormMinLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
1744
+ FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1745
+ FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
1389
1746
  VALIDATE_MESSAGE_PROVIDER
1390
1747
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1391
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
1748
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1392
1749
  type: Directive,
1393
1750
  args: [{
1394
- selector: '[fsFormMinLength]',
1751
+ selector: '[fsFormEmails]',
1395
1752
  providers: [
1396
1753
  VALIDATE_MESSAGE_PROVIDER
1397
1754
  ],
1398
1755
  }]
1399
- }], propDecorators: { fsFormMinLength: [{
1756
+ }], propDecorators: { fsFormEmails: [{
1400
1757
  type: Input
1401
1758
  }], validationMessage: [{
1402
1759
  type: Input,
1403
- args: ['fsFormMinLengthMessage']
1760
+ args: ['fsFormEmailsMessage']
1404
1761
  }] } });
1405
1762
 
1406
- class FsFormMaxLengthDirective extends FsControlDirective {
1763
+ class FsFormFunctionDirective extends FsControlDirective {
1764
+ constructor() {
1765
+ super(...arguments);
1766
+ this.validateOnSubmit = false;
1767
+ }
1768
+ ngOnChanges() {
1769
+ this._control.updateValueAndValidity();
1770
+ }
1771
+ validateAsync(control) {
1772
+ if (this.validateOnSubmit && !this.formDirective.validating) {
1773
+ return of(null);
1774
+ }
1775
+ return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
1776
+ }
1777
+ }
1778
+ FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1779
+ FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
1780
+ VALIDATE_MESSAGE_PROVIDER,
1781
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1782
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
1783
+ type: Directive,
1784
+ args: [{
1785
+ selector: '[fsFormFunction]',
1786
+ providers: [
1787
+ VALIDATE_MESSAGE_PROVIDER,
1788
+ ],
1789
+ }]
1790
+ }], propDecorators: { fsFormFunction: [{
1791
+ type: Input
1792
+ }], fsFormFunctionData: [{
1793
+ type: Input
1794
+ }], validateOnSubmit: [{
1795
+ type: Input
1796
+ }] } });
1797
+
1798
+ class FsFormGreaterEqualDirective extends FsControlDirective {
1407
1799
  set validationMessage(value) {
1408
- this._validateMessages.maxlength = value;
1800
+ this._validateMessages.greater = value;
1409
1801
  }
1410
1802
  ngOnChanges() {
1411
1803
  this._control.updateValueAndValidity();
1412
1804
  }
1413
1805
  validate(control) {
1414
- return Validators.maxLength(this.fsFormMaxLength)(this._control);
1806
+ const greater = parseFloat(this.fsFormGreaterEqual);
1807
+ const value = parseFloat(this._control.value);
1808
+ if (!isNaN(greater) && !isNaN(value) && value < greater) {
1809
+ return { greaterEqual: { greater, actual: value } };
1810
+ }
1811
+ return FsValidators.numeric(this._control);
1415
1812
  }
1416
1813
  }
1417
- FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1418
- FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
1814
+ FsFormGreaterEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1815
+ FsFormGreaterEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterEqualDirective, selector: "[fsFormGreaterEqual]", inputs: { fsFormGreaterEqual: "fsFormGreaterEqual", validationMessage: ["fsFormGreaterEqualMessage", "validationMessage"] }, providers: [
1419
1816
  VALIDATE_MESSAGE_PROVIDER
1420
1817
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1421
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
1818
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, decorators: [{
1422
1819
  type: Directive,
1423
1820
  args: [{
1424
- selector: '[fsFormMaxLength]',
1821
+ selector: '[fsFormGreaterEqual]',
1425
1822
  providers: [
1426
1823
  VALIDATE_MESSAGE_PROVIDER
1427
1824
  ],
1428
1825
  }]
1429
- }], propDecorators: { fsFormMaxLength: [{
1826
+ }], propDecorators: { fsFormGreaterEqual: [{
1430
1827
  type: Input
1431
1828
  }], validationMessage: [{
1432
1829
  type: Input,
1433
- args: ['fsFormMaxLengthMessage']
1830
+ args: ['fsFormGreaterEqualMessage']
1434
1831
  }] } });
1435
1832
 
1436
- class FsFormEmailDirective extends FsControlDirective {
1833
+ class FsFormGreaterDirective extends FsControlDirective {
1437
1834
  set validationMessage(value) {
1438
- this._validateMessages.email = value;
1835
+ this._validateMessages.greater = value;
1439
1836
  }
1440
1837
  ngOnChanges() {
1441
1838
  this._control.updateValueAndValidity();
1442
1839
  }
1443
1840
  validate(control) {
1444
- if (isEnabled(this.fsFormEmail)) {
1445
- return FsValidators.email(this._control);
1446
- }
1447
- else {
1448
- return null;
1841
+ const greater = parseFloat(this.fsFormGreater);
1842
+ const value = parseFloat(this._control.value);
1843
+ if (!isNaN(greater) && !isNaN(value) && value <= greater) {
1844
+ return { greater: { greater, actual: value } };
1449
1845
  }
1846
+ return FsValidators.numeric(this._control);
1450
1847
  }
1451
1848
  }
1452
- FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1453
- FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
1849
+ FsFormGreaterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1850
+ FsFormGreaterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterDirective, selector: "[fsFormGreater]", inputs: { fsFormGreater: "fsFormGreater", validationMessage: ["fsFormGreaterMessage", "validationMessage"] }, providers: [
1454
1851
  VALIDATE_MESSAGE_PROVIDER
1455
1852
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1456
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
1457
1854
  type: Directive,
1458
1855
  args: [{
1459
- selector: '[fsFormEmail]',
1856
+ selector: '[fsFormGreater]',
1460
1857
  providers: [
1461
1858
  VALIDATE_MESSAGE_PROVIDER
1462
1859
  ],
1463
1860
  }]
1464
- }], propDecorators: { fsFormEmail: [{
1861
+ }], propDecorators: { fsFormGreater: [{
1465
1862
  type: Input
1466
1863
  }], validationMessage: [{
1467
1864
  type: Input,
1468
- args: ['fsFormEmailMessage']
1865
+ args: ['fsFormGreaterMessage']
1469
1866
  }] } });
1470
1867
 
1471
- class FsFormEmailsDirective extends FsControlDirective {
1868
+ class FsFormIntegerDirective extends FsControlDirective {
1472
1869
  set validationMessage(value) {
1473
- this._validateMessages.emails = value;
1870
+ this._validateMessages.integer = value;
1474
1871
  }
1475
1872
  ngOnChanges() {
1476
1873
  this._control.updateValueAndValidity();
1477
1874
  }
1478
1875
  validate(control) {
1479
- if (isEnabled(this.fsFormEmails)) {
1480
- return FsValidators.emails(this._control);
1481
- }
1482
- else {
1483
- return null;
1876
+ if (isEnabled(this.fsFormInteger)) {
1877
+ return FsValidators.integer(this._control);
1484
1878
  }
1879
+ return null;
1485
1880
  }
1486
1881
  }
1487
- FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1488
- FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
1489
- VALIDATE_MESSAGE_PROVIDER
1882
+ FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1883
+ FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "validationMessage"] }, providers: [
1884
+ VALIDATE_MESSAGE_PROVIDER,
1490
1885
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1491
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1886
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1492
1887
  type: Directive,
1493
1888
  args: [{
1494
- selector: '[fsFormEmails]',
1889
+ selector: '[fsFormInteger]',
1495
1890
  providers: [
1496
- VALIDATE_MESSAGE_PROVIDER
1891
+ VALIDATE_MESSAGE_PROVIDER,
1497
1892
  ],
1498
1893
  }]
1499
- }], propDecorators: { fsFormEmails: [{
1894
+ }], propDecorators: { fsFormInteger: [{
1500
1895
  type: Input
1501
1896
  }], validationMessage: [{
1502
1897
  type: Input,
1503
- args: ['fsFormEmailsMessage']
1898
+ args: ['fsFormIntegerMessage']
1504
1899
  }] } });
1505
1900
 
1506
- class FsFormPhoneDirective extends FsControlDirective {
1901
+ class FsFormLesserEqualDirective extends FsControlDirective {
1507
1902
  set validationMessage(value) {
1508
- this._validateMessages.phone = value;
1903
+ this._validateMessages.lesser = value;
1509
1904
  }
1510
1905
  ngOnChanges() {
1511
1906
  this._control.updateValueAndValidity();
1512
1907
  }
1513
1908
  validate(control) {
1514
- if (isEnabled(this.fsFormPhone)) {
1515
- return FsValidators.phone(this._control);
1516
- }
1517
- else {
1518
- return null;
1909
+ const lesser = parseFloat(this.fsFormLesserEqual);
1910
+ const value = parseFloat(this._control.value);
1911
+ if (!isNaN(lesser) && !isNaN(value) && value > lesser) {
1912
+ return { lesserEqual: { lesser, actual: value } };
1519
1913
  }
1914
+ return FsValidators.numeric(this._control);
1520
1915
  }
1521
1916
  }
1522
- FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1523
- FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
1917
+ FsFormLesserEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1918
+ FsFormLesserEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserEqualDirective, selector: "[fsFormLesserEqual]", inputs: { fsFormLesserEqual: "fsFormLesserEqual", validationMessage: ["fsFormLesserEqualMessage", "validationMessage"] }, providers: [
1524
1919
  VALIDATE_MESSAGE_PROVIDER
1525
1920
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1526
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
1921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, decorators: [{
1527
1922
  type: Directive,
1528
1923
  args: [{
1529
- selector: '[fsFormPhone]',
1924
+ selector: '[fsFormLesserEqual]',
1530
1925
  providers: [
1531
1926
  VALIDATE_MESSAGE_PROVIDER
1532
1927
  ],
1533
1928
  }]
1534
- }], propDecorators: { fsFormPhone: [{
1929
+ }], propDecorators: { fsFormLesserEqual: [{
1535
1930
  type: Input
1536
1931
  }], validationMessage: [{
1537
1932
  type: Input,
1538
- args: ['fsFormPhoneMessage']
1933
+ args: ['fsFormLesserEqualMessage']
1539
1934
  }] } });
1540
1935
 
1541
- class FsFormCompareDirective extends FsControlDirective {
1936
+ class FsFormLesserDirective extends FsControlDirective {
1542
1937
  set validationMessage(value) {
1543
- this._validateMessages.compare = value;
1938
+ this._validateMessages.lesser = value;
1544
1939
  }
1545
1940
  ngOnChanges() {
1546
1941
  this._control.updateValueAndValidity();
1547
1942
  }
1548
1943
  validate(control) {
1549
- if (this.fsFormCompare.value === this.elementRef.nativeElement.value) {
1550
- return null;
1551
- }
1552
- else {
1553
- return { compare: true };
1944
+ const lesser = parseFloat(this.fsFormLesser);
1945
+ const value = parseFloat(this._control.value);
1946
+ if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1947
+ return { lesser: { lesser, actual: value } };
1554
1948
  }
1555
- }
1556
- ngAfterViewInit() {
1557
- this.fsFormCompare.addEventListener('keyup', () => {
1558
- this._control.updateValueAndValidity();
1559
- }, false);
1560
- }
1561
- ngOnDestroy() {
1562
- this.fsFormCompare.removeEventListener('keyup', () => {
1563
- this._control.updateValueAndValidity();
1564
- }, false);
1949
+ return FsValidators.numeric(this._control);
1565
1950
  }
1566
1951
  }
1567
- FsFormCompareDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormCompareDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1568
- FsFormCompareDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormCompareDirective, selector: "[fsFormCompare]", inputs: { fsFormCompare: "fsFormCompare", validationMessage: ["fsFormCompareMessage", "validationMessage"] }, providers: [
1569
- VALIDATE_MESSAGE_PROVIDER,
1952
+ FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1953
+ FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
1954
+ VALIDATE_MESSAGE_PROVIDER
1570
1955
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1571
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormCompareDirective, decorators: [{
1956
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1572
1957
  type: Directive,
1573
1958
  args: [{
1574
- selector: '[fsFormCompare]',
1959
+ selector: '[fsFormLesser]',
1575
1960
  providers: [
1576
- VALIDATE_MESSAGE_PROVIDER,
1961
+ VALIDATE_MESSAGE_PROVIDER
1577
1962
  ],
1578
1963
  }]
1579
- }], propDecorators: { fsFormCompare: [{
1964
+ }], propDecorators: { fsFormLesser: [{
1580
1965
  type: Input
1581
1966
  }], validationMessage: [{
1582
1967
  type: Input,
1583
- args: ['fsFormCompareMessage']
1968
+ args: ['fsFormLesserMessage']
1584
1969
  }] } });
1585
1970
 
1586
- class FsFormIntegerDirective extends FsControlDirective {
1971
+ class FsFormMaxDirective extends FsControlDirective {
1587
1972
  set validationMessage(value) {
1588
- this._validateMessages.integer = value;
1973
+ this._validateMessages.max = value;
1589
1974
  }
1590
1975
  ngOnChanges() {
1591
1976
  this._control.updateValueAndValidity();
1592
1977
  }
1593
1978
  validate(control) {
1594
- if (isEnabled(this.fsFormInteger)) {
1595
- return FsValidators.integer(this._control);
1596
- }
1597
- else {
1598
- return null;
1599
- }
1979
+ return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1600
1980
  }
1601
1981
  }
1602
- FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1603
- FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "validationMessage"] }, providers: [
1982
+ FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1983
+ FsFormMaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
1604
1984
  VALIDATE_MESSAGE_PROVIDER
1605
1985
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1606
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1986
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, decorators: [{
1607
1987
  type: Directive,
1608
1988
  args: [{
1609
- selector: '[fsFormInteger]',
1989
+ selector: '[fsFormMax]',
1610
1990
  providers: [
1611
1991
  VALIDATE_MESSAGE_PROVIDER
1612
1992
  ],
1613
1993
  }]
1614
- }], propDecorators: { fsFormInteger: [{
1994
+ }], propDecorators: { fsFormMax: [{
1615
1995
  type: Input
1616
1996
  }], validationMessage: [{
1617
1997
  type: Input,
1618
- args: ['fsFormIntegerMessage']
1998
+ args: ['fsFormMaxMessage']
1619
1999
  }] } });
1620
2000
 
1621
- class FsFormNumericDirective extends FsControlDirective {
2001
+ class FsFormMaxLengthDirective extends FsControlDirective {
1622
2002
  set validationMessage(value) {
1623
- this._validateMessages.numeric = value;
2003
+ this._validateMessages.maxlength = value;
1624
2004
  }
1625
2005
  ngOnChanges() {
1626
2006
  this._control.updateValueAndValidity();
1627
2007
  }
1628
2008
  validate(control) {
1629
- if (isEnabled(this.fsFormNumeric)) {
1630
- return FsValidators.numeric(this._control);
1631
- }
1632
- else {
1633
- return null;
1634
- }
2009
+ return Validators.maxLength(this.fsFormMaxLength)(this._control);
1635
2010
  }
1636
2011
  }
1637
- FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1638
- FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "validationMessage"] }, providers: [
2012
+ FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2013
+ FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
1639
2014
  VALIDATE_MESSAGE_PROVIDER
1640
2015
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1641
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
2016
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
1642
2017
  type: Directive,
1643
2018
  args: [{
1644
- selector: '[fsFormNumeric]',
2019
+ selector: '[fsFormMaxLength]',
1645
2020
  providers: [
1646
2021
  VALIDATE_MESSAGE_PROVIDER
1647
2022
  ],
1648
2023
  }]
1649
- }], propDecorators: { fsFormNumeric: [{
2024
+ }], propDecorators: { fsFormMaxLength: [{
1650
2025
  type: Input
1651
2026
  }], validationMessage: [{
1652
2027
  type: Input,
1653
- args: ['fsFormNumericMessage']
2028
+ args: ['fsFormMaxLengthMessage']
1654
2029
  }] } });
1655
2030
 
1656
- class FsFormPatternDirective extends FsControlDirective {
2031
+ class FsFormMinDirective extends FsControlDirective {
1657
2032
  set validationMessage(value) {
1658
- this._validateMessages.pattern = value;
2033
+ this._validateMessages.min = value;
1659
2034
  }
1660
2035
  ngOnChanges() {
1661
2036
  this._control.updateValueAndValidity();
1662
2037
  }
1663
2038
  validate(control) {
1664
- return Validators.pattern(this.fsFormPattern)(this._control);
2039
+ return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
1665
2040
  }
1666
2041
  }
1667
- FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1668
- FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "validationMessage"] }, providers: [
2042
+ FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2043
+ FsFormMinDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
1669
2044
  VALIDATE_MESSAGE_PROVIDER
1670
2045
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1671
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
2046
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, decorators: [{
1672
2047
  type: Directive,
1673
2048
  args: [{
1674
- selector: '[fsFormPattern]',
2049
+ selector: '[fsFormMin]',
1675
2050
  providers: [
1676
2051
  VALIDATE_MESSAGE_PROVIDER
1677
2052
  ],
1678
2053
  }]
1679
- }], propDecorators: { fsFormPattern: [{
2054
+ }], propDecorators: { fsFormMin: [{
1680
2055
  type: Input
1681
2056
  }], validationMessage: [{
1682
2057
  type: Input,
1683
- args: ['fsFormPatternMessage']
2058
+ args: ['fsFormMinMessage']
1684
2059
  }] } });
1685
2060
 
1686
- class FsFormFunctionDirective extends FsControlDirective {
1687
- constructor() {
1688
- super(...arguments);
1689
- this.validateOnSubmit = false;
2061
+ class FsFormMinLengthDirective extends FsControlDirective {
2062
+ set validationMessage(value) {
2063
+ this._validateMessages.minlength = value;
1690
2064
  }
1691
2065
  ngOnChanges() {
1692
2066
  this._control.updateValueAndValidity();
1693
2067
  }
1694
- validateAsync(control) {
1695
- if (this.validateOnSubmit && !this.formDirective.validating) {
1696
- return of(null);
1697
- }
1698
- return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
2068
+ validate(control) {
2069
+ return Validators.minLength(this.fsFormMinLength)(this._control);
1699
2070
  }
1700
2071
  }
1701
- FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1702
- FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
2072
+ FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2073
+ FsFormMinLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
1703
2074
  VALIDATE_MESSAGE_PROVIDER
1704
2075
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1705
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
2076
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
1706
2077
  type: Directive,
1707
2078
  args: [{
1708
- selector: '[fsFormFunction]',
2079
+ selector: '[fsFormMinLength]',
1709
2080
  providers: [
1710
2081
  VALIDATE_MESSAGE_PROVIDER
1711
2082
  ],
1712
2083
  }]
1713
- }], propDecorators: { fsFormFunction: [{
1714
- type: Input
1715
- }], fsFormFunctionData: [{
1716
- type: Input
1717
- }], validateOnSubmit: [{
2084
+ }], propDecorators: { fsFormMinLength: [{
1718
2085
  type: Input
2086
+ }], validationMessage: [{
2087
+ type: Input,
2088
+ args: ['fsFormMinLengthMessage']
1719
2089
  }] } });
1720
2090
 
1721
- class FsFormGreaterDirective extends FsControlDirective {
1722
- set validationMessage(value) {
1723
- this._validateMessages.greater = value;
1724
- }
2091
+ /**
2092
+ * This directive required for cases when we have custom Control like <fs-phone-field> but without any of our validators applied
2093
+ *
2094
+ * This directive required for automatic validation messages
2095
+ */
2096
+ class FsFormNoFsValidatorsDirective extends FsControlDirective {
1725
2097
  ngOnChanges() {
1726
2098
  this._control.updateValueAndValidity();
1727
2099
  }
1728
- validate(control) {
1729
- const greater = parseFloat(this.fsFormGreater);
1730
- const value = parseFloat(this._control.value);
1731
- if (!isNaN(greater) && !isNaN(value) && value <= greater) {
1732
- return { greater: { greater, actual: value } };
2100
+ _subscribeToStatusChagnes() {
2101
+ if (!!this._control.validator || !!this._control.asyncValidator) {
2102
+ super._subscribeToStatusChagnes();
1733
2103
  }
1734
- return FsValidators.numeric(this._control);
1735
2104
  }
1736
2105
  }
1737
- FsFormGreaterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1738
- FsFormGreaterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterDirective, selector: "[fsFormGreater]", inputs: { fsFormGreater: "fsFormGreater", validationMessage: ["fsFormGreaterMessage", "validationMessage"] }, providers: [
2106
+ FsFormNoFsValidatorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2107
+ 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([fsFormGreaterEqual]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])", providers: [
1739
2108
  VALIDATE_MESSAGE_PROVIDER
1740
2109
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1741
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
2110
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, decorators: [{
1742
2111
  type: Directive,
1743
2112
  args: [{
1744
- selector: '[fsFormGreater]',
2113
+ selector: '[ngModel]' +
2114
+ ':not([required])' +
2115
+ ':not([fsFormRequired])' +
2116
+ ':not([fsFormCompare])' +
2117
+ ':not([fsFormDateRange])' +
2118
+ ':not([fsFormEmail])' +
2119
+ ':not([fsFormEmails])' +
2120
+ ':not([fsFormFunction])' +
2121
+ ':not([fsFormGreater])' +
2122
+ ':not([fsFormGreaterEqual])' +
2123
+ ':not([fsFormInteger])' +
2124
+ ':not([fsFormLesser])' +
2125
+ ':not([fsFormMax])' +
2126
+ ':not([fsFormMaxLength])' +
2127
+ ':not([fsFormMin])' +
2128
+ ':not([fsFormMinLength])' +
2129
+ ':not([fsFormNumeric])' +
2130
+ ':not([fsFormPattern])' +
2131
+ ':not([fsFormPhone])' +
2132
+ ':not([fsFormUrl])' +
2133
+ ':not([validate])',
1745
2134
  providers: [
1746
2135
  VALIDATE_MESSAGE_PROVIDER
1747
2136
  ],
1748
- }]
1749
- }], propDecorators: { fsFormGreater: [{
1750
- type: Input
1751
- }], validationMessage: [{
1752
- type: Input,
1753
- args: ['fsFormGreaterMessage']
1754
- }] } });
2137
+ }]
2138
+ }] });
1755
2139
 
1756
- class FsFormDateRangeDirective extends FsControlDirective {
2140
+ class FsFormNumericDirective extends FsControlDirective {
1757
2141
  set validationMessage(value) {
1758
- this._validateMessages.dateRange = value;
2142
+ this._validateMessages.numeric = value;
1759
2143
  }
1760
2144
  ngOnChanges() {
1761
2145
  this._control.updateValueAndValidity();
1762
2146
  }
1763
2147
  validate(control) {
1764
- if (isEnabled(this.fsFormDateRange)) {
1765
- return FsValidators.dateRange(this._control);
2148
+ if (isEnabled(this.fsFormNumeric)) {
2149
+ return FsValidators.numeric(this._control);
1766
2150
  }
1767
2151
  else {
1768
2152
  return null;
1769
2153
  }
1770
2154
  }
1771
2155
  }
1772
- FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1773
- FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "validationMessage"] }, providers: [
2156
+ FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2157
+ FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "validationMessage"] }, providers: [
1774
2158
  VALIDATE_MESSAGE_PROVIDER
1775
2159
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1776
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
2160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
1777
2161
  type: Directive,
1778
2162
  args: [{
1779
- selector: '[fsFormDateRange]',
2163
+ selector: '[fsFormNumeric]',
1780
2164
  providers: [
1781
2165
  VALIDATE_MESSAGE_PROVIDER
1782
2166
  ],
1783
2167
  }]
1784
- }], propDecorators: { fsFormDateRange: [{
2168
+ }], propDecorators: { fsFormNumeric: [{
1785
2169
  type: Input
1786
2170
  }], validationMessage: [{
1787
2171
  type: Input,
1788
- args: ['fsFormDateRangeMessage']
2172
+ args: ['fsFormNumericMessage']
1789
2173
  }] } });
1790
2174
 
1791
- class FsFormLesserDirective extends FsControlDirective {
2175
+ class FsFormPatternDirective extends FsControlDirective {
1792
2176
  set validationMessage(value) {
1793
- this._validateMessages.lesser = value;
2177
+ this._validateMessages.pattern = value;
1794
2178
  }
1795
2179
  ngOnChanges() {
1796
2180
  this._control.updateValueAndValidity();
1797
2181
  }
1798
2182
  validate(control) {
1799
- const lesser = parseFloat(this.fsFormLesser);
1800
- const value = parseFloat(this._control.value);
1801
- if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1802
- return { lesser: { lesser, actual: value } };
1803
- }
1804
- return FsValidators.numeric(this._control);
2183
+ return Validators.pattern(this.fsFormPattern)(this._control);
1805
2184
  }
1806
2185
  }
1807
- FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1808
- FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
2186
+ FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2187
+ FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "validationMessage"] }, providers: [
1809
2188
  VALIDATE_MESSAGE_PROVIDER
1810
2189
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1811
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
2190
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
1812
2191
  type: Directive,
1813
2192
  args: [{
1814
- selector: '[fsFormLesser]',
2193
+ selector: '[fsFormPattern]',
1815
2194
  providers: [
1816
2195
  VALIDATE_MESSAGE_PROVIDER
1817
2196
  ],
1818
2197
  }]
1819
- }], propDecorators: { fsFormLesser: [{
2198
+ }], propDecorators: { fsFormPattern: [{
1820
2199
  type: Input
1821
2200
  }], validationMessage: [{
1822
2201
  type: Input,
1823
- args: ['fsFormLesserMessage']
2202
+ args: ['fsFormPatternMessage']
1824
2203
  }] } });
1825
2204
 
1826
- class FsFormUrlDirective extends FsControlDirective {
1827
- constructor() {
1828
- super(...arguments);
1829
- this.fsFormUrlProtocol = false;
1830
- }
2205
+ class FsFormPhoneDirective extends FsControlDirective {
1831
2206
  set validationMessage(value) {
1832
- this._validateMessages.url = value;
2207
+ this._validateMessages.phone = value;
1833
2208
  }
1834
2209
  ngOnChanges() {
1835
2210
  this._control.updateValueAndValidity();
1836
2211
  }
1837
2212
  validate(control) {
1838
- if (isEnabled(this.fsFormUrl)) {
1839
- return FsValidators.url(this._control, this.fsFormUrlProtocol);
2213
+ if (isEnabled(this.fsFormPhone)) {
2214
+ return FsValidators.phone(this._control);
1840
2215
  }
1841
2216
  else {
1842
2217
  return null;
1843
2218
  }
1844
2219
  }
1845
2220
  }
1846
- FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1847
- FsFormUrlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormUrlDirective, selector: "[fsFormUrl]", inputs: { fsFormUrl: "fsFormUrl", fsFormUrlProtocol: "fsFormUrlProtocol", validationMessage: ["fsFormUrlMessage", "validationMessage"] }, providers: [
2221
+ FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2222
+ FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
1848
2223
  VALIDATE_MESSAGE_PROVIDER
1849
2224
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1850
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, decorators: [{
2225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
1851
2226
  type: Directive,
1852
2227
  args: [{
1853
- selector: '[fsFormUrl]',
2228
+ selector: '[fsFormPhone]',
1854
2229
  providers: [
1855
2230
  VALIDATE_MESSAGE_PROVIDER
1856
2231
  ],
1857
2232
  }]
1858
- }], propDecorators: { fsFormUrl: [{
1859
- type: Input
1860
- }], fsFormUrlProtocol: [{
2233
+ }], propDecorators: { fsFormPhone: [{
1861
2234
  type: Input
1862
2235
  }], validationMessage: [{
1863
2236
  type: Input,
1864
- args: ['fsFormUrlMessage']
2237
+ args: ['fsFormPhoneMessage']
1865
2238
  }] } });
1866
2239
 
1867
- class FsFormDialogCloseDirective {
1868
- constructor(_form, _dialogRef) {
1869
- this._form = _form;
1870
- this._dialogRef = _dialogRef;
1871
- this._destroy$ = new Subject();
1872
- this.type = 'button';
2240
+ class FsFormRequiredDirective extends FsControlDirective {
2241
+ constructor() {
2242
+ super(...arguments);
2243
+ this.required = false;
1873
2244
  }
1874
- closeClick() {
1875
- if (this._form) {
1876
- this._form.triggerConfirm()
1877
- .pipe(filter((confirmResult) => (confirmResult !== ConfirmResult.Review)), takeUntil(this._destroy$))
1878
- .subscribe(() => {
1879
- this._dialogRef.close(this.closeData);
1880
- });
1881
- }
1882
- else {
1883
- this._dialogRef.close(this.closeData);
2245
+ set setFsFormRequired(value) {
2246
+ this.required = isEnabled(value);
2247
+ }
2248
+ set setRequired(value) {
2249
+ this.required = isEnabled(value);
2250
+ }
2251
+ set validationMessage(value) {
2252
+ this._validateMessages.required = value;
2253
+ }
2254
+ ngOnChanges() {
2255
+ this._control.updateValueAndValidity();
2256
+ }
2257
+ validate(control) {
2258
+ if (this.required) {
2259
+ return Validators.required(this._control);
1884
2260
  }
2261
+ return null;
1885
2262
  }
1886
- ngOnDestroy() {
1887
- this._destroy$.next();
1888
- this._destroy$.complete();
2263
+ render() {
2264
+ const wrapper = this.getWrapperElement();
2265
+ if (wrapper && this.getlabelSelector()) {
2266
+ const labelWrapper = wrapper.querySelector(this.getlabelSelector());
2267
+ // Adding class fs-form-label-requried adds the * to the label
2268
+ if (labelWrapper) {
2269
+ if (this.required) {
2270
+ this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
2271
+ }
2272
+ else {
2273
+ this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
2274
+ }
2275
+ }
2276
+ }
2277
+ super.render();
1889
2278
  }
1890
2279
  }
1891
- FsFormDialogCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogCloseDirective, deps: [{ token: FsFormDirective, optional: true }, { token: i2$1.MatDialogRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1892
- FsFormDialogCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", inputs: { closeData: "closeData" }, host: { listeners: { "click": "closeClick($event.target)" }, properties: { "attr.type": "this.type" } }, ngImport: i0 });
1893
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
2280
+ FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2281
+ 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: [
2282
+ VALIDATE_MESSAGE_PROVIDER,
2283
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2284
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
1894
2285
  type: Directive,
1895
2286
  args: [{
1896
- selector: '[fsFormDialogClose],[fs-form-dialog-close]'
2287
+ selector: '[fsFormRequired],[ngModel][required]',
2288
+ providers: [
2289
+ VALIDATE_MESSAGE_PROVIDER,
2290
+ ],
1897
2291
  }]
1898
- }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
1899
- type: Optional
1900
- }] }, { type: i2$1.MatDialogRef, decorators: [{
1901
- type: Optional
1902
- }] }]; }, propDecorators: { closeData: [{
1903
- type: Input
1904
- }], type: [{
1905
- type: HostBinding,
1906
- args: ['attr.type']
1907
- }], closeClick: [{
1908
- type: HostListener,
1909
- args: ['click', ['$event.target']]
2292
+ }], propDecorators: { setFsFormRequired: [{
2293
+ type: Input,
2294
+ args: ['fsFormRequired']
2295
+ }], setRequired: [{
2296
+ type: Input,
2297
+ args: ['required']
2298
+ }], validationMessage: [{
2299
+ type: Input,
2300
+ args: ['fsFormRequiredMessage']
1910
2301
  }] } });
1911
2302
 
1912
- class FsButtonDirective {
1913
- constructor(_matButton, _form, _elementRef, _cdRef) {
1914
- this._matButton = _matButton;
1915
- this._form = _form;
1916
- this._elementRef = _elementRef;
1917
- this._cdRef = _cdRef;
1918
- this.dirtySubmit = true;
1919
- this.transitionStyle = null;
1920
- this.active = false;
1921
- this.submit = false;
1922
- this._previousDisabled = false;
1923
- this._destroy$ = new Subject();
1924
- }
1925
- ngOnInit() {
1926
- this.submit = this._elementRef.nativeElement.getAttribute('type') === 'submit';
1927
- this.form = this.form || this._form;
1928
- if (this.form) {
1929
- this.form.addButton(this);
1930
- if (this.submit) {
1931
- fromEvent(this.element, 'click')
1932
- .pipe(takeUntil(this._destroy$))
1933
- .subscribe(() => {
1934
- this.active = true;
1935
- });
1936
- if (this.dirtySubmit) {
1937
- if (this.form.dirtySubmitButton) {
1938
- if (!this.form.ngForm.dirty) {
1939
- this.disable();
1940
- }
1941
- }
1942
- }
1943
- this.transitionStyle = 'none';
1944
- setTimeout(() => {
1945
- this.transitionStyle = null;
1946
- }, 500);
1947
- }
1948
- }
1949
- }
1950
- disable() {
1951
- if (this._matButton && !this.active) {
1952
- this._previousDisabled = this._matButton.disabled;
1953
- this._matButton.disabled = true;
1954
- this._cdRef.markForCheck();
1955
- }
1956
- }
1957
- enable() {
1958
- if (this._matButton) {
1959
- this._matButton.disabled = false;
1960
- this._matButton.disableRipple = true;
1961
- this._cdRef.markForCheck();
1962
- }
1963
- }
1964
- process() {
1965
- this.setClass('process');
1966
- if (this._matButton) {
1967
- this._matButton.disableRipple = true;
1968
- }
1969
- }
1970
- success() {
1971
- this.setClass('success');
1972
- if (this._matButton) {
1973
- this._matButton.disableRipple = false;
1974
- }
1975
- }
1976
- error() {
1977
- this.setClass('error');
1978
- if (this._matButton) {
1979
- this._matButton.disableRipple = false;
1980
- }
1981
- }
1982
- setClass(cls) {
1983
- const svg = this._getSvg(cls);
1984
- this._resetClass();
1985
- this._disableShadowAnimation();
1986
- this.element.classList.add(`submit-${cls}`);
1987
- this.element.append(svg);
1988
- }
1989
- get element() {
1990
- return this._elementRef.nativeElement;
1991
- }
1992
- resetActive() {
1993
- this.active = false;
1994
- }
1995
- reset() {
1996
- if (!this._previousDisabled) {
1997
- this.enable();
1998
- }
1999
- this.element.querySelectorAll('.svg-icon')
2000
- .forEach((el) => {
2001
- el.remove();
2002
- });
2003
- if (this._matButton) {
2004
- this._matButton.disableRipple = false;
2005
- }
2006
- this._resetClass();
2007
- }
2008
- ngOnDestroy() {
2009
- this._destroy$.next();
2010
- this._destroy$.complete();
2011
- this.form?.removeButton(this);
2303
+ class FsFormUrlDirective extends FsControlDirective {
2304
+ constructor() {
2305
+ super(...arguments);
2306
+ this.fsFormUrlProtocol = false;
2012
2307
  }
2013
- _disableShadowAnimation() {
2014
- // .mat-elevation-z2 removes the click shadow animation
2015
- //this.element.classList.add('mat-elevation-z2');
2308
+ set validationMessage(value) {
2309
+ this._validateMessages.url = value;
2016
2310
  }
2017
- _resetClass() {
2018
- this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
2311
+ ngOnChanges() {
2312
+ this._control.updateValueAndValidity();
2019
2313
  }
2020
- _getSvg(type) {
2021
- if (type === 'success') {
2022
- return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-success" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 38 38" style="enable-background:new 0 0 38 38;" xml:space="preserve" width="38px" height="38px">
2023
- <g>
2024
- <g class="check">
2025
- <g>
2026
- <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"/>
2027
- </g>
2028
- </g>
2029
- </g>
2030
- </svg>`, 'text/xml').firstChild;
2031
- }
2032
- if (type === 'process') {
2033
- return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-process" width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
2034
- <g fill="none" fill-rule="evenodd">
2035
- <g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
2036
- <path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur=".7s" repeatCount="indefinite"/></path>
2037
- </g>
2038
- </g>
2039
- </svg>`, 'text/xml').firstChild;
2314
+ validate(control) {
2315
+ if (isEnabled(this.fsFormUrl)) {
2316
+ return FsValidators.url(this._control, this.fsFormUrlProtocol);
2040
2317
  }
2041
- if (type === 'error') {
2042
- return new DOMParser().parseFromString(`<svg class="svg-icon svg-icon-error" xmlns="http://www.w3.org/2000/svg" width="38px" height="38px" viewBox="0 0 16 16"><g><path d="M8 1c3.9 0 7 3.1 7 7s-3.1 7-7 7-7-3.1-7-7 3.1-7 7-7zM8 0c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8v0z" data-original="#444444" data-old_color="#444444"/><path d="M12.2 10.8l-2.8-2.8 2.8-2.8-1.4-1.4-2.8 2.8-2.8-2.8-1.4 1.4 2.8 2.8-2.8 2.8 1.4 1.4 2.8-2.8 2.8 2.8z"/></g> </svg>`, 'text/xml').firstChild;
2318
+ else {
2319
+ return null;
2043
2320
  }
2044
2321
  }
2045
2322
  }
2046
- FsButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsButtonDirective, deps: [{ token: i1$2.MatButton, host: true, optional: true }, { token: FsFormDirective, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2047
- FsButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: { name: "name", dirtySubmit: "dirtySubmit", form: "form" }, host: { properties: { "style.transition": "this.transitionStyle" } }, ngImport: i0 });
2048
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsButtonDirective, decorators: [{
2323
+ FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2324
+ 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: [
2325
+ VALIDATE_MESSAGE_PROVIDER
2326
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2327
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, decorators: [{
2049
2328
  type: Directive,
2050
2329
  args: [{
2051
- selector: '[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]',
2330
+ selector: '[fsFormUrl]',
2331
+ providers: [
2332
+ VALIDATE_MESSAGE_PROVIDER
2333
+ ],
2052
2334
  }]
2053
- }], ctorParameters: function () { return [{ type: i1$2.MatButton, decorators: [{
2054
- type: Optional
2055
- }, {
2056
- type: Host
2057
- }] }, { type: FsFormDirective, decorators: [{
2058
- type: Optional
2059
- }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
2060
- type: Input
2061
- }], dirtySubmit: [{
2335
+ }], propDecorators: { fsFormUrl: [{
2062
2336
  type: Input
2063
- }], form: [{
2337
+ }], fsFormUrlProtocol: [{
2064
2338
  type: Input
2065
- }], transitionStyle: [{
2066
- type: HostBinding,
2067
- args: ['style.transition']
2339
+ }], validationMessage: [{
2340
+ type: Input,
2341
+ args: ['fsFormUrlMessage']
2068
2342
  }] } });
2069
2343
 
2070
2344
  class FsFormValidateDirective extends FsControlDirective {
@@ -2104,204 +2378,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2104
2378
  type: Input
2105
2379
  }] } });
2106
2380
 
2107
- class FsFormDialogActionsComponent {
2108
- constructor(_form, _dialogRef, _cdRef) {
2109
- this._form = _form;
2110
- this._dialogRef = _dialogRef;
2111
- this._cdRef = _cdRef;
2112
- this.save = true;
2113
- this.create = false;
2114
- this.close = false;
2115
- this.done = false;
2116
- this.closeData = null;
2117
- this.dirty = false;
2118
- this._destroy$ = new Subject();
2119
- }
2120
- ngOnInit() {
2121
- if (this._form) {
2122
- this._form.ngForm.valueChanges
2123
- .pipe(filter(() => (!this.dirty)), takeUntil(this._destroy$))
2124
- .subscribe(() => {
2125
- this.dirty = this._form.ngForm.dirty;
2126
- this._cdRef.markForCheck();
2127
- });
2128
- this._form.submitted
2129
- .pipe(delay(50), takeUntil(this._destroy$))
2130
- .subscribe(() => {
2131
- this.dirty = false;
2132
- this._cdRef.markForCheck();
2133
- });
2134
- this._form.reseted
2135
- .pipe(takeUntil(this._destroy$))
2136
- .subscribe(() => {
2137
- this.dirty = false;
2138
- this._cdRef.markForCheck();
2139
- });
2140
- }
2141
- }
2142
- ngOnDestroy() {
2143
- this._destroy$.next();
2144
- this._destroy$.complete();
2145
- }
2146
- }
2147
- FsFormDialogActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, deps: [{ token: FsFormDirective, optional: true }, { token: i2$1.MatDialogRef, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2148
- FsFormDialogActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDialogActionsComponent, selector: "fs-form-dialog-actions", inputs: { save: "save", create: "create", close: "close", done: "done", closeData: "closeData", name: "name" }, ngImport: i0, template: "<div class=\"form-buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save || create\">\n <button\n mat-button\n type=\"submit\"\n color=\"primary\"\n [name]=\"name\">\n {{create ? 'Create' : 'Save'}}\n </button>\n <button\n mat-button\n type=\"button\"\n class=\"close-button cancel-button\"\n [disabled]=\"close && !dirty && !create\"\n [mat-dialog-close]=\"null\">\n Cancel\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"done\">\n <button\n mat-button\n type=\"button\"\n color=\"primary\"\n [mat-dialog-close]=\"null\">\n Done\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"save || create\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"close\">\n <button\n mat-button\n type=\"button\"\n class=\"close-button\"\n fsFormDialogClose\n [closeData]=\"closeData\"\n [color]=\"dirty ? 'basic' : 'primary'\">\n Close\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"!(save || create)\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n</div>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n", styles: [":host{width:100%}.form-buttons.save-create .close-button:not(.cancel-button){float:right}\n"], components: [{ type: i1$2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: ["name", "dirtySubmit", "form"] }, { type: i2$1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", inputs: ["closeData"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2149
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
2150
- type: Component,
2151
- args: [{ selector: 'fs-form-dialog-actions', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save || create\">\n <button\n mat-button\n type=\"submit\"\n color=\"primary\"\n [name]=\"name\">\n {{create ? 'Create' : 'Save'}}\n </button>\n <button\n mat-button\n type=\"button\"\n class=\"close-button cancel-button\"\n [disabled]=\"close && !dirty && !create\"\n [mat-dialog-close]=\"null\">\n Cancel\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"done\">\n <button\n mat-button\n type=\"button\"\n color=\"primary\"\n [mat-dialog-close]=\"null\">\n Done\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"save || create\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"close\">\n <button\n mat-button\n type=\"button\"\n class=\"close-button\"\n fsFormDialogClose\n [closeData]=\"closeData\"\n [color]=\"dirty ? 'basic' : 'primary'\">\n Close\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"!(save || create)\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n</div>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n", styles: [":host{width:100%}.form-buttons.save-create .close-button:not(.cancel-button){float:right}\n"] }]
2152
- }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
2153
- type: Optional
2154
- }] }, { type: i2$1.MatDialogRef, decorators: [{
2155
- type: Optional
2156
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { save: [{
2157
- type: Input
2158
- }], create: [{
2159
- type: Input
2160
- }], close: [{
2161
- type: Input
2162
- }], done: [{
2163
- type: Input
2164
- }], closeData: [{
2165
- type: Input
2166
- }], name: [{
2167
- type: Input
2168
- }] } });
2169
-
2170
- /**
2171
- * This directive required for cases when we have custom Control like <fs-phone-field> but without any of our validators applied
2172
- *
2173
- * This directive required for automatic validation messages
2174
- */
2175
- class FsFormNoFsValidatorsDirective extends FsControlDirective {
2176
- ngOnChanges() {
2177
- this._control.updateValueAndValidity();
2178
- }
2179
- _subscribeToStatusChagnes() {
2180
- if (!!this._control.validator || !!this._control.asyncValidator) {
2181
- super._subscribeToStatusChagnes();
2182
- }
2183
- }
2184
- }
2185
- FsFormNoFsValidatorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2186
- FsFormNoFsValidatorsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])", providers: [
2187
- VALIDATE_MESSAGE_PROVIDER
2188
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2189
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, decorators: [{
2190
- type: Directive,
2191
- args: [{
2192
- selector: '[ngModel]' +
2193
- ':not([required])' +
2194
- ':not([fsFormRequired])' +
2195
- ':not([fsFormCompare])' +
2196
- ':not([fsFormDateRange])' +
2197
- ':not([fsFormEmail])' +
2198
- ':not([fsFormEmails])' +
2199
- ':not([fsFormFunction])' +
2200
- ':not([fsFormGreater])' +
2201
- ':not([fsFormInteger])' +
2202
- ':not([fsFormLesser])' +
2203
- ':not([fsFormMax])' +
2204
- ':not([fsFormMaxLength])' +
2205
- ':not([fsFormMin])' +
2206
- ':not([fsFormMinLength])' +
2207
- ':not([fsFormNumeric])' +
2208
- ':not([fsFormPattern])' +
2209
- ':not([fsFormPhone])' +
2210
- ':not([fsFormUrl])' +
2211
- ':not([validate])',
2212
- providers: [
2213
- VALIDATE_MESSAGE_PROVIDER
2214
- ],
2215
- }]
2216
- }] });
2217
-
2218
- class FsFormTemplateDirective {
2219
- constructor() { }
2220
- ngAfterContentInit() {
2221
- }
2222
- }
2223
- FsFormTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2224
- FsFormTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormTemplateDirective, selector: "[fsFormTemplate]", viewQueries: [{ propertyName: "models", predicate: NgModel, descendants: true }], ngImport: i0 });
2225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateDirective, decorators: [{
2226
- type: Directive,
2227
- args: [{
2228
- selector: '[fsFormTemplate]',
2229
- }]
2230
- }], ctorParameters: function () { return []; }, propDecorators: { models: [{
2231
- type: ViewChildren,
2232
- args: [NgModel]
2233
- }] } });
2234
-
2235
- class FsSubmitButtonDirective extends FsButtonDirective {
2236
- }
2237
- FsSubmitButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsSubmitButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2238
- FsSubmitButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsSubmitButtonDirective, selector: "dummy-selector", usesInheritance: true, ngImport: i0 });
2239
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsSubmitButtonDirective, decorators: [{
2240
- type: Directive,
2241
- args: [{
2242
- selector: 'dummy-selector',
2243
- }]
2244
- }] });
2245
-
2246
- class FsFormTemplateComponent {
2247
- constructor() { }
2248
- ngAfterContentInit() {
2249
- debugger;
2250
- const x = this.models;
2251
- this.models.changes.subscribe((x) => {
2252
- debugger;
2253
- });
2254
- }
2255
- ngOnInit() {
2256
- debugger;
2257
- }
2258
- }
2259
- FsFormTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2260
- 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 });
2261
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, decorators: [{
2262
- type: Component,
2263
- args: [{ selector: 'fs-form-template', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #templateRef1>\n <ng-content></ng-content>\n</ng-template>" }]
2264
- }], ctorParameters: function () { return []; }, propDecorators: { templateRef: [{
2265
- type: ViewChild,
2266
- args: ['templateRef1']
2267
- }], formTemplate: [{
2268
- type: Input
2269
- }], models: [{
2270
- type: ContentChildren,
2271
- args: [NgModel, { descendants: true }]
2272
- }] } });
2273
-
2274
- class FsFormTemplateOutletComponent {
2275
- constructor() { }
2276
- ngOnChanges(changes) {
2277
- if (changes.formTemplate?.currentValue) {
2278
- }
2279
- }
2280
- ngAfterContentInit() {
2281
- // const x = this.models;
2282
- // this.models.changes.subscribe((x) => {
2283
- // debugger;
2284
- // });
2285
- }
2286
- }
2287
- FsFormTemplateOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2288
- FsFormTemplateOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsFormTemplateOutletComponent, selector: "fs-form-template-outlet", inputs: { formTemplate: "formTemplate" }, queries: [{ propertyName: "models", predicate: NgModel, descendants: true }], usesOnChanges: true, ngImport: i0, template: "\n{{formTemplate.templateRef|json}}\n\n<ng-container *ngIf=\"formTemplate\">\n <ng-container [ngTemplateOutlet]=\"formTemplate.templateRef\"></ng-container> \n</ng-container>", directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "json": i4.JsonPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2289
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, decorators: [{
2290
- type: Component,
2291
- args: [{ selector: 'fs-form-template-outlet', changeDetection: ChangeDetectionStrategy.OnPush, template: "\n{{formTemplate.templateRef|json}}\n\n<ng-container *ngIf=\"formTemplate\">\n <ng-container [ngTemplateOutlet]=\"formTemplate.templateRef\"></ng-container> \n</ng-container>" }]
2292
- }], ctorParameters: function () { return []; }, propDecorators: { formTemplate: [{
2293
- type: Input
2294
- }], models: [{
2295
- type: ContentChildren,
2296
- args: [NgModel, { descendants: true }]
2297
- }] } });
2298
-
2299
2381
  class FsFormModule {
2300
2382
  static forRoot() {
2301
2383
  /**
2302
2384
  * Hack: https://github.com/angular/components/issues/20097
2303
2385
  */
2304
- ErrorStateMatcher.prototype.isErrorState = (control, form) => {
2386
+ ErrorStateMatcher.prototype
2387
+ .isErrorState = (control, form) => {
2305
2388
  return control?.invalid && control?.touched && control?.dirty;
2306
2389
  };
2307
2390
  return {
@@ -2327,7 +2410,9 @@ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
2327
2410
  FsFormFunctionDirective,
2328
2411
  FsFormDateRangeDirective,
2329
2412
  FsFormGreaterDirective,
2413
+ FsFormGreaterEqualDirective,
2330
2414
  FsFormLesserDirective,
2415
+ FsFormLesserEqualDirective,
2331
2416
  FsFormUrlDirective,
2332
2417
  FsFormDialogCloseDirective,
2333
2418
  FsFormValidateDirective,
@@ -2337,10 +2422,13 @@ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
2337
2422
  FsSubmitButtonDirective,
2338
2423
  FsFormTemplateComponent,
2339
2424
  FsFormTemplateDirective,
2340
- FsFormTemplateOutletComponent], imports: [CommonModule,
2425
+ FsFormTemplateOutletComponent,
2426
+ ConfirmUnsavedComponent], imports: [CommonModule,
2341
2427
  FormsModule,
2342
2428
  MatButtonModule,
2343
- MatDialogModule], exports: [FsFormDirective,
2429
+ MatDialogModule,
2430
+ MatDialogModule,
2431
+ FsDialogModule], exports: [FsFormDirective,
2344
2432
  FsControlDirective,
2345
2433
  FsFormRequiredDirective,
2346
2434
  FsFormMinDirective,
@@ -2357,7 +2445,9 @@ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
2357
2445
  FsFormFunctionDirective,
2358
2446
  FsFormDateRangeDirective,
2359
2447
  FsFormGreaterDirective,
2448
+ FsFormGreaterEqualDirective,
2360
2449
  FsFormLesserDirective,
2450
+ FsFormLesserEqualDirective,
2361
2451
  FsFormUrlDirective,
2362
2452
  FsFormDialogCloseDirective,
2363
2453
  FsFormValidateDirective,
@@ -2378,6 +2468,8 @@ FsFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
2378
2468
  FormsModule,
2379
2469
  MatButtonModule,
2380
2470
  MatDialogModule,
2471
+ MatDialogModule,
2472
+ FsDialogModule,
2381
2473
  ]] });
2382
2474
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormModule, decorators: [{
2383
2475
  type: NgModule,
@@ -2387,6 +2479,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2387
2479
  FormsModule,
2388
2480
  MatButtonModule,
2389
2481
  MatDialogModule,
2482
+ MatDialogModule,
2483
+ FsDialogModule,
2390
2484
  ],
2391
2485
  declarations: [
2392
2486
  FsFormDirective,
@@ -2406,7 +2500,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2406
2500
  FsFormFunctionDirective,
2407
2501
  FsFormDateRangeDirective,
2408
2502
  FsFormGreaterDirective,
2503
+ FsFormGreaterEqualDirective,
2409
2504
  FsFormLesserDirective,
2505
+ FsFormLesserEqualDirective,
2410
2506
  FsFormUrlDirective,
2411
2507
  FsFormDialogCloseDirective,
2412
2508
  FsFormValidateDirective,
@@ -2417,6 +2513,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2417
2513
  FsFormTemplateComponent,
2418
2514
  FsFormTemplateDirective,
2419
2515
  FsFormTemplateOutletComponent,
2516
+ ConfirmUnsavedComponent,
2420
2517
  ],
2421
2518
  exports: [
2422
2519
  FsFormDirective,
@@ -2436,7 +2533,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2436
2533
  FsFormFunctionDirective,
2437
2534
  FsFormDateRangeDirective,
2438
2535
  FsFormGreaterDirective,
2536
+ FsFormGreaterEqualDirective,
2439
2537
  FsFormLesserDirective,
2538
+ FsFormLesserEqualDirective,
2440
2539
  FsFormUrlDirective,
2441
2540
  FsFormDialogCloseDirective,
2442
2541
  FsFormValidateDirective,
@@ -2463,5 +2562,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2463
2562
  * Generated bundle index. Do not edit.
2464
2563
  */
2465
2564
 
2466
- export { ConfirmResult, FormDeactivateGuard, FormStatus, FsButtonDirective, FsControlDirective, FsForm, FsFormCompareDirective, FsFormDateRangeDirective, FsFormDialogActionsComponent, FsFormDialogCloseDirective, FsFormDirective, FsFormEmailDirective, FsFormEmailsDirective, FsFormFunctionDirective, FsFormGreaterDirective, FsFormIntegerDirective, FsFormLesserDirective, FsFormMaxDirective, FsFormMaxLengthDirective, FsFormMinDirective, FsFormMinLengthDirective, FsFormModule, FsFormNoFsValidatorsDirective, FsFormNumericDirective, FsFormPatternDirective, FsFormPhoneDirective, FsFormRequiredDirective, FsFormTemplateComponent, FsFormTemplateDirective, FsFormTemplateOutletComponent, FsFormUrlDirective, FsFormValidateDirective, FsSubmitButtonDirective, FsValidators };
2565
+ export { ConfirmResult, FormDeactivateGuard, FormStatus, FsButtonDirective, FsControlDirective, FsForm, FsFormCompareDirective, FsFormDateRangeDirective, FsFormDialogActionsComponent, FsFormDialogCloseDirective, FsFormDirective, FsFormEmailDirective, FsFormEmailsDirective, FsFormFunctionDirective, FsFormGreaterDirective, FsFormGreaterEqualDirective, FsFormIntegerDirective, FsFormLesserDirective, FsFormLesserEqualDirective, FsFormMaxDirective, FsFormMaxLengthDirective, FsFormMinDirective, FsFormMinLengthDirective, FsFormModule, FsFormNoFsValidatorsDirective, FsFormNumericDirective, FsFormPatternDirective, FsFormPhoneDirective, FsFormRequiredDirective, FsFormTemplateComponent, FsFormTemplateDirective, FsFormTemplateOutletComponent, FsFormUrlDirective, FsFormValidateDirective, FsSubmitButtonDirective, FsValidators };
2467
2566
  //# sourceMappingURL=firestitch-form.mjs.map