@firestitch/form 13.2.0 → 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 (49) 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/directives/button.directive.d.ts +2 -2
  6. package/app/directives/form/form.directive.d.ts +5 -7
  7. package/app/directives/form-dialog-close.directive.d.ts +2 -2
  8. package/app/directives/index.d.ts +2 -2
  9. package/app/directives/validators/compare.directive.d.ts +2 -2
  10. package/app/directives/validators/control.directive.d.ts +12 -12
  11. package/app/directives/validators/function.directive.d.ts +1 -1
  12. package/app/directives/validators/integer.directive.d.ts +1 -1
  13. package/app/directives/validators/required.directive.d.ts +1 -1
  14. package/app/enums/index.d.ts +2 -0
  15. package/app/fs-form.module.d.ts +7 -5
  16. package/app/guards/form-deactivate.guard.d.ts +2 -4
  17. package/app/helpers/index.d.ts +0 -1
  18. package/app/services/fsform.service.d.ts +5 -1
  19. package/esm2020/app/components/confirm-unsaved/confirm-unsaved.component.mjs +44 -0
  20. package/esm2020/app/components/confirm-unsaved/index.mjs +2 -0
  21. package/esm2020/app/components/form-dialog-actions/form-dialog-actions.component.mjs +3 -3
  22. package/esm2020/app/components/form-dialog-actions/index.mjs +1 -1
  23. package/esm2020/app/components/index.mjs +2 -1
  24. package/esm2020/app/directives/button.directive.mjs +6 -6
  25. package/esm2020/app/directives/form/form.directive.mjs +28 -32
  26. package/esm2020/app/directives/form/index.mjs +1 -1
  27. package/esm2020/app/directives/form-dialog-close.directive.mjs +6 -6
  28. package/esm2020/app/directives/index.mjs +3 -3
  29. package/esm2020/app/directives/validators/compare.directive.mjs +4 -6
  30. package/esm2020/app/directives/validators/control.directive.mjs +20 -21
  31. package/esm2020/app/directives/validators/function.directive.mjs +5 -5
  32. package/esm2020/app/directives/validators/index.mjs +1 -1
  33. package/esm2020/app/directives/validators/integer.directive.mjs +7 -9
  34. package/esm2020/app/directives/validators/required.directive.mjs +6 -8
  35. package/esm2020/app/enums/index.mjs +3 -0
  36. package/esm2020/app/fs-form.module.mjs +32 -23
  37. package/esm2020/app/guards/form-deactivate.guard.mjs +13 -16
  38. package/esm2020/app/helpers/get-form-errors.mjs +1 -1
  39. package/esm2020/app/helpers/index.mjs +1 -2
  40. package/esm2020/app/services/fsform.service.mjs +59 -7
  41. package/esm2020/public_api.mjs +16 -16
  42. package/fesm2015/firestitch-form.mjs +1173 -1153
  43. package/fesm2015/firestitch-form.mjs.map +1 -1
  44. package/fesm2020/firestitch-form.mjs +1173 -1155
  45. package/fesm2020/firestitch-form.mjs.map +1 -1
  46. package/package.json +1 -5
  47. package/public_api.d.ts +16 -16
  48. package/app/helpers/confirm-unsaved.d.ts +0 -5
  49. 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,670 +890,630 @@ 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
- greaterEqual: 'Value must be greater than or equal $(1)',
896
- lesserEqual: 'Value must be less than or equal $(1)',
897
- };
898
-
899
- const VALIDATE_MESSAGES = new InjectionToken('fs.form.validate-messages');
900
- const VALIDATE_MESSAGE_PROVIDER = {
901
- provide: VALIDATE_MESSAGES,
902
- useFactory: messageProviderFactory,
903
- };
904
- function messageProviderFactory() {
905
- return { ...ERROR_MESSAGES };
906
- }
907
-
908
- class FsControlDirective {
909
- constructor(elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
910
- this.elementRef = elementRef;
911
- this.renderer2 = renderer2;
912
- this.injector = injector;
913
- this._validateMessages = _validateMessages;
914
- this.ngControl = ngControl;
915
- this.formDirective = formDirective;
916
- this.appendMessageClass = 'fs-form-message';
917
- this.appendLabelClass = 'fs-form-label';
918
- this.appendErrorClass = 'fs-form-error';
919
- this.appendHintClass = 'fs-form-hint';
920
- this.errors = [];
921
- // 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;
922
904
  this._destroy$ = new Subject();
923
- if (ngControl) {
924
- this._control = ngControl.control;
925
- }
926
- else {
927
- console.error('The element does not have a valid ngModel', this.elementRef.nativeElement);
928
- }
929
- }
930
- set validateMessages(messages) {
931
- this._validateMessages = {
932
- ...this._validateMessages,
933
- ...messages,
934
- };
935
905
  }
936
906
  ngOnInit() {
937
- this._setupValidators();
938
- }
939
- ngOnDestroy() {
940
- this._destroy$.next();
941
- this._destroy$.complete();
942
- }
943
- ngAfterContentInit() {
944
- this._subscribeToStatusChagnes();
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
+ }
929
+ }
945
930
  }
946
- _subscribeToStatusChagnes() {
947
- if (this._control) {
948
- this._control.statusChanges
949
- .pipe(takeUntil(this._destroy$))
950
- .subscribe(this.render.bind(this));
931
+ disable() {
932
+ if (this._matButton && !this.active) {
933
+ this._previousDisabled = this._matButton.disabled;
934
+ this._matButton.disabled = true;
935
+ this._cdRef.markForCheck();
951
936
  }
952
937
  }
953
- getMessageSelector() {
954
- if (this.messageSelector === false) {
955
- return '';
938
+ enable() {
939
+ if (this._matButton) {
940
+ this._matButton.disabled = false;
941
+ this._matButton.disableRipple = true;
942
+ this._cdRef.markForCheck();
956
943
  }
957
- if (this.messageSelector) {
958
- return this.messageSelector;
944
+ }
945
+ process() {
946
+ this.setClass('process');
947
+ if (this._matButton) {
948
+ this._matButton.disableRipple = true;
959
949
  }
960
- else if (this.formDirective?.messageSelector) {
961
- return this.formDirective.messageSelector;
950
+ }
951
+ success() {
952
+ this.setClass('success');
953
+ if (this._matButton) {
954
+ this._matButton.disableRipple = false;
962
955
  }
963
956
  }
964
- getHintWrapperSelector() {
965
- if (this.hintSelector === false) {
966
- return '';
967
- }
968
- if (this.hintSelector) {
969
- return this.hintSelector;
970
- }
971
- else if (this.formDirective?.hintSelector) {
972
- return this.formDirective.hintSelector;
973
- }
974
- }
975
- getWrapperSelector() {
976
- if (this.wrapperSelector === false) {
977
- return '';
978
- }
979
- if (this.wrapperSelector) {
980
- return this.wrapperSelector;
981
- }
982
- else if (this.formDirective?.wrapperSelector) {
983
- return this.formDirective.wrapperSelector;
957
+ error() {
958
+ this.setClass('error');
959
+ if (this._matButton) {
960
+ this._matButton.disableRipple = false;
984
961
  }
985
962
  }
986
- getlabelSelector() {
987
- if (this.labelSelector === false) {
988
- return '';
989
- }
990
- if (this.labelSelector) {
991
- return this.labelSelector;
992
- }
993
- else if (this.formDirective?.labelSelector) {
994
- return this.formDirective.labelSelector;
995
- }
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);
996
969
  }
997
- getWrapperElement() {
998
- const wrapper = this.getWrapper(this.elementRef.nativeElement);
999
- if (wrapper) {
1000
- return wrapper;
1001
- }
1002
- return this.elementRef.nativeElement;
970
+ get element() {
971
+ return this._elementRef.nativeElement;
1003
972
  }
1004
- /*
1005
- <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.
1006
- <input>
1007
- <div class="fs-form-message"> <-- Message Selector. Look for the element with class .fs-form-message or messageSelector
1008
- <div class="fs-form-message"></div>
1009
- <div class="fs-form-hint"></div> <-- Hint Selector. Look for the element with class .fs-form-hint or hintSelector
1010
- </div>
1011
- </mat-form-field>
1012
- */
1013
- render() {
1014
- if (this.ngControl) {
1015
- const renderer = this.renderer2;
1016
- const wrapper = this.getWrapperElement();
1017
- const error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
1018
- const shouldErrorBeRendered = this.ngControl.invalid
1019
- && (this.ngControl.dirty || this.formDirective?.ngForm?.submitted);
1020
- if (shouldErrorBeRendered && error) {
1021
- wrapper.classList.add('ng-invalid', 'ng-dirty');
1022
- }
1023
- else {
1024
- wrapper.classList.remove('ng-invalid');
1025
- }
1026
- if (!this.getMessageSelector()) {
1027
- return;
1028
- }
1029
- const messageWrapper = wrapper.querySelector(this.getMessageSelector());
1030
- if (!messageWrapper) {
1031
- return console.warn('Failed to locate ' + this.getMessageSelector(), this.elementRef.nativeElement);
1032
- }
1033
- if (this.getlabelSelector()) {
1034
- const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1035
- if (labelWrapper) {
1036
- if (this.appendLabelClass) {
1037
- this.renderer2.addClass(labelWrapper, this.appendLabelClass);
1038
- }
1039
- }
1040
- }
1041
- if (this.appendMessageClass) {
1042
- renderer.addClass(messageWrapper, this.appendMessageClass);
1043
- }
1044
- if (this.getHintWrapperSelector()) {
1045
- const hint = messageWrapper.querySelector(this.getHintWrapperSelector());
1046
- if (hint) {
1047
- renderer.setStyle(hint, 'display', error ? 'none' : 'block');
1048
- if (this.appendHintClass) {
1049
- renderer.addClass(hint, this.appendHintClass);
1050
- }
1051
- }
1052
- }
1053
- let errorWrapper = wrapper.querySelector('.fs-form-error-target');
1054
- if (errorWrapper) {
1055
- errorWrapper.remove();
1056
- }
1057
- if (!shouldErrorBeRendered || !error) {
1058
- return;
1059
- }
1060
- errorWrapper = renderer.createElement('div');
1061
- renderer.addClass(errorWrapper, 'fs-form-error-target');
1062
- renderer.addClass(errorWrapper, this.appendErrorClass);
1063
- renderer.addClass(errorWrapper, this.appendErrorClass + '-' + error.name);
1064
- const errorText = renderer.createText(error.message);
1065
- renderer.appendChild(errorWrapper, errorText);
1066
- messageWrapper.appendChild(errorWrapper);
1067
- }
973
+ resetActive() {
974
+ this.active = false;
1068
975
  }
1069
- getWrapper(node, count = 0) {
1070
- if (!node || count > 10) {
1071
- return null;
976
+ reset() {
977
+ if (!this._previousDisabled) {
978
+ this.enable();
1072
979
  }
1073
- if (node.parentNode && node.parentNode.querySelector(this.getWrapperSelector())) {
1074
- return node;
980
+ this.element.querySelectorAll('.svg-icon')
981
+ .forEach((el) => {
982
+ el.remove();
983
+ });
984
+ if (this._matButton) {
985
+ this._matButton.disableRipple = false;
1075
986
  }
1076
- return this.getWrapper(node.parentNode, ++count);
987
+ this._resetClass();
1077
988
  }
1078
- parseErrorMessage(message, args) {
1079
- values(args)
1080
- .forEach((name) => {
1081
- message = message.replace(/\$\(\d\)/, name);
1082
- });
1083
- return message;
989
+ ngOnDestroy() {
990
+ this._destroy$.next();
991
+ this._destroy$.complete();
992
+ this.form?.removeButton(this);
1084
993
  }
1085
- getError(controlRef) {
1086
- const name = keys(controlRef.control.errors)[0];
1087
- if (!name) {
1088
- return null;
1089
- }
1090
- let message = controlRef.control.errors[name];
1091
- if (this._validateMessages[name]) {
1092
- message = this.parseErrorMessage(this._validateMessages[name], message);
1093
- }
1094
- return { name: name, message: message };
994
+ _disableShadowAnimation() {
995
+ // .mat-elevation-z2 removes the click shadow animation
996
+ //this.element.classList.add('mat-elevation-z2');
1095
997
  }
1096
- _setupValidators() {
1097
- const control = this._control;
1098
- if (this.validate) {
1099
- const validators = control.validator
1100
- ? [control.validator, this.validate.bind(this)]
1101
- : this.validate.bind(this);
1102
- control.setValidators(validators);
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;
1103
1012
  }
1104
- if (this.validateAsync) {
1105
- const asyncValidators = control.asyncValidator
1106
- ? [control.asyncValidator, this.validateAsync.bind(this)]
1107
- : this.validateAsync.bind(this);
1108
- control.setAsyncValidators(asyncValidators);
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;
1109
1024
  }
1110
- control.updateValueAndValidity();
1111
1025
  }
1112
1026
  }
1113
- 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 });
1114
- 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: [
1115
- VALIDATE_MESSAGE_PROVIDER
1116
- ], ngImport: i0 });
1117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsControlDirective, decorators: [{
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: [{
1118
1030
  type: Directive,
1119
1031
  args: [{
1120
- selector: '[fsFormControl]',
1121
- providers: [
1122
- VALIDATE_MESSAGE_PROVIDER
1123
- ],
1032
+ selector: '[mat-raised-button]:not([fsFormButtonStandalone]),[mat-button]:not([fsFormButtonStandalone]),[mat-flat-button]:not([fsFormButtonStandalone]),[mat-stroked-button]:not([fsFormButtonStandalone])',
1124
1033
  }]
1125
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.Injector }, { type: undefined, decorators: [{
1126
- type: Self
1127
- }, {
1128
- type: Inject,
1129
- args: [VALIDATE_MESSAGES]
1130
- }] }, { type: i1$1.NgControl, decorators: [{
1034
+ }], ctorParameters: function () { return [{ type: i1$1.MatButton, decorators: [{
1131
1035
  type: Optional
1036
+ }, {
1037
+ type: Host
1132
1038
  }] }, { type: FsFormDirective, decorators: [{
1133
1039
  type: Optional
1134
- }, {
1135
- type: Inject,
1136
- args: [FsFormDirective]
1137
- }] }]; }, propDecorators: { wrapperSelector: [{
1138
- type: Input
1139
- }], messageSelector: [{
1140
- type: Input
1141
- }], hintSelector: [{
1142
- type: Input
1143
- }], labelSelector: [{
1144
- type: Input
1145
- }], appendMessageClass: [{
1146
- type: Input
1147
- }], appendLabelClass: [{
1148
- type: Input
1149
- }], appendErrorClass: [{
1040
+ }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
1150
1041
  type: Input
1151
- }], appendHintClass: [{
1042
+ }], dirtySubmit: [{
1152
1043
  type: Input
1153
- }], validateMessages: [{
1044
+ }], form: [{
1154
1045
  type: Input
1046
+ }], transitionStyle: [{
1047
+ type: HostBinding,
1048
+ args: ['style.transition']
1155
1049
  }] } });
1156
1050
 
1157
- function isEnabled(value) {
1158
- return value !== 'false' && (value || value === '');
1159
- }
1160
-
1161
- class FsFormRequiredDirective extends FsControlDirective {
1162
- constructor() {
1163
- super(...arguments);
1164
- this.required = false;
1165
- }
1166
- set setFsFormRequired(value) {
1167
- this.required = isEnabled(value);
1051
+ class FsFormDialogCloseDirective {
1052
+ constructor(_form, _dialogRef) {
1053
+ this._form = _form;
1054
+ this._dialogRef = _dialogRef;
1055
+ this.type = 'button';
1056
+ this._destroy$ = new Subject();
1168
1057
  }
1169
- set setRequired(value) {
1170
- this.required = isEnabled(value);
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
+ }
1171
1069
  }
1172
- set validationMessage(value) {
1173
- this._validateMessages.required = value;
1174
- }
1175
- ngOnChanges() {
1176
- this._control.updateValueAndValidity();
1177
- }
1178
- validate(control) {
1179
- if (this.required) {
1180
- return Validators.required(this._control);
1181
- }
1182
- else {
1183
- return null;
1184
- }
1185
- }
1186
- render() {
1187
- const wrapper = this.getWrapperElement();
1188
- if (wrapper && this.getlabelSelector()) {
1189
- const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1190
- // Adding class fs-form-label-requried adds the * to the label
1191
- if (labelWrapper) {
1192
- if (this.required) {
1193
- this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
1194
- }
1195
- else {
1196
- this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
1197
- }
1198
- }
1199
- }
1200
- super.render();
1070
+ ngOnDestroy() {
1071
+ this._destroy$.next();
1072
+ this._destroy$.complete();
1201
1073
  }
1202
1074
  }
1203
- FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1204
- 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: [
1205
- VALIDATE_MESSAGE_PROVIDER
1206
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1207
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
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: [{
1208
1078
  type: Directive,
1209
1079
  args: [{
1210
- selector: '[fsFormRequired],[ngModel][required]',
1211
- providers: [
1212
- VALIDATE_MESSAGE_PROVIDER
1213
- ],
1080
+ selector: '[fsFormDialogClose],[fs-form-dialog-close]',
1214
1081
  }]
1215
- }], propDecorators: { setFsFormRequired: [{
1216
- type: Input,
1217
- args: ['fsFormRequired']
1218
- }], setRequired: [{
1219
- type: Input,
1220
- args: ['required']
1221
- }], validationMessage: [{
1222
- type: Input,
1223
- args: ['fsFormRequiredMessage']
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']]
1224
1094
  }] } });
1225
1095
 
1226
- class FsValidators {
1227
- static email(control) {
1228
- if (!control.value || email(control.value)) {
1229
- return null;
1230
- }
1231
- return { email: true };
1232
- }
1233
- static emails(control) {
1234
- const model = control.value || '';
1235
- const hasInvalidEmails = model
1236
- .split(',')
1237
- .some((part) => !email(part));
1238
- return hasInvalidEmails ? { email: true } : null;
1239
- }
1240
- static numeric(control) {
1241
- if (isEmpty(control.value) || isNumeric(control.value)) {
1242
- return null;
1243
- }
1244
- else {
1245
- return { numeric: true };
1246
- }
1247
- }
1248
- static integer(control) {
1249
- if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1250
- return null;
1251
- }
1252
- else {
1253
- return { integer: true };
1254
- }
1255
- }
1256
- static phone(control) {
1257
- if (!control.value || phone(control.value)) {
1258
- return null;
1259
- }
1260
- return { phone: true };
1261
- }
1262
- static url(control, protocolRequired = false) {
1263
- if (!control.value) {
1264
- return null;
1265
- }
1266
- if (!url(control.value)) {
1267
- return { url: true };
1268
- }
1269
- if (protocolRequired) {
1270
- const pattern = new RegExp(/^http(s)?:\/\//gm);
1271
- if (!String(control.value).match(pattern)) {
1272
- return { urlProtocol: true };
1273
- }
1274
- }
1275
- return null;
1276
- }
1277
- static dateRange(control) {
1278
- if (!control.value) {
1279
- return null;
1280
- }
1281
- if (isObject(control.value)) {
1282
- const start = control.value.start;
1283
- const end = control.value.end;
1284
- if ((!start && !end) || (isValid(start) && isValid(end))) {
1285
- return null;
1286
- }
1287
- }
1288
- return { dateRange: true };
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();
1289
1108
  }
1290
- static func(control, formFunction, data) {
1291
- let result;
1292
- let stream$;
1293
- try {
1294
- result = formFunction(control, data);
1295
- }
1296
- catch (err) {
1297
- err = err instanceof Error ? err.message : err;
1298
- stream$ = throwError(err);
1299
- }
1300
- if (!stream$) {
1301
- if (result instanceof Promise) {
1302
- stream$ = from(result);
1303
- }
1304
- else if (isObservable(result)) {
1305
- stream$ = result;
1306
- }
1307
- else {
1308
- stream$ = of(null);
1309
- }
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
+ });
1310
1129
  }
1311
- return stream$
1312
- .pipe(mapTo(null), catchError((err) => {
1313
- return of({ validationError: err });
1314
- }), take(1));
1315
- }
1316
- }
1317
-
1318
- class FsFormMinDirective extends FsControlDirective {
1319
- set validationMessage(value) {
1320
- this._validateMessages.min = value;
1321
- }
1322
- ngOnChanges() {
1323
- this._control.updateValueAndValidity();
1324
1130
  }
1325
- validate(control) {
1326
- return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
1131
+ ngOnDestroy() {
1132
+ this._destroy$.next();
1133
+ this._destroy$.complete();
1327
1134
  }
1328
1135
  }
1329
- FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1330
- FsFormMinDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
1331
- VALIDATE_MESSAGE_PROVIDER
1332
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1333
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, decorators: [{
1334
- type: Directive,
1335
- args: [{
1336
- selector: '[fsFormMin]',
1337
- providers: [
1338
- VALIDATE_MESSAGE_PROVIDER
1339
- ],
1340
- }]
1341
- }], propDecorators: { fsFormMin: [{
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
+ FsFormDialogActionsComponentcmp = 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: [{
1342
1156
  type: Input
1343
- }], validationMessage: [{
1344
- type: Input,
1345
- args: ['fsFormMinMessage']
1346
1157
  }] } });
1347
1158
 
1348
- class FsFormMaxDirective extends FsControlDirective {
1349
- set validationMessage(value) {
1350
- this._validateMessages.max = value;
1351
- }
1352
- ngOnChanges() {
1353
- this._control.updateValueAndValidity();
1159
+ class FsFormTemplateComponent {
1160
+ constructor() { }
1161
+ ngAfterContentInit() {
1162
+ debugger;
1163
+ const x = this.models;
1164
+ this.models.changes.subscribe((x) => {
1165
+ debugger;
1166
+ });
1354
1167
  }
1355
- validate(control) {
1356
- return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1168
+ ngOnInit() {
1169
+ debugger;
1357
1170
  }
1358
1171
  }
1359
- FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1360
- FsFormMaxDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
1361
- VALIDATE_MESSAGE_PROVIDER
1362
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1363
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, decorators: [{
1364
- type: Directive,
1365
- args: [{
1366
- selector: '[fsFormMax]',
1367
- providers: [
1368
- VALIDATE_MESSAGE_PROVIDER
1369
- ],
1370
- }]
1371
- }], propDecorators: { fsFormMax: [{
1172
+ FsFormTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1173
+ FsFormTemplateComponentcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsFormTemplateComponent, selector: "fs-form-template", inputs: { formTemplate: "formTemplate" }, queries: [{ propertyName: "models", predicate: NgModel, descendants: true }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["templateRef1"], descendants: true }], ngImport: i0, template: "<ng-template #templateRef1>\n <ng-content></ng-content>\n</ng-template>", changeDetection: i0.ChangeDetectionStrategy.OnPush });
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: [{
1372
1181
  type: Input
1373
- }], validationMessage: [{
1374
- type: Input,
1375
- args: ['fsFormMaxMessage']
1182
+ }], models: [{
1183
+ type: ContentChildren,
1184
+ args: [NgModel, { descendants: true }]
1376
1185
  }] } });
1377
1186
 
1378
- class FsFormMinLengthDirective extends FsControlDirective {
1379
- set validationMessage(value) {
1380
- this._validateMessages.minlength = value;
1187
+ class FsFormTemplateOutletComponent {
1188
+ constructor() { }
1189
+ ngOnChanges(changes) {
1190
+ if (changes.formTemplate?.currentValue) {
1191
+ }
1381
1192
  }
1382
- ngOnChanges() {
1383
- this._control.updateValueAndValidity();
1193
+ ngAfterContentInit() {
1194
+ // const x = this.models;
1195
+ // this.models.changes.subscribe((x) => {
1196
+ // debugger;
1197
+ // });
1384
1198
  }
1385
- validate(control) {
1386
- return Validators.minLength(this.fsFormMinLength)(this._control);
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() {
1387
1215
  }
1388
1216
  }
1389
- FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1390
- FsFormMinLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
1391
- VALIDATE_MESSAGE_PROVIDER
1392
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1393
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
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: [{
1394
1220
  type: Directive,
1395
1221
  args: [{
1396
- selector: '[fsFormMinLength]',
1397
- providers: [
1398
- VALIDATE_MESSAGE_PROVIDER
1399
- ],
1222
+ selector: '[fsFormTemplate]',
1400
1223
  }]
1401
- }], propDecorators: { fsFormMinLength: [{
1402
- type: Input
1403
- }], validationMessage: [{
1404
- type: Input,
1405
- args: ['fsFormMinLengthMessage']
1224
+ }], ctorParameters: function () { return []; }, propDecorators: { models: [{
1225
+ type: ViewChildren,
1226
+ args: [NgModel]
1406
1227
  }] } });
1407
1228
 
1408
- class FsFormMaxLengthDirective extends FsControlDirective {
1409
- set validationMessage(value) {
1410
- this._validateMessages.maxlength = value;
1411
- }
1412
- ngOnChanges() {
1413
- this._control.updateValueAndValidity();
1414
- }
1415
- validate(control) {
1416
- return Validators.maxLength(this.fsFormMaxLength)(this._control);
1417
- }
1229
+ class FsSubmitButtonDirective extends FsButtonDirective {
1418
1230
  }
1419
- FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1420
- FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
1421
- VALIDATE_MESSAGE_PROVIDER
1422
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1423
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
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: [{
1424
1234
  type: Directive,
1425
1235
  args: [{
1426
- selector: '[fsFormMaxLength]',
1427
- providers: [
1428
- VALIDATE_MESSAGE_PROVIDER
1429
- ],
1236
+ selector: 'dummy-selector',
1430
1237
  }]
1431
- }], propDecorators: { fsFormMaxLength: [{
1432
- type: Input
1433
- }], validationMessage: [{
1434
- type: Input,
1435
- args: ['fsFormMaxLengthMessage']
1436
- }] } });
1238
+ }] });
1437
1239
 
1438
- class FsFormEmailDirective extends FsControlDirective {
1439
- set validationMessage(value) {
1440
- this._validateMessages.email = value;
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
+ }
1441
1291
  }
1442
- ngOnChanges() {
1443
- this._control.updateValueAndValidity();
1292
+ set validateMessages(messages) {
1293
+ this._validateMessages = {
1294
+ ...this._validateMessages,
1295
+ ...messages,
1296
+ };
1444
1297
  }
1445
- validate(control) {
1446
- if (isEnabled(this.fsFormEmail)) {
1447
- return FsValidators.email(this._control);
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 '';
1448
1311
  }
1449
- else {
1450
- return null;
1312
+ if (this.messageSelector) {
1313
+ return this.messageSelector;
1314
+ }
1315
+ else if (this.formDirective?.messageSelector) {
1316
+ return this.formDirective.messageSelector;
1451
1317
  }
1452
1318
  }
1453
- }
1454
- FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1455
- FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
1456
- VALIDATE_MESSAGE_PROVIDER
1457
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1458
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1459
- type: Directive,
1460
- args: [{
1461
- selector: '[fsFormEmail]',
1462
- providers: [
1463
- VALIDATE_MESSAGE_PROVIDER
1464
- ],
1465
- }]
1466
- }], propDecorators: { fsFormEmail: [{
1467
- type: Input
1468
- }], validationMessage: [{
1469
- type: Input,
1470
- args: ['fsFormEmailMessage']
1471
- }] } });
1472
-
1473
- class FsFormEmailsDirective extends FsControlDirective {
1474
- set validationMessage(value) {
1475
- this._validateMessages.emails = value;
1319
+ getHintWrapperSelector() {
1320
+ if (this.hintSelector === false) {
1321
+ return '';
1322
+ }
1323
+ if (this.hintSelector) {
1324
+ return this.hintSelector;
1325
+ }
1326
+ else if (this.formDirective?.hintSelector) {
1327
+ return this.formDirective.hintSelector;
1328
+ }
1476
1329
  }
1477
- ngOnChanges() {
1478
- this._control.updateValueAndValidity();
1330
+ getWrapperSelector() {
1331
+ if (this.wrapperSelector === false) {
1332
+ return '';
1333
+ }
1334
+ if (this.wrapperSelector) {
1335
+ return this.wrapperSelector;
1336
+ }
1337
+ else if (this.formDirective?.wrapperSelector) {
1338
+ return this.formDirective.wrapperSelector;
1339
+ }
1479
1340
  }
1480
- validate(control) {
1481
- if (isEnabled(this.fsFormEmails)) {
1482
- return FsValidators.emails(this._control);
1341
+ getlabelSelector() {
1342
+ if (this.labelSelector === false) {
1343
+ return '';
1344
+ }
1345
+ if (this.labelSelector) {
1346
+ return this.labelSelector;
1347
+ }
1348
+ else if (this.formDirective?.labelSelector) {
1349
+ return this.formDirective.labelSelector;
1350
+ }
1351
+ }
1352
+ getWrapperElement() {
1353
+ const wrapper = this.getWrapper(this._elementRef.nativeElement);
1354
+ if (wrapper) {
1355
+ return wrapper;
1356
+ }
1357
+ return this._elementRef.nativeElement;
1358
+ }
1359
+ /*
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.
1361
+ <input>
1362
+ <div class="fs-form-message"> <-- Message Selector. Look for the element with class .fs-form-message or messageSelector
1363
+ <div class="fs-form-message"></div>
1364
+ <div class="fs-form-hint"></div> <-- Hint Selector. Look for the element with class .fs-form-hint or hintSelector
1365
+ </div>
1366
+ </mat-form-field>
1367
+ */
1368
+ render() {
1369
+ if (this.ngControl) {
1370
+ const renderer = this.renderer2;
1371
+ const wrapper = this.getWrapperElement();
1372
+ const error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
1373
+ const shouldErrorBeRendered = this.ngControl.invalid
1374
+ && (this.ngControl.dirty || this.formDirective?.ngForm?.submitted);
1375
+ if (shouldErrorBeRendered && error) {
1376
+ wrapper.classList.add('ng-invalid', 'ng-dirty');
1377
+ }
1378
+ else {
1379
+ wrapper.classList.remove('ng-invalid');
1380
+ }
1381
+ if (!this.getMessageSelector()) {
1382
+ return;
1383
+ }
1384
+ const messageWrapper = wrapper.querySelector(this.getMessageSelector());
1385
+ if (!messageWrapper) {
1386
+ return console.warn(`Failed to locate ${this.getMessageSelector()}`, this._elementRef.nativeElement);
1387
+ }
1388
+ if (this.getlabelSelector()) {
1389
+ const labelWrapper = wrapper.querySelector(this.getlabelSelector());
1390
+ if (labelWrapper) {
1391
+ if (this.appendLabelClass) {
1392
+ this.renderer2.addClass(labelWrapper, this.appendLabelClass);
1393
+ }
1394
+ }
1395
+ }
1396
+ if (this.appendMessageClass) {
1397
+ renderer.addClass(messageWrapper, this.appendMessageClass);
1398
+ }
1399
+ if (this.getHintWrapperSelector()) {
1400
+ const hint = messageWrapper.querySelector(this.getHintWrapperSelector());
1401
+ if (hint) {
1402
+ renderer.setStyle(hint, 'display', error ? 'none' : 'block');
1403
+ if (this.appendHintClass) {
1404
+ renderer.addClass(hint, this.appendHintClass);
1405
+ }
1406
+ }
1407
+ }
1408
+ let errorWrapper = wrapper.querySelector('.fs-form-error-target');
1409
+ if (errorWrapper) {
1410
+ errorWrapper.remove();
1411
+ }
1412
+ if (!shouldErrorBeRendered || !error) {
1413
+ return;
1414
+ }
1415
+ errorWrapper = renderer.createElement('div');
1416
+ renderer.addClass(errorWrapper, 'fs-form-error-target');
1417
+ renderer.addClass(errorWrapper, this.appendErrorClass);
1418
+ renderer.addClass(errorWrapper, `${this.appendErrorClass}-${error.name}`);
1419
+ const errorText = renderer.createText(error.message);
1420
+ renderer.appendChild(errorWrapper, errorText);
1421
+ messageWrapper.appendChild(errorWrapper);
1422
+ }
1423
+ }
1424
+ _subscribeToStatusChagnes() {
1425
+ if (this._control) {
1426
+ this._control.statusChanges
1427
+ .pipe(takeUntil(this._destroy$))
1428
+ .subscribe(this.render.bind(this));
1483
1429
  }
1484
- else {
1430
+ }
1431
+ getWrapper(node, count = 0) {
1432
+ if (!node || count > 10) {
1485
1433
  return null;
1486
1434
  }
1435
+ if (node.parentNode && node.parentNode.querySelector(this.getWrapperSelector())) {
1436
+ return node;
1437
+ }
1438
+ return this.getWrapper(node.parentNode, ++count);
1487
1439
  }
1488
- }
1489
- FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1490
- FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
1491
- VALIDATE_MESSAGE_PROVIDER
1492
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1493
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1494
- type: Directive,
1495
- args: [{
1496
- selector: '[fsFormEmails]',
1497
- providers: [
1498
- VALIDATE_MESSAGE_PROVIDER
1499
- ],
1500
- }]
1501
- }], propDecorators: { fsFormEmails: [{
1502
- type: Input
1503
- }], validationMessage: [{
1504
- type: Input,
1505
- args: ['fsFormEmailsMessage']
1506
- }] } });
1507
-
1508
- class FsFormPhoneDirective extends FsControlDirective {
1509
- set validationMessage(value) {
1510
- this._validateMessages.phone = value;
1440
+ parseErrorMessage(message, args) {
1441
+ values(args)
1442
+ .forEach((name) => {
1443
+ message = message.replace(/\$\(\d\)/, name);
1444
+ });
1445
+ return message;
1511
1446
  }
1512
- ngOnChanges() {
1513
- this._control.updateValueAndValidity();
1447
+ getError(controlRef) {
1448
+ const name = keys(controlRef.control.errors)[0];
1449
+ if (!name) {
1450
+ return null;
1451
+ }
1452
+ let message = controlRef.control.errors[name];
1453
+ if (this._validateMessages[name]) {
1454
+ message = this.parseErrorMessage(this._validateMessages[name], message);
1455
+ }
1456
+ return { name: name, message: message };
1514
1457
  }
1515
- validate(control) {
1516
- if (isEnabled(this.fsFormPhone)) {
1517
- return FsValidators.phone(this._control);
1458
+ _setupValidators() {
1459
+ const control = this._control;
1460
+ if (this.validate) {
1461
+ const validators = control.validator
1462
+ ? [control.validator, this.validate.bind(this)]
1463
+ : this.validate.bind(this);
1464
+ control.setValidators(validators);
1518
1465
  }
1519
- else {
1520
- return null;
1466
+ if (this.validateAsync) {
1467
+ const asyncValidators = control.asyncValidator
1468
+ ? [control.asyncValidator, this.validateAsync.bind(this)]
1469
+ : this.validateAsync.bind(this);
1470
+ control.setAsyncValidators(asyncValidators);
1521
1471
  }
1472
+ control.updateValueAndValidity();
1522
1473
  }
1523
1474
  }
1524
- FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1525
- FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
1526
- VALIDATE_MESSAGE_PROVIDER
1527
- ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1528
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
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 });
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: [
1477
+ VALIDATE_MESSAGE_PROVIDER,
1478
+ ], ngImport: i0 });
1479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsControlDirective, decorators: [{
1529
1480
  type: Directive,
1530
1481
  args: [{
1531
- selector: '[fsFormPhone]',
1482
+ selector: '[fsFormControl]',
1532
1483
  providers: [
1533
- VALIDATE_MESSAGE_PROVIDER
1484
+ VALIDATE_MESSAGE_PROVIDER,
1534
1485
  ],
1535
1486
  }]
1536
- }], propDecorators: { fsFormPhone: [{
1487
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.Injector }, { type: undefined, decorators: [{
1488
+ type: Self
1489
+ }, {
1490
+ type: Inject,
1491
+ args: [VALIDATE_MESSAGES]
1492
+ }] }, { type: i1$2.NgControl, decorators: [{
1493
+ type: Optional
1494
+ }] }, { type: FsFormDirective, decorators: [{
1495
+ type: Optional
1496
+ }, {
1497
+ type: Inject,
1498
+ args: [FsFormDirective]
1499
+ }] }]; }, propDecorators: { wrapperSelector: [{
1500
+ type: Input
1501
+ }], messageSelector: [{
1502
+ type: Input
1503
+ }], hintSelector: [{
1504
+ type: Input
1505
+ }], labelSelector: [{
1506
+ type: Input
1507
+ }], appendMessageClass: [{
1508
+ type: Input
1509
+ }], appendLabelClass: [{
1510
+ type: Input
1511
+ }], appendErrorClass: [{
1512
+ type: Input
1513
+ }], appendHintClass: [{
1514
+ type: Input
1515
+ }], validateMessages: [{
1537
1516
  type: Input
1538
- }], validationMessage: [{
1539
- type: Input,
1540
- args: ['fsFormPhoneMessage']
1541
1517
  }] } });
1542
1518
 
1543
1519
  class FsFormCompareDirective extends FsControlDirective {
@@ -1548,12 +1524,10 @@ class FsFormCompareDirective extends FsControlDirective {
1548
1524
  this._control.updateValueAndValidity();
1549
1525
  }
1550
1526
  validate(control) {
1551
- if (this.fsFormCompare.value === this.elementRef.nativeElement.value) {
1527
+ if (this.fsFormCompare.value === this._elementRef.nativeElement.value) {
1552
1528
  return null;
1553
1529
  }
1554
- else {
1555
- return { compare: true };
1556
- }
1530
+ return { compare: true };
1557
1531
  }
1558
1532
  ngAfterViewInit() {
1559
1533
  this.fsFormCompare.addEventListener('keyup', () => {
@@ -1585,104 +1559,205 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1585
1559
  args: ['fsFormCompareMessage']
1586
1560
  }] } });
1587
1561
 
1588
- class FsFormIntegerDirective extends FsControlDirective {
1562
+ class FsValidators {
1563
+ static email(control) {
1564
+ if (!control.value || email(control.value)) {
1565
+ return null;
1566
+ }
1567
+ return { email: true };
1568
+ }
1569
+ static emails(control) {
1570
+ const model = control.value || '';
1571
+ const hasInvalidEmails = model
1572
+ .split(',')
1573
+ .some((part) => !email(part));
1574
+ return hasInvalidEmails ? { email: true } : null;
1575
+ }
1576
+ static numeric(control) {
1577
+ if (isEmpty(control.value) || isNumeric(control.value)) {
1578
+ return null;
1579
+ }
1580
+ else {
1581
+ return { numeric: true };
1582
+ }
1583
+ }
1584
+ static integer(control) {
1585
+ if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1586
+ return null;
1587
+ }
1588
+ else {
1589
+ return { integer: true };
1590
+ }
1591
+ }
1592
+ static phone(control) {
1593
+ if (!control.value || phone(control.value)) {
1594
+ return null;
1595
+ }
1596
+ return { phone: true };
1597
+ }
1598
+ static url(control, protocolRequired = false) {
1599
+ if (!control.value) {
1600
+ return null;
1601
+ }
1602
+ if (!url(control.value)) {
1603
+ return { url: true };
1604
+ }
1605
+ if (protocolRequired) {
1606
+ const pattern = new RegExp(/^http(s)?:\/\//gm);
1607
+ if (!String(control.value).match(pattern)) {
1608
+ return { urlProtocol: true };
1609
+ }
1610
+ }
1611
+ return null;
1612
+ }
1613
+ static dateRange(control) {
1614
+ if (!control.value) {
1615
+ return null;
1616
+ }
1617
+ if (isObject(control.value)) {
1618
+ const start = control.value.start;
1619
+ const end = control.value.end;
1620
+ if ((!start && !end) || (isValid(start) && isValid(end))) {
1621
+ return null;
1622
+ }
1623
+ }
1624
+ return { dateRange: true };
1625
+ }
1626
+ static func(control, formFunction, data) {
1627
+ let result;
1628
+ let stream$;
1629
+ try {
1630
+ result = formFunction(control, data);
1631
+ }
1632
+ catch (err) {
1633
+ err = err instanceof Error ? err.message : err;
1634
+ stream$ = throwError(err);
1635
+ }
1636
+ if (!stream$) {
1637
+ if (result instanceof Promise) {
1638
+ stream$ = from(result);
1639
+ }
1640
+ else if (isObservable(result)) {
1641
+ stream$ = result;
1642
+ }
1643
+ else {
1644
+ stream$ = of(null);
1645
+ }
1646
+ }
1647
+ return stream$
1648
+ .pipe(mapTo(null), catchError((err) => {
1649
+ return of({ validationError: err });
1650
+ }), take(1));
1651
+ }
1652
+ }
1653
+
1654
+ function isEnabled(value) {
1655
+ return value !== 'false' && (value || value === '');
1656
+ }
1657
+
1658
+ class FsFormDateRangeDirective extends FsControlDirective {
1589
1659
  set validationMessage(value) {
1590
- this._validateMessages.integer = value;
1660
+ this._validateMessages.dateRange = value;
1591
1661
  }
1592
1662
  ngOnChanges() {
1593
1663
  this._control.updateValueAndValidity();
1594
1664
  }
1595
1665
  validate(control) {
1596
- if (isEnabled(this.fsFormInteger)) {
1597
- return FsValidators.integer(this._control);
1666
+ if (isEnabled(this.fsFormDateRange)) {
1667
+ return FsValidators.dateRange(this._control);
1598
1668
  }
1599
1669
  else {
1600
1670
  return null;
1601
1671
  }
1602
1672
  }
1603
1673
  }
1604
- FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1605
- FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "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: [
1606
1676
  VALIDATE_MESSAGE_PROVIDER
1607
1677
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1608
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1678
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1609
1679
  type: Directive,
1610
1680
  args: [{
1611
- selector: '[fsFormInteger]',
1681
+ selector: '[fsFormDateRange]',
1612
1682
  providers: [
1613
1683
  VALIDATE_MESSAGE_PROVIDER
1614
1684
  ],
1615
1685
  }]
1616
- }], propDecorators: { fsFormInteger: [{
1686
+ }], propDecorators: { fsFormDateRange: [{
1617
1687
  type: Input
1618
1688
  }], validationMessage: [{
1619
1689
  type: Input,
1620
- args: ['fsFormIntegerMessage']
1690
+ args: ['fsFormDateRangeMessage']
1621
1691
  }] } });
1622
1692
 
1623
- class FsFormNumericDirective extends FsControlDirective {
1693
+ class FsFormEmailDirective extends FsControlDirective {
1624
1694
  set validationMessage(value) {
1625
- this._validateMessages.numeric = value;
1695
+ this._validateMessages.email = value;
1626
1696
  }
1627
1697
  ngOnChanges() {
1628
1698
  this._control.updateValueAndValidity();
1629
1699
  }
1630
1700
  validate(control) {
1631
- if (isEnabled(this.fsFormNumeric)) {
1632
- return FsValidators.numeric(this._control);
1701
+ if (isEnabled(this.fsFormEmail)) {
1702
+ return FsValidators.email(this._control);
1633
1703
  }
1634
1704
  else {
1635
1705
  return null;
1636
1706
  }
1637
1707
  }
1638
1708
  }
1639
- FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1640
- FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "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: [
1641
1711
  VALIDATE_MESSAGE_PROVIDER
1642
1712
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1643
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
1713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1644
1714
  type: Directive,
1645
1715
  args: [{
1646
- selector: '[fsFormNumeric]',
1716
+ selector: '[fsFormEmail]',
1647
1717
  providers: [
1648
1718
  VALIDATE_MESSAGE_PROVIDER
1649
1719
  ],
1650
1720
  }]
1651
- }], propDecorators: { fsFormNumeric: [{
1721
+ }], propDecorators: { fsFormEmail: [{
1652
1722
  type: Input
1653
1723
  }], validationMessage: [{
1654
1724
  type: Input,
1655
- args: ['fsFormNumericMessage']
1725
+ args: ['fsFormEmailMessage']
1656
1726
  }] } });
1657
1727
 
1658
- class FsFormPatternDirective extends FsControlDirective {
1728
+ class FsFormEmailsDirective extends FsControlDirective {
1659
1729
  set validationMessage(value) {
1660
- this._validateMessages.pattern = value;
1730
+ this._validateMessages.emails = value;
1661
1731
  }
1662
1732
  ngOnChanges() {
1663
1733
  this._control.updateValueAndValidity();
1664
1734
  }
1665
1735
  validate(control) {
1666
- return Validators.pattern(this.fsFormPattern)(this._control);
1736
+ if (isEnabled(this.fsFormEmails)) {
1737
+ return FsValidators.emails(this._control);
1738
+ }
1739
+ else {
1740
+ return null;
1741
+ }
1667
1742
  }
1668
1743
  }
1669
- FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1670
- FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "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: [
1671
1746
  VALIDATE_MESSAGE_PROVIDER
1672
1747
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1673
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
1748
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1674
1749
  type: Directive,
1675
1750
  args: [{
1676
- selector: '[fsFormPattern]',
1751
+ selector: '[fsFormEmails]',
1677
1752
  providers: [
1678
1753
  VALIDATE_MESSAGE_PROVIDER
1679
1754
  ],
1680
1755
  }]
1681
- }], propDecorators: { fsFormPattern: [{
1756
+ }], propDecorators: { fsFormEmails: [{
1682
1757
  type: Input
1683
1758
  }], validationMessage: [{
1684
1759
  type: Input,
1685
- args: ['fsFormPatternMessage']
1760
+ args: ['fsFormEmailsMessage']
1686
1761
  }] } });
1687
1762
 
1688
1763
  class FsFormFunctionDirective extends FsControlDirective {
@@ -1702,14 +1777,14 @@ class FsFormFunctionDirective extends FsControlDirective {
1702
1777
  }
1703
1778
  FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1704
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: [
1705
- VALIDATE_MESSAGE_PROVIDER
1780
+ VALIDATE_MESSAGE_PROVIDER,
1706
1781
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1707
1782
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
1708
1783
  type: Directive,
1709
1784
  args: [{
1710
1785
  selector: '[fsFormFunction]',
1711
1786
  providers: [
1712
- VALIDATE_MESSAGE_PROVIDER
1787
+ VALIDATE_MESSAGE_PROVIDER,
1713
1788
  ],
1714
1789
  }]
1715
1790
  }], propDecorators: { fsFormFunction: [{
@@ -1720,7 +1795,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1720
1795
  type: Input
1721
1796
  }] } });
1722
1797
 
1723
- class FsFormGreaterDirective extends FsControlDirective {
1798
+ class FsFormGreaterEqualDirective extends FsControlDirective {
1724
1799
  set validationMessage(value) {
1725
1800
  this._validateMessages.greater = value;
1726
1801
  }
@@ -1728,445 +1803,289 @@ class FsFormGreaterDirective extends FsControlDirective {
1728
1803
  this._control.updateValueAndValidity();
1729
1804
  }
1730
1805
  validate(control) {
1731
- const greater = parseFloat(this.fsFormGreater);
1806
+ const greater = parseFloat(this.fsFormGreaterEqual);
1732
1807
  const value = parseFloat(this._control.value);
1733
- if (!isNaN(greater) && !isNaN(value) && value <= greater) {
1734
- return { greater: { greater, actual: value } };
1808
+ if (!isNaN(greater) && !isNaN(value) && value < greater) {
1809
+ return { greaterEqual: { greater, actual: value } };
1735
1810
  }
1736
1811
  return FsValidators.numeric(this._control);
1737
1812
  }
1738
1813
  }
1739
- FsFormGreaterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1740
- FsFormGreaterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterDirective, selector: "[fsFormGreater]", inputs: { fsFormGreater: "fsFormGreater", validationMessage: ["fsFormGreaterMessage", "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: [
1741
1816
  VALIDATE_MESSAGE_PROVIDER
1742
1817
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1743
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
1818
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, decorators: [{
1744
1819
  type: Directive,
1745
1820
  args: [{
1746
- selector: '[fsFormGreater]',
1821
+ selector: '[fsFormGreaterEqual]',
1747
1822
  providers: [
1748
1823
  VALIDATE_MESSAGE_PROVIDER
1749
1824
  ],
1750
1825
  }]
1751
- }], propDecorators: { fsFormGreater: [{
1826
+ }], propDecorators: { fsFormGreaterEqual: [{
1752
1827
  type: Input
1753
1828
  }], validationMessage: [{
1754
1829
  type: Input,
1755
- args: ['fsFormGreaterMessage']
1830
+ args: ['fsFormGreaterEqualMessage']
1756
1831
  }] } });
1757
1832
 
1758
- class FsFormDateRangeDirective extends FsControlDirective {
1833
+ class FsFormGreaterDirective extends FsControlDirective {
1759
1834
  set validationMessage(value) {
1760
- this._validateMessages.dateRange = value;
1835
+ this._validateMessages.greater = value;
1761
1836
  }
1762
1837
  ngOnChanges() {
1763
1838
  this._control.updateValueAndValidity();
1764
1839
  }
1765
1840
  validate(control) {
1766
- if (isEnabled(this.fsFormDateRange)) {
1767
- return FsValidators.dateRange(this._control);
1768
- }
1769
- else {
1770
- 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 } };
1771
1845
  }
1846
+ return FsValidators.numeric(this._control);
1772
1847
  }
1773
1848
  }
1774
- FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1775
- FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "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: [
1776
1851
  VALIDATE_MESSAGE_PROVIDER
1777
1852
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1778
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
1779
1854
  type: Directive,
1780
1855
  args: [{
1781
- selector: '[fsFormDateRange]',
1856
+ selector: '[fsFormGreater]',
1782
1857
  providers: [
1783
1858
  VALIDATE_MESSAGE_PROVIDER
1784
1859
  ],
1785
1860
  }]
1786
- }], propDecorators: { fsFormDateRange: [{
1861
+ }], propDecorators: { fsFormGreater: [{
1787
1862
  type: Input
1788
1863
  }], validationMessage: [{
1789
1864
  type: Input,
1790
- args: ['fsFormDateRangeMessage']
1865
+ args: ['fsFormGreaterMessage']
1791
1866
  }] } });
1792
1867
 
1793
- class FsFormLesserDirective extends FsControlDirective {
1868
+ class FsFormIntegerDirective extends FsControlDirective {
1794
1869
  set validationMessage(value) {
1795
- this._validateMessages.lesser = value;
1870
+ this._validateMessages.integer = value;
1796
1871
  }
1797
1872
  ngOnChanges() {
1798
1873
  this._control.updateValueAndValidity();
1799
1874
  }
1800
1875
  validate(control) {
1801
- const lesser = parseFloat(this.fsFormLesser);
1802
- const value = parseFloat(this._control.value);
1803
- if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1804
- return { lesser: { lesser, actual: value } };
1876
+ if (isEnabled(this.fsFormInteger)) {
1877
+ return FsValidators.integer(this._control);
1805
1878
  }
1806
- return FsValidators.numeric(this._control);
1879
+ return null;
1807
1880
  }
1808
1881
  }
1809
- FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1810
- FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
1811
- 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,
1812
1885
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1813
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1886
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1814
1887
  type: Directive,
1815
1888
  args: [{
1816
- selector: '[fsFormLesser]',
1889
+ selector: '[fsFormInteger]',
1817
1890
  providers: [
1818
- VALIDATE_MESSAGE_PROVIDER
1891
+ VALIDATE_MESSAGE_PROVIDER,
1819
1892
  ],
1820
1893
  }]
1821
- }], propDecorators: { fsFormLesser: [{
1894
+ }], propDecorators: { fsFormInteger: [{
1822
1895
  type: Input
1823
1896
  }], validationMessage: [{
1824
1897
  type: Input,
1825
- args: ['fsFormLesserMessage']
1898
+ args: ['fsFormIntegerMessage']
1826
1899
  }] } });
1827
1900
 
1828
- class FsFormUrlDirective extends FsControlDirective {
1829
- constructor() {
1830
- super(...arguments);
1831
- this.fsFormUrlProtocol = false;
1832
- }
1901
+ class FsFormLesserEqualDirective extends FsControlDirective {
1833
1902
  set validationMessage(value) {
1834
- this._validateMessages.url = value;
1903
+ this._validateMessages.lesser = value;
1835
1904
  }
1836
1905
  ngOnChanges() {
1837
1906
  this._control.updateValueAndValidity();
1838
1907
  }
1839
1908
  validate(control) {
1840
- if (isEnabled(this.fsFormUrl)) {
1841
- return FsValidators.url(this._control, this.fsFormUrlProtocol);
1842
- }
1843
- else {
1844
- 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 } };
1845
1913
  }
1914
+ return FsValidators.numeric(this._control);
1846
1915
  }
1847
1916
  }
1848
- FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1849
- 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: [
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: [
1850
1919
  VALIDATE_MESSAGE_PROVIDER
1851
1920
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1852
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, decorators: [{
1921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, decorators: [{
1853
1922
  type: Directive,
1854
1923
  args: [{
1855
- selector: '[fsFormUrl]',
1924
+ selector: '[fsFormLesserEqual]',
1856
1925
  providers: [
1857
1926
  VALIDATE_MESSAGE_PROVIDER
1858
1927
  ],
1859
1928
  }]
1860
- }], propDecorators: { fsFormUrl: [{
1861
- type: Input
1862
- }], fsFormUrlProtocol: [{
1929
+ }], propDecorators: { fsFormLesserEqual: [{
1863
1930
  type: Input
1864
1931
  }], validationMessage: [{
1865
1932
  type: Input,
1866
- args: ['fsFormUrlMessage']
1867
- }] } });
1868
-
1869
- class FsFormDialogCloseDirective {
1870
- constructor(_form, _dialogRef) {
1871
- this._form = _form;
1872
- this._dialogRef = _dialogRef;
1873
- this._destroy$ = new Subject();
1874
- this.type = 'button';
1875
- }
1876
- closeClick() {
1877
- if (this._form) {
1878
- this._form.triggerConfirm()
1879
- .pipe(filter((confirmResult) => (confirmResult !== ConfirmResult.Review)), takeUntil(this._destroy$))
1880
- .subscribe(() => {
1881
- this._dialogRef.close(this.closeData);
1882
- });
1883
- }
1884
- else {
1885
- this._dialogRef.close(this.closeData);
1886
- }
1887
- }
1888
- ngOnDestroy() {
1889
- this._destroy$.next();
1890
- this._destroy$.complete();
1891
- }
1892
- }
1893
- 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 });
1894
- 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 });
1895
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
1896
- type: Directive,
1897
- args: [{
1898
- selector: '[fsFormDialogClose],[fs-form-dialog-close]'
1899
- }]
1900
- }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
1901
- type: Optional
1902
- }] }, { type: i2$1.MatDialogRef, decorators: [{
1903
- type: Optional
1904
- }] }]; }, propDecorators: { closeData: [{
1905
- type: Input
1906
- }], type: [{
1907
- type: HostBinding,
1908
- args: ['attr.type']
1909
- }], closeClick: [{
1910
- type: HostListener,
1911
- args: ['click', ['$event.target']]
1933
+ args: ['fsFormLesserEqualMessage']
1912
1934
  }] } });
1913
1935
 
1914
- class FsButtonDirective {
1915
- constructor(_matButton, _form, _elementRef, _cdRef) {
1916
- this._matButton = _matButton;
1917
- this._form = _form;
1918
- this._elementRef = _elementRef;
1919
- this._cdRef = _cdRef;
1920
- this.dirtySubmit = true;
1921
- this.transitionStyle = null;
1922
- this.active = false;
1923
- this.submit = false;
1924
- this._previousDisabled = false;
1925
- this._destroy$ = new Subject();
1926
- }
1927
- ngOnInit() {
1928
- this.submit = this._elementRef.nativeElement.getAttribute('type') === 'submit';
1929
- this.form = this.form || this._form;
1930
- if (this.form) {
1931
- this.form.addButton(this);
1932
- if (this.submit) {
1933
- fromEvent(this.element, 'click')
1934
- .pipe(takeUntil(this._destroy$))
1935
- .subscribe(() => {
1936
- this.active = true;
1937
- });
1938
- if (this.dirtySubmit) {
1939
- if (this.form.dirtySubmitButton) {
1940
- if (!this.form.ngForm.dirty) {
1941
- this.disable();
1942
- }
1943
- }
1944
- }
1945
- this.transitionStyle = 'none';
1946
- setTimeout(() => {
1947
- this.transitionStyle = null;
1948
- }, 500);
1949
- }
1950
- }
1951
- }
1952
- disable() {
1953
- if (this._matButton && !this.active) {
1954
- this._previousDisabled = this._matButton.disabled;
1955
- this._matButton.disabled = true;
1956
- this._cdRef.markForCheck();
1957
- }
1958
- }
1959
- enable() {
1960
- if (this._matButton) {
1961
- this._matButton.disabled = false;
1962
- this._matButton.disableRipple = true;
1963
- this._cdRef.markForCheck();
1964
- }
1965
- }
1966
- process() {
1967
- this.setClass('process');
1968
- if (this._matButton) {
1969
- this._matButton.disableRipple = true;
1970
- }
1971
- }
1972
- success() {
1973
- this.setClass('success');
1974
- if (this._matButton) {
1975
- this._matButton.disableRipple = false;
1976
- }
1977
- }
1978
- error() {
1979
- this.setClass('error');
1980
- if (this._matButton) {
1981
- this._matButton.disableRipple = false;
1982
- }
1983
- }
1984
- setClass(cls) {
1985
- const svg = this._getSvg(cls);
1986
- this._resetClass();
1987
- this._disableShadowAnimation();
1988
- this.element.classList.add(`submit-${cls}`);
1989
- this.element.append(svg);
1990
- }
1991
- get element() {
1992
- return this._elementRef.nativeElement;
1936
+ class FsFormLesserDirective extends FsControlDirective {
1937
+ set validationMessage(value) {
1938
+ this._validateMessages.lesser = value;
1993
1939
  }
1994
- resetActive() {
1995
- this.active = false;
1940
+ ngOnChanges() {
1941
+ this._control.updateValueAndValidity();
1996
1942
  }
1997
- reset() {
1998
- if (!this._previousDisabled) {
1999
- this.enable();
2000
- }
2001
- this.element.querySelectorAll('.svg-icon')
2002
- .forEach((el) => {
2003
- el.remove();
2004
- });
2005
- if (this._matButton) {
2006
- this._matButton.disableRipple = false;
1943
+ validate(control) {
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 } };
2007
1948
  }
2008
- this._resetClass();
2009
- }
2010
- ngOnDestroy() {
2011
- this._destroy$.next();
2012
- this._destroy$.complete();
2013
- this.form?.removeButton(this);
1949
+ return FsValidators.numeric(this._control);
2014
1950
  }
2015
- _disableShadowAnimation() {
2016
- // .mat-elevation-z2 removes the click shadow animation
2017
- //this.element.classList.add('mat-elevation-z2');
1951
+ }
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
1955
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1956
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1957
+ type: Directive,
1958
+ args: [{
1959
+ selector: '[fsFormLesser]',
1960
+ providers: [
1961
+ VALIDATE_MESSAGE_PROVIDER
1962
+ ],
1963
+ }]
1964
+ }], propDecorators: { fsFormLesser: [{
1965
+ type: Input
1966
+ }], validationMessage: [{
1967
+ type: Input,
1968
+ args: ['fsFormLesserMessage']
1969
+ }] } });
1970
+
1971
+ class FsFormMaxDirective extends FsControlDirective {
1972
+ set validationMessage(value) {
1973
+ this._validateMessages.max = value;
2018
1974
  }
2019
- _resetClass() {
2020
- this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
1975
+ ngOnChanges() {
1976
+ this._control.updateValueAndValidity();
2021
1977
  }
2022
- _getSvg(type) {
2023
- if (type === 'success') {
2024
- 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">
2025
- <g>
2026
- <g class="check">
2027
- <g>
2028
- <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"/>
2029
- </g>
2030
- </g>
2031
- </g>
2032
- </svg>`, 'text/xml').firstChild;
2033
- }
2034
- if (type === 'process') {
2035
- 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">
2036
- <g fill="none" fill-rule="evenodd">
2037
- <g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
2038
- <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>
2039
- </g>
2040
- </g>
2041
- </svg>`, 'text/xml').firstChild;
2042
- }
2043
- if (type === 'error') {
2044
- 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;
2045
- }
1978
+ validate(control) {
1979
+ return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
2046
1980
  }
2047
1981
  }
2048
- 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 });
2049
- 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 });
2050
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsButtonDirective, decorators: [{
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: [
1984
+ VALIDATE_MESSAGE_PROVIDER
1985
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1986
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, decorators: [{
2051
1987
  type: Directive,
2052
1988
  args: [{
2053
- selector: '[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]',
1989
+ selector: '[fsFormMax]',
1990
+ providers: [
1991
+ VALIDATE_MESSAGE_PROVIDER
1992
+ ],
2054
1993
  }]
2055
- }], ctorParameters: function () { return [{ type: i1$2.MatButton, decorators: [{
2056
- type: Optional
2057
- }, {
2058
- type: Host
2059
- }] }, { type: FsFormDirective, decorators: [{
2060
- type: Optional
2061
- }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { name: [{
2062
- type: Input
2063
- }], dirtySubmit: [{
2064
- type: Input
2065
- }], form: [{
1994
+ }], propDecorators: { fsFormMax: [{
2066
1995
  type: Input
2067
- }], transitionStyle: [{
2068
- type: HostBinding,
2069
- args: ['style.transition']
1996
+ }], validationMessage: [{
1997
+ type: Input,
1998
+ args: ['fsFormMaxMessage']
2070
1999
  }] } });
2071
2000
 
2072
- class FsFormValidateDirective extends FsControlDirective {
2073
- constructor() {
2074
- super(...arguments);
2075
- this.validateOnSubmit = false;
2001
+ class FsFormMaxLengthDirective extends FsControlDirective {
2002
+ set validationMessage(value) {
2003
+ this._validateMessages.maxlength = value;
2076
2004
  }
2077
2005
  ngOnChanges() {
2078
2006
  this._control.updateValueAndValidity();
2079
2007
  }
2080
- validateAsync(control) {
2081
- if (this.validateOnSubmit && !this.formDirective.validating) {
2082
- return of(null);
2083
- }
2084
- return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2008
+ validate(control) {
2009
+ return Validators.maxLength(this.fsFormMaxLength)(this._control);
2085
2010
  }
2086
2011
  }
2087
- FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2088
- FsFormValidateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormValidateDirective, selector: "[validate]", inputs: { validateFn: ["validate", "validateFn"], validateFnData: ["validateData", "validateFnData"], validateOnSubmit: "validateOnSubmit" }, providers: [
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: [
2089
2014
  VALIDATE_MESSAGE_PROVIDER
2090
2015
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2091
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, decorators: [{
2016
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
2092
2017
  type: Directive,
2093
2018
  args: [{
2094
- selector: '[validate]',
2019
+ selector: '[fsFormMaxLength]',
2095
2020
  providers: [
2096
2021
  VALIDATE_MESSAGE_PROVIDER
2097
2022
  ],
2098
2023
  }]
2099
- }], propDecorators: { validateFn: [{
2100
- type: Input,
2101
- args: ['validate']
2102
- }], validateFnData: [{
2103
- type: Input,
2104
- args: ['validateData']
2105
- }], validateOnSubmit: [{
2024
+ }], propDecorators: { fsFormMaxLength: [{
2106
2025
  type: Input
2026
+ }], validationMessage: [{
2027
+ type: Input,
2028
+ args: ['fsFormMaxLengthMessage']
2107
2029
  }] } });
2108
2030
 
2109
- class FsFormDialogActionsComponent {
2110
- constructor(_form, _dialogRef, _cdRef) {
2111
- this._form = _form;
2112
- this._dialogRef = _dialogRef;
2113
- this._cdRef = _cdRef;
2114
- this.save = true;
2115
- this.create = false;
2116
- this.close = false;
2117
- this.done = false;
2118
- this.closeData = null;
2119
- this.dirty = false;
2120
- this._destroy$ = new Subject();
2031
+ class FsFormMinDirective extends FsControlDirective {
2032
+ set validationMessage(value) {
2033
+ this._validateMessages.min = value;
2121
2034
  }
2122
- ngOnInit() {
2123
- if (this._form) {
2124
- this._form.ngForm.valueChanges
2125
- .pipe(filter(() => (!this.dirty)), takeUntil(this._destroy$))
2126
- .subscribe(() => {
2127
- this.dirty = this._form.ngForm.dirty;
2128
- this._cdRef.markForCheck();
2129
- });
2130
- this._form.submitted
2131
- .pipe(delay(50), takeUntil(this._destroy$))
2132
- .subscribe(() => {
2133
- this.dirty = false;
2134
- this._cdRef.markForCheck();
2135
- });
2136
- this._form.reseted
2137
- .pipe(takeUntil(this._destroy$))
2138
- .subscribe(() => {
2139
- this.dirty = false;
2140
- this._cdRef.markForCheck();
2141
- });
2142
- }
2035
+ ngOnChanges() {
2036
+ this._control.updateValueAndValidity();
2143
2037
  }
2144
- ngOnDestroy() {
2145
- this._destroy$.next();
2146
- this._destroy$.complete();
2038
+ validate(control) {
2039
+ return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
2147
2040
  }
2148
2041
  }
2149
- 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 });
2150
- FsFormDialogActionsComponentcmp = 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 });
2151
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
2152
- type: Component,
2153
- 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"] }]
2154
- }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
2155
- type: Optional
2156
- }] }, { type: i2$1.MatDialogRef, decorators: [{
2157
- type: Optional
2158
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { save: [{
2159
- type: Input
2160
- }], create: [{
2161
- type: Input
2162
- }], close: [{
2163
- type: Input
2164
- }], done: [{
2165
- type: Input
2166
- }], closeData: [{
2042
+ FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2043
+ FsFormMinDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
2044
+ VALIDATE_MESSAGE_PROVIDER
2045
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2046
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, decorators: [{
2047
+ type: Directive,
2048
+ args: [{
2049
+ selector: '[fsFormMin]',
2050
+ providers: [
2051
+ VALIDATE_MESSAGE_PROVIDER
2052
+ ],
2053
+ }]
2054
+ }], propDecorators: { fsFormMin: [{
2167
2055
  type: Input
2168
- }], name: [{
2056
+ }], validationMessage: [{
2057
+ type: Input,
2058
+ args: ['fsFormMinMessage']
2059
+ }] } });
2060
+
2061
+ class FsFormMinLengthDirective extends FsControlDirective {
2062
+ set validationMessage(value) {
2063
+ this._validateMessages.minlength = value;
2064
+ }
2065
+ ngOnChanges() {
2066
+ this._control.updateValueAndValidity();
2067
+ }
2068
+ validate(control) {
2069
+ return Validators.minLength(this.fsFormMinLength)(this._control);
2070
+ }
2071
+ }
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: [
2074
+ VALIDATE_MESSAGE_PROVIDER
2075
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2076
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
2077
+ type: Directive,
2078
+ args: [{
2079
+ selector: '[fsFormMinLength]',
2080
+ providers: [
2081
+ VALIDATE_MESSAGE_PROVIDER
2082
+ ],
2083
+ }]
2084
+ }], propDecorators: { fsFormMinLength: [{
2169
2085
  type: Input
2086
+ }], validationMessage: [{
2087
+ type: Input,
2088
+ args: ['fsFormMinLengthMessage']
2170
2089
  }] } });
2171
2090
 
2172
2091
  /**
@@ -2216,157 +2135,247 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2216
2135
  VALIDATE_MESSAGE_PROVIDER
2217
2136
  ],
2218
2137
  }]
2219
- }] });
2138
+ }] });
2139
+
2140
+ class FsFormNumericDirective extends FsControlDirective {
2141
+ set validationMessage(value) {
2142
+ this._validateMessages.numeric = value;
2143
+ }
2144
+ ngOnChanges() {
2145
+ this._control.updateValueAndValidity();
2146
+ }
2147
+ validate(control) {
2148
+ if (isEnabled(this.fsFormNumeric)) {
2149
+ return FsValidators.numeric(this._control);
2150
+ }
2151
+ else {
2152
+ return null;
2153
+ }
2154
+ }
2155
+ }
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: [
2158
+ VALIDATE_MESSAGE_PROVIDER
2159
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
2161
+ type: Directive,
2162
+ args: [{
2163
+ selector: '[fsFormNumeric]',
2164
+ providers: [
2165
+ VALIDATE_MESSAGE_PROVIDER
2166
+ ],
2167
+ }]
2168
+ }], propDecorators: { fsFormNumeric: [{
2169
+ type: Input
2170
+ }], validationMessage: [{
2171
+ type: Input,
2172
+ args: ['fsFormNumericMessage']
2173
+ }] } });
2220
2174
 
2221
- class FsFormGreaterEqualDirective extends FsControlDirective {
2175
+ class FsFormPatternDirective extends FsControlDirective {
2222
2176
  set validationMessage(value) {
2223
- this._validateMessages.greater = value;
2177
+ this._validateMessages.pattern = value;
2224
2178
  }
2225
2179
  ngOnChanges() {
2226
2180
  this._control.updateValueAndValidity();
2227
2181
  }
2228
2182
  validate(control) {
2229
- const greater = parseFloat(this.fsFormGreaterEqual);
2230
- const value = parseFloat(this._control.value);
2231
- if (!isNaN(greater) && !isNaN(value) && value < greater) {
2232
- return { greaterEqual: { greater, actual: value } };
2233
- }
2234
- return FsValidators.numeric(this._control);
2183
+ return Validators.pattern(this.fsFormPattern)(this._control);
2235
2184
  }
2236
2185
  }
2237
- FsFormGreaterEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2238
- FsFormGreaterEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterEqualDirective, selector: "[fsFormGreaterEqual]", inputs: { fsFormGreaterEqual: "fsFormGreaterEqual", validationMessage: ["fsFormGreaterEqualMessage", "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: [
2239
2188
  VALIDATE_MESSAGE_PROVIDER
2240
2189
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2241
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, decorators: [{
2190
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
2242
2191
  type: Directive,
2243
2192
  args: [{
2244
- selector: '[fsFormGreaterEqual]',
2193
+ selector: '[fsFormPattern]',
2245
2194
  providers: [
2246
2195
  VALIDATE_MESSAGE_PROVIDER
2247
2196
  ],
2248
2197
  }]
2249
- }], propDecorators: { fsFormGreaterEqual: [{
2198
+ }], propDecorators: { fsFormPattern: [{
2250
2199
  type: Input
2251
2200
  }], validationMessage: [{
2252
2201
  type: Input,
2253
- args: ['fsFormGreaterEqualMessage']
2202
+ args: ['fsFormPatternMessage']
2254
2203
  }] } });
2255
2204
 
2256
- class FsFormLesserEqualDirective extends FsControlDirective {
2205
+ class FsFormPhoneDirective extends FsControlDirective {
2257
2206
  set validationMessage(value) {
2258
- this._validateMessages.lesser = value;
2207
+ this._validateMessages.phone = value;
2259
2208
  }
2260
2209
  ngOnChanges() {
2261
2210
  this._control.updateValueAndValidity();
2262
2211
  }
2263
2212
  validate(control) {
2264
- const lesser = parseFloat(this.fsFormLesserEqual);
2265
- const value = parseFloat(this._control.value);
2266
- if (!isNaN(lesser) && !isNaN(value) && value > lesser) {
2267
- return { lesserEqual: { lesser, actual: value } };
2213
+ if (isEnabled(this.fsFormPhone)) {
2214
+ return FsValidators.phone(this._control);
2215
+ }
2216
+ else {
2217
+ return null;
2268
2218
  }
2269
- return FsValidators.numeric(this._control);
2270
2219
  }
2271
2220
  }
2272
- FsFormLesserEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2273
- FsFormLesserEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserEqualDirective, selector: "[fsFormLesserEqual]", inputs: { fsFormLesserEqual: "fsFormLesserEqual", validationMessage: ["fsFormLesserEqualMessage", "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: [
2274
2223
  VALIDATE_MESSAGE_PROVIDER
2275
2224
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2276
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, decorators: [{
2225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
2277
2226
  type: Directive,
2278
2227
  args: [{
2279
- selector: '[fsFormLesserEqual]',
2228
+ selector: '[fsFormPhone]',
2280
2229
  providers: [
2281
2230
  VALIDATE_MESSAGE_PROVIDER
2282
2231
  ],
2283
2232
  }]
2284
- }], propDecorators: { fsFormLesserEqual: [{
2233
+ }], propDecorators: { fsFormPhone: [{
2285
2234
  type: Input
2286
2235
  }], validationMessage: [{
2287
2236
  type: Input,
2288
- args: ['fsFormLesserEqualMessage']
2237
+ args: ['fsFormPhoneMessage']
2289
2238
  }] } });
2290
2239
 
2291
- class FsFormTemplateDirective {
2292
- constructor() { }
2293
- ngAfterContentInit() {
2240
+ class FsFormRequiredDirective extends FsControlDirective {
2241
+ constructor() {
2242
+ super(...arguments);
2243
+ this.required = false;
2244
+ }
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);
2260
+ }
2261
+ return null;
2262
+ }
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();
2294
2278
  }
2295
2279
  }
2296
- FsFormTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2297
- 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 });
2298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateDirective, 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: [{
2299
2285
  type: Directive,
2300
2286
  args: [{
2301
- selector: '[fsFormTemplate]',
2287
+ selector: '[fsFormRequired],[ngModel][required]',
2288
+ providers: [
2289
+ VALIDATE_MESSAGE_PROVIDER,
2290
+ ],
2302
2291
  }]
2303
- }], ctorParameters: function () { return []; }, propDecorators: { models: [{
2304
- type: ViewChildren,
2305
- args: [NgModel]
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']
2306
2301
  }] } });
2307
2302
 
2308
- class FsSubmitButtonDirective extends FsButtonDirective {
2303
+ class FsFormUrlDirective extends FsControlDirective {
2304
+ constructor() {
2305
+ super(...arguments);
2306
+ this.fsFormUrlProtocol = false;
2307
+ }
2308
+ set validationMessage(value) {
2309
+ this._validateMessages.url = value;
2310
+ }
2311
+ ngOnChanges() {
2312
+ this._control.updateValueAndValidity();
2313
+ }
2314
+ validate(control) {
2315
+ if (isEnabled(this.fsFormUrl)) {
2316
+ return FsValidators.url(this._control, this.fsFormUrlProtocol);
2317
+ }
2318
+ else {
2319
+ return null;
2320
+ }
2321
+ }
2309
2322
  }
2310
- FsSubmitButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsSubmitButtonDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2311
- FsSubmitButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsSubmitButtonDirective, selector: "dummy-selector", usesInheritance: true, ngImport: i0 });
2312
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsSubmitButtonDirective, 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: [{
2313
2328
  type: Directive,
2314
2329
  args: [{
2315
- selector: 'dummy-selector',
2330
+ selector: '[fsFormUrl]',
2331
+ providers: [
2332
+ VALIDATE_MESSAGE_PROVIDER
2333
+ ],
2316
2334
  }]
2317
- }] });
2318
-
2319
- class FsFormTemplateComponent {
2320
- constructor() { }
2321
- ngAfterContentInit() {
2322
- debugger;
2323
- const x = this.models;
2324
- this.models.changes.subscribe((x) => {
2325
- debugger;
2326
- });
2327
- }
2328
- ngOnInit() {
2329
- debugger;
2330
- }
2331
- }
2332
- FsFormTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2333
- 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 });
2334
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, decorators: [{
2335
- type: Component,
2336
- args: [{ selector: 'fs-form-template', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #templateRef1>\n <ng-content></ng-content>\n</ng-template>" }]
2337
- }], ctorParameters: function () { return []; }, propDecorators: { templateRef: [{
2338
- type: ViewChild,
2339
- args: ['templateRef1']
2340
- }], formTemplate: [{
2335
+ }], propDecorators: { fsFormUrl: [{
2341
2336
  type: Input
2342
- }], models: [{
2343
- type: ContentChildren,
2344
- args: [NgModel, { descendants: true }]
2337
+ }], fsFormUrlProtocol: [{
2338
+ type: Input
2339
+ }], validationMessage: [{
2340
+ type: Input,
2341
+ args: ['fsFormUrlMessage']
2345
2342
  }] } });
2346
2343
 
2347
- class FsFormTemplateOutletComponent {
2348
- constructor() { }
2349
- ngOnChanges(changes) {
2350
- if (changes.formTemplate?.currentValue) {
2351
- }
2344
+ class FsFormValidateDirective extends FsControlDirective {
2345
+ constructor() {
2346
+ super(...arguments);
2347
+ this.validateOnSubmit = false;
2352
2348
  }
2353
- ngAfterContentInit() {
2354
- // const x = this.models;
2355
- // this.models.changes.subscribe((x) => {
2356
- // debugger;
2357
- // });
2349
+ ngOnChanges() {
2350
+ this._control.updateValueAndValidity();
2351
+ }
2352
+ validateAsync(control) {
2353
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2354
+ return of(null);
2355
+ }
2356
+ return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2358
2357
  }
2359
2358
  }
2360
- FsFormTemplateOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2361
- FsFormTemplateOutletComponentcmp = 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 });
2362
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, decorators: [{
2363
- type: Component,
2364
- 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>" }]
2365
- }], ctorParameters: function () { return []; }, propDecorators: { formTemplate: [{
2359
+ FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2360
+ FsFormValidateDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormValidateDirective, selector: "[validate]", inputs: { validateFn: ["validate", "validateFn"], validateFnData: ["validateData", "validateFnData"], validateOnSubmit: "validateOnSubmit" }, providers: [
2361
+ VALIDATE_MESSAGE_PROVIDER
2362
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, decorators: [{
2364
+ type: Directive,
2365
+ args: [{
2366
+ selector: '[validate]',
2367
+ providers: [
2368
+ VALIDATE_MESSAGE_PROVIDER
2369
+ ],
2370
+ }]
2371
+ }], propDecorators: { validateFn: [{
2372
+ type: Input,
2373
+ args: ['validate']
2374
+ }], validateFnData: [{
2375
+ type: Input,
2376
+ args: ['validateData']
2377
+ }], validateOnSubmit: [{
2366
2378
  type: Input
2367
- }], models: [{
2368
- type: ContentChildren,
2369
- args: [NgModel, { descendants: true }]
2370
2379
  }] } });
2371
2380
 
2372
2381
  class FsFormModule {
@@ -2374,7 +2383,8 @@ class FsFormModule {
2374
2383
  /**
2375
2384
  * Hack: https://github.com/angular/components/issues/20097
2376
2385
  */
2377
- ErrorStateMatcher.prototype.isErrorState = (control, form) => {
2386
+ ErrorStateMatcher.prototype
2387
+ .isErrorState = (control, form) => {
2378
2388
  return control?.invalid && control?.touched && control?.dirty;
2379
2389
  };
2380
2390
  return {
@@ -2412,10 +2422,13 @@ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
2412
2422
  FsSubmitButtonDirective,
2413
2423
  FsFormTemplateComponent,
2414
2424
  FsFormTemplateDirective,
2415
- FsFormTemplateOutletComponent], imports: [CommonModule,
2425
+ FsFormTemplateOutletComponent,
2426
+ ConfirmUnsavedComponent], imports: [CommonModule,
2416
2427
  FormsModule,
2417
2428
  MatButtonModule,
2418
- MatDialogModule], exports: [FsFormDirective,
2429
+ MatDialogModule,
2430
+ MatDialogModule,
2431
+ FsDialogModule], exports: [FsFormDirective,
2419
2432
  FsControlDirective,
2420
2433
  FsFormRequiredDirective,
2421
2434
  FsFormMinDirective,
@@ -2455,6 +2468,8 @@ FsFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
2455
2468
  FormsModule,
2456
2469
  MatButtonModule,
2457
2470
  MatDialogModule,
2471
+ MatDialogModule,
2472
+ FsDialogModule,
2458
2473
  ]] });
2459
2474
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormModule, decorators: [{
2460
2475
  type: NgModule,
@@ -2464,6 +2479,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2464
2479
  FormsModule,
2465
2480
  MatButtonModule,
2466
2481
  MatDialogModule,
2482
+ MatDialogModule,
2483
+ FsDialogModule,
2467
2484
  ],
2468
2485
  declarations: [
2469
2486
  FsFormDirective,
@@ -2496,6 +2513,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2496
2513
  FsFormTemplateComponent,
2497
2514
  FsFormTemplateDirective,
2498
2515
  FsFormTemplateOutletComponent,
2516
+ ConfirmUnsavedComponent,
2499
2517
  ],
2500
2518
  exports: [
2501
2519
  FsFormDirective,