@firestitch/form 13.2.0 → 13.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) 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/directives/validators/url.directive.d.ts +1 -1
  15. package/app/enums/index.d.ts +2 -0
  16. package/app/fs-form.module.d.ts +7 -5
  17. package/app/guards/form-deactivate.guard.d.ts +2 -4
  18. package/app/helpers/index.d.ts +0 -1
  19. package/app/services/fsform.service.d.ts +5 -1
  20. package/esm2020/app/components/confirm-unsaved/confirm-unsaved.component.mjs +44 -0
  21. package/esm2020/app/components/confirm-unsaved/index.mjs +2 -0
  22. package/esm2020/app/components/form-dialog-actions/form-dialog-actions.component.mjs +3 -3
  23. package/esm2020/app/components/form-dialog-actions/index.mjs +1 -1
  24. package/esm2020/app/components/index.mjs +2 -1
  25. package/esm2020/app/directives/button.directive.mjs +6 -6
  26. package/esm2020/app/directives/form/form.directive.mjs +29 -33
  27. package/esm2020/app/directives/form/index.mjs +1 -1
  28. package/esm2020/app/directives/form-dialog-close.directive.mjs +6 -6
  29. package/esm2020/app/directives/index.mjs +3 -3
  30. package/esm2020/app/directives/validators/compare.directive.mjs +4 -6
  31. package/esm2020/app/directives/validators/control.directive.mjs +20 -21
  32. package/esm2020/app/directives/validators/function.directive.mjs +5 -5
  33. package/esm2020/app/directives/validators/index.mjs +1 -1
  34. package/esm2020/app/directives/validators/integer.directive.mjs +7 -9
  35. package/esm2020/app/directives/validators/required.directive.mjs +6 -8
  36. package/esm2020/app/directives/validators/url.directive.mjs +8 -10
  37. package/esm2020/app/enums/index.mjs +3 -0
  38. package/esm2020/app/fs-form.module.mjs +32 -23
  39. package/esm2020/app/guards/form-deactivate.guard.mjs +13 -16
  40. package/esm2020/app/helpers/get-form-errors.mjs +1 -1
  41. package/esm2020/app/helpers/index.mjs +1 -2
  42. package/esm2020/app/services/fsform.service.mjs +59 -7
  43. package/esm2020/app/validators/validators.mjs +7 -11
  44. package/esm2020/public_api.mjs +16 -16
  45. package/fesm2015/firestitch-form.mjs +1195 -1181
  46. package/fesm2015/firestitch-form.mjs.map +1 -1
  47. package/fesm2020/firestitch-form.mjs +1195 -1183
  48. package/fesm2020/firestitch-form.mjs.map +1 -1
  49. package/package.json +1 -5
  50. package/public_api.d.ts +16 -16
  51. package/app/helpers/confirm-unsaved.d.ts +0 -5
  52. 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;
@@ -706,9 +722,9 @@ class FsFormDirective {
706
722
  this.ngForm.form.registerControl = (name, control) => {
707
723
  const el = this._element.nativeElement.querySelector(`input[name='${name}']`);
708
724
  if (el) {
709
- el.setAttribute('name', `${name}_${guid()}`);
710
725
  if (!el.getAttribute('autocomplete')) {
711
726
  el.setAttribute('autocomplete', 'none');
727
+ el.setAttribute('name', `${name}_${guid()}`);
712
728
  }
713
729
  }
714
730
  return this._registerControl(name, control);
@@ -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;
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();
1276
1108
  }
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
- }
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
+ });
1287
1129
  }
1288
- return { dateRange: true };
1289
1130
  }
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
- }
1310
- }
1311
- return stream$
1312
- .pipe(mapTo(null), catchError((err) => {
1313
- return of({ validationError: err });
1314
- }), take(1));
1131
+ ngOnDestroy() {
1132
+ this._destroy$.next();
1133
+ this._destroy$.complete();
1315
1134
  }
1316
- }
1135
+ }
1136
+ FsFormDialogActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, deps: [{ token: FsFormDirective, optional: true }, { token: i1.MatDialogRef, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1137
+ FsFormDialogActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDialogActionsComponent, selector: "fs-form-dialog-actions", inputs: { save: "save", create: "create", close: "close", done: "done", closeData: "closeData", name: "name" }, ngImport: i0, template: "<div class=\"form-buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save || create\">\n <button\n mat-button\n type=\"submit\"\n color=\"primary\"\n [name]=\"name\">\n {{create ? 'Create' : 'Save'}}\n </button>\n <button\n mat-button\n type=\"button\"\n class=\"close-button cancel-button\"\n [disabled]=\"close && !dirty && !create\"\n [mat-dialog-close]=\"null\">\n Cancel\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"done\">\n <button\n mat-button\n type=\"button\"\n color=\"primary\"\n [mat-dialog-close]=\"null\">\n Done\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"save || create\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"close\">\n <button\n mat-button\n type=\"button\"\n class=\"close-button\"\n fsFormDialogClose\n [closeData]=\"closeData\"\n [color]=\"dirty ? 'basic' : 'primary'\">\n Close\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"!(save || create)\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n</div>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n", styles: [":host{width:100%}.form-buttons.save-create .close-button:not(.cancel-button){float:right}\n"], components: [{ type: i1$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FsButtonDirective, selector: "[mat-raised-button]:not([fsFormButtonStandalone]),[mat-button]:not([fsFormButtonStandalone]),[mat-flat-button]:not([fsFormButtonStandalone]),[mat-stroked-button]:not([fsFormButtonStandalone])", inputs: ["name", "dirtySubmit", "form"] }, { type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", inputs: ["closeData"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1138
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
1139
+ type: Component,
1140
+ args: [{ selector: 'fs-form-dialog-actions', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save || create\">\n <button\n mat-button\n type=\"submit\"\n color=\"primary\"\n [name]=\"name\">\n {{create ? 'Create' : 'Save'}}\n </button>\n <button\n mat-button\n type=\"button\"\n class=\"close-button cancel-button\"\n [disabled]=\"close && !dirty && !create\"\n [mat-dialog-close]=\"null\">\n Cancel\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"done\">\n <button\n mat-button\n type=\"button\"\n color=\"primary\"\n [mat-dialog-close]=\"null\">\n Done\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"save || create\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"close\">\n <button\n mat-button\n type=\"button\"\n class=\"close-button\"\n fsFormDialogClose\n [closeData]=\"closeData\"\n [color]=\"dirty ? 'basic' : 'primary'\">\n Close\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"!(save || create)\">\n <ng-template [ngTemplateOutlet]=\"content\"></ng-template>\n </ng-container>\n</div>\n\n<ng-template #content>\n <ng-content></ng-content>\n</ng-template>\n", styles: [":host{width:100%}.form-buttons.save-create .close-button:not(.cancel-button){float:right}\n"] }]
1141
+ }], ctorParameters: function () { return [{ type: FsFormDirective, decorators: [{
1142
+ type: Optional
1143
+ }] }, { type: i1.MatDialogRef, decorators: [{
1144
+ type: Optional
1145
+ }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { save: [{
1146
+ type: Input
1147
+ }], create: [{
1148
+ type: Input
1149
+ }], close: [{
1150
+ type: Input
1151
+ }], done: [{
1152
+ type: Input
1153
+ }], closeData: [{
1154
+ type: Input
1155
+ }], name: [{
1156
+ type: Input
1157
+ }] } });
1317
1158
 
1318
- class FsFormMinDirective extends FsControlDirective {
1319
- set validationMessage(value) {
1320
- this._validateMessages.min = value;
1321
- }
1322
- ngOnChanges() {
1323
- 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
+ });
1324
1167
  }
1325
- validate(control) {
1326
- return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
1168
+ ngOnInit() {
1169
+ debugger;
1327
1170
  }
1328
1171
  }
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: [{
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: [{
1342
1181
  type: Input
1343
- }], validationMessage: [{
1344
- type: Input,
1345
- args: ['fsFormMinMessage']
1182
+ }], models: [{
1183
+ type: ContentChildren,
1184
+ args: [NgModel, { descendants: true }]
1346
1185
  }] } });
1347
1186
 
1348
- class FsFormMaxDirective extends FsControlDirective {
1349
- set validationMessage(value) {
1350
- this._validateMessages.max = value;
1187
+ class FsFormTemplateOutletComponent {
1188
+ constructor() { }
1189
+ ngOnChanges(changes) {
1190
+ if (changes.formTemplate?.currentValue) {
1191
+ }
1351
1192
  }
1352
- ngOnChanges() {
1353
- this._control.updateValueAndValidity();
1354
- }
1355
- validate(control) {
1356
- return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1193
+ ngAfterContentInit() {
1194
+ // const x = this.models;
1195
+ // this.models.changes.subscribe((x) => {
1196
+ // debugger;
1197
+ // });
1357
1198
  }
1358
1199
  }
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: [{
1200
+ FsFormTemplateOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1201
+ 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 });
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: [{
1372
1206
  type: Input
1373
- }], validationMessage: [{
1374
- type: Input,
1375
- args: ['fsFormMaxMessage']
1207
+ }], models: [{
1208
+ type: ContentChildren,
1209
+ args: [NgModel, { descendants: true }]
1376
1210
  }] } });
1377
1211
 
1378
- class FsFormMinLengthDirective extends FsControlDirective {
1379
- set validationMessage(value) {
1380
- this._validateMessages.minlength = value;
1381
- }
1382
- ngOnChanges() {
1383
- this._control.updateValueAndValidity();
1384
- }
1385
- validate(control) {
1386
- return Validators.minLength(this.fsFormMinLength)(this._control);
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 '';
1483
1344
  }
1484
- else {
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));
1429
+ }
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,201 @@ 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
+ return { numeric: true };
1581
+ }
1582
+ static integer(control) {
1583
+ if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1584
+ return null;
1585
+ }
1586
+ return { integer: true };
1587
+ }
1588
+ static phone(control) {
1589
+ if (!control.value || phone(control.value)) {
1590
+ return null;
1591
+ }
1592
+ return { phone: true };
1593
+ }
1594
+ static url(control, protocolRequired = false) {
1595
+ if (!control.value) {
1596
+ return null;
1597
+ }
1598
+ if (!url(control.value)) {
1599
+ return { url: true };
1600
+ }
1601
+ if (protocolRequired) {
1602
+ const pattern = new RegExp(/^http(s)?:\/\//gm);
1603
+ if (!String(control.value).match(pattern)) {
1604
+ return { urlProtocol: true };
1605
+ }
1606
+ }
1607
+ return null;
1608
+ }
1609
+ static dateRange(control) {
1610
+ if (!control.value) {
1611
+ return null;
1612
+ }
1613
+ if (isObject(control.value)) {
1614
+ const start = control.value.start;
1615
+ const end = control.value.end;
1616
+ if ((!start && !end) || (isValid(start) && isValid(end))) {
1617
+ return null;
1618
+ }
1619
+ }
1620
+ return { dateRange: true };
1621
+ }
1622
+ static func(control, formFunction, data) {
1623
+ let result;
1624
+ let stream$;
1625
+ try {
1626
+ result = formFunction(control, data);
1627
+ }
1628
+ catch (err) {
1629
+ const error = err instanceof Error ? err.message : err;
1630
+ stream$ = throwError(error);
1631
+ }
1632
+ if (!stream$) {
1633
+ if (result instanceof Promise) {
1634
+ stream$ = from(result);
1635
+ }
1636
+ else if (isObservable(result)) {
1637
+ stream$ = result;
1638
+ }
1639
+ else {
1640
+ stream$ = of(null);
1641
+ }
1642
+ }
1643
+ return stream$
1644
+ .pipe(mapTo(null), catchError((err) => {
1645
+ return of({ validationError: err });
1646
+ }), take(1));
1647
+ }
1648
+ }
1649
+
1650
+ function isEnabled(value) {
1651
+ return value !== 'false' && (value || value === '');
1652
+ }
1653
+
1654
+ class FsFormDateRangeDirective extends FsControlDirective {
1589
1655
  set validationMessage(value) {
1590
- this._validateMessages.integer = value;
1656
+ this._validateMessages.dateRange = value;
1591
1657
  }
1592
1658
  ngOnChanges() {
1593
1659
  this._control.updateValueAndValidity();
1594
1660
  }
1595
1661
  validate(control) {
1596
- if (isEnabled(this.fsFormInteger)) {
1597
- return FsValidators.integer(this._control);
1662
+ if (isEnabled(this.fsFormDateRange)) {
1663
+ return FsValidators.dateRange(this._control);
1598
1664
  }
1599
1665
  else {
1600
1666
  return null;
1601
1667
  }
1602
1668
  }
1603
1669
  }
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: [
1670
+ FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1671
+ FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "validationMessage"] }, providers: [
1606
1672
  VALIDATE_MESSAGE_PROVIDER
1607
1673
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1608
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1674
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1609
1675
  type: Directive,
1610
1676
  args: [{
1611
- selector: '[fsFormInteger]',
1677
+ selector: '[fsFormDateRange]',
1612
1678
  providers: [
1613
1679
  VALIDATE_MESSAGE_PROVIDER
1614
1680
  ],
1615
1681
  }]
1616
- }], propDecorators: { fsFormInteger: [{
1682
+ }], propDecorators: { fsFormDateRange: [{
1617
1683
  type: Input
1618
1684
  }], validationMessage: [{
1619
1685
  type: Input,
1620
- args: ['fsFormIntegerMessage']
1686
+ args: ['fsFormDateRangeMessage']
1621
1687
  }] } });
1622
1688
 
1623
- class FsFormNumericDirective extends FsControlDirective {
1689
+ class FsFormEmailDirective extends FsControlDirective {
1624
1690
  set validationMessage(value) {
1625
- this._validateMessages.numeric = value;
1691
+ this._validateMessages.email = value;
1626
1692
  }
1627
1693
  ngOnChanges() {
1628
1694
  this._control.updateValueAndValidity();
1629
1695
  }
1630
1696
  validate(control) {
1631
- if (isEnabled(this.fsFormNumeric)) {
1632
- return FsValidators.numeric(this._control);
1697
+ if (isEnabled(this.fsFormEmail)) {
1698
+ return FsValidators.email(this._control);
1633
1699
  }
1634
1700
  else {
1635
1701
  return null;
1636
1702
  }
1637
1703
  }
1638
1704
  }
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: [
1705
+ FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1706
+ FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
1641
1707
  VALIDATE_MESSAGE_PROVIDER
1642
1708
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1643
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
1709
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, decorators: [{
1644
1710
  type: Directive,
1645
1711
  args: [{
1646
- selector: '[fsFormNumeric]',
1712
+ selector: '[fsFormEmail]',
1647
1713
  providers: [
1648
1714
  VALIDATE_MESSAGE_PROVIDER
1649
1715
  ],
1650
1716
  }]
1651
- }], propDecorators: { fsFormNumeric: [{
1717
+ }], propDecorators: { fsFormEmail: [{
1652
1718
  type: Input
1653
1719
  }], validationMessage: [{
1654
1720
  type: Input,
1655
- args: ['fsFormNumericMessage']
1721
+ args: ['fsFormEmailMessage']
1656
1722
  }] } });
1657
1723
 
1658
- class FsFormPatternDirective extends FsControlDirective {
1724
+ class FsFormEmailsDirective extends FsControlDirective {
1659
1725
  set validationMessage(value) {
1660
- this._validateMessages.pattern = value;
1726
+ this._validateMessages.emails = value;
1661
1727
  }
1662
1728
  ngOnChanges() {
1663
1729
  this._control.updateValueAndValidity();
1664
1730
  }
1665
1731
  validate(control) {
1666
- return Validators.pattern(this.fsFormPattern)(this._control);
1732
+ if (isEnabled(this.fsFormEmails)) {
1733
+ return FsValidators.emails(this._control);
1734
+ }
1735
+ else {
1736
+ return null;
1737
+ }
1667
1738
  }
1668
1739
  }
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: [
1740
+ FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1741
+ FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
1671
1742
  VALIDATE_MESSAGE_PROVIDER
1672
1743
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1673
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
1744
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
1674
1745
  type: Directive,
1675
1746
  args: [{
1676
- selector: '[fsFormPattern]',
1747
+ selector: '[fsFormEmails]',
1677
1748
  providers: [
1678
1749
  VALIDATE_MESSAGE_PROVIDER
1679
1750
  ],
1680
1751
  }]
1681
- }], propDecorators: { fsFormPattern: [{
1752
+ }], propDecorators: { fsFormEmails: [{
1682
1753
  type: Input
1683
1754
  }], validationMessage: [{
1684
1755
  type: Input,
1685
- args: ['fsFormPatternMessage']
1756
+ args: ['fsFormEmailsMessage']
1686
1757
  }] } });
1687
1758
 
1688
1759
  class FsFormFunctionDirective extends FsControlDirective {
@@ -1697,27 +1768,62 @@ class FsFormFunctionDirective extends FsControlDirective {
1697
1768
  if (this.validateOnSubmit && !this.formDirective.validating) {
1698
1769
  return of(null);
1699
1770
  }
1700
- return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
1771
+ return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
1772
+ }
1773
+ }
1774
+ FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1775
+ FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
1776
+ VALIDATE_MESSAGE_PROVIDER,
1777
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1778
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
1779
+ type: Directive,
1780
+ args: [{
1781
+ selector: '[fsFormFunction]',
1782
+ providers: [
1783
+ VALIDATE_MESSAGE_PROVIDER,
1784
+ ],
1785
+ }]
1786
+ }], propDecorators: { fsFormFunction: [{
1787
+ type: Input
1788
+ }], fsFormFunctionData: [{
1789
+ type: Input
1790
+ }], validateOnSubmit: [{
1791
+ type: Input
1792
+ }] } });
1793
+
1794
+ class FsFormGreaterEqualDirective extends FsControlDirective {
1795
+ set validationMessage(value) {
1796
+ this._validateMessages.greater = value;
1797
+ }
1798
+ ngOnChanges() {
1799
+ this._control.updateValueAndValidity();
1800
+ }
1801
+ validate(control) {
1802
+ const greater = parseFloat(this.fsFormGreaterEqual);
1803
+ const value = parseFloat(this._control.value);
1804
+ if (!isNaN(greater) && !isNaN(value) && value < greater) {
1805
+ return { greaterEqual: { greater, actual: value } };
1806
+ }
1807
+ return FsValidators.numeric(this._control);
1701
1808
  }
1702
1809
  }
1703
- FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1704
- FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
1810
+ FsFormGreaterEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1811
+ FsFormGreaterEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterEqualDirective, selector: "[fsFormGreaterEqual]", inputs: { fsFormGreaterEqual: "fsFormGreaterEqual", validationMessage: ["fsFormGreaterEqualMessage", "validationMessage"] }, providers: [
1705
1812
  VALIDATE_MESSAGE_PROVIDER
1706
1813
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1707
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
1814
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, decorators: [{
1708
1815
  type: Directive,
1709
1816
  args: [{
1710
- selector: '[fsFormFunction]',
1817
+ selector: '[fsFormGreaterEqual]',
1711
1818
  providers: [
1712
1819
  VALIDATE_MESSAGE_PROVIDER
1713
1820
  ],
1714
1821
  }]
1715
- }], propDecorators: { fsFormFunction: [{
1716
- type: Input
1717
- }], fsFormFunctionData: [{
1718
- type: Input
1719
- }], validateOnSubmit: [{
1822
+ }], propDecorators: { fsFormGreaterEqual: [{
1720
1823
  type: Input
1824
+ }], validationMessage: [{
1825
+ type: Input,
1826
+ args: ['fsFormGreaterEqualMessage']
1721
1827
  }] } });
1722
1828
 
1723
1829
  class FsFormGreaterDirective extends FsControlDirective {
@@ -1755,42 +1861,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1755
1861
  args: ['fsFormGreaterMessage']
1756
1862
  }] } });
1757
1863
 
1758
- class FsFormDateRangeDirective extends FsControlDirective {
1864
+ class FsFormIntegerDirective extends FsControlDirective {
1759
1865
  set validationMessage(value) {
1760
- this._validateMessages.dateRange = value;
1866
+ this._validateMessages.integer = value;
1761
1867
  }
1762
1868
  ngOnChanges() {
1763
1869
  this._control.updateValueAndValidity();
1764
1870
  }
1765
1871
  validate(control) {
1766
- if (isEnabled(this.fsFormDateRange)) {
1767
- return FsValidators.dateRange(this._control);
1768
- }
1769
- else {
1770
- return null;
1872
+ if (isEnabled(this.fsFormInteger)) {
1873
+ return FsValidators.integer(this._control);
1771
1874
  }
1875
+ return null;
1772
1876
  }
1773
1877
  }
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: [
1776
- VALIDATE_MESSAGE_PROVIDER
1878
+ FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1879
+ FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "validationMessage"] }, providers: [
1880
+ VALIDATE_MESSAGE_PROVIDER,
1777
1881
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1778
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
1882
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
1779
1883
  type: Directive,
1780
1884
  args: [{
1781
- selector: '[fsFormDateRange]',
1885
+ selector: '[fsFormInteger]',
1782
1886
  providers: [
1783
- VALIDATE_MESSAGE_PROVIDER
1887
+ VALIDATE_MESSAGE_PROVIDER,
1784
1888
  ],
1785
1889
  }]
1786
- }], propDecorators: { fsFormDateRange: [{
1890
+ }], propDecorators: { fsFormInteger: [{
1787
1891
  type: Input
1788
1892
  }], validationMessage: [{
1789
1893
  type: Input,
1790
- args: ['fsFormDateRangeMessage']
1894
+ args: ['fsFormIntegerMessage']
1791
1895
  }] } });
1792
1896
 
1793
- class FsFormLesserDirective extends FsControlDirective {
1897
+ class FsFormLesserEqualDirective extends FsControlDirective {
1794
1898
  set validationMessage(value) {
1795
1899
  this._validateMessages.lesser = value;
1796
1900
  }
@@ -1798,375 +1902,186 @@ class FsFormLesserDirective extends FsControlDirective {
1798
1902
  this._control.updateValueAndValidity();
1799
1903
  }
1800
1904
  validate(control) {
1801
- const lesser = parseFloat(this.fsFormLesser);
1905
+ const lesser = parseFloat(this.fsFormLesserEqual);
1802
1906
  const value = parseFloat(this._control.value);
1803
- if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1804
- return { lesser: { lesser, actual: value } };
1907
+ if (!isNaN(lesser) && !isNaN(value) && value > lesser) {
1908
+ return { lesserEqual: { lesser, actual: value } };
1805
1909
  }
1806
1910
  return FsValidators.numeric(this._control);
1807
1911
  }
1808
1912
  }
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: [
1913
+ FsFormLesserEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1914
+ FsFormLesserEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserEqualDirective, selector: "[fsFormLesserEqual]", inputs: { fsFormLesserEqual: "fsFormLesserEqual", validationMessage: ["fsFormLesserEqualMessage", "validationMessage"] }, providers: [
1811
1915
  VALIDATE_MESSAGE_PROVIDER
1812
1916
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1813
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1917
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, decorators: [{
1814
1918
  type: Directive,
1815
1919
  args: [{
1816
- selector: '[fsFormLesser]',
1920
+ selector: '[fsFormLesserEqual]',
1817
1921
  providers: [
1818
1922
  VALIDATE_MESSAGE_PROVIDER
1819
1923
  ],
1820
1924
  }]
1821
- }], propDecorators: { fsFormLesser: [{
1925
+ }], propDecorators: { fsFormLesserEqual: [{
1822
1926
  type: Input
1823
1927
  }], validationMessage: [{
1824
1928
  type: Input,
1825
- args: ['fsFormLesserMessage']
1929
+ args: ['fsFormLesserEqualMessage']
1826
1930
  }] } });
1827
1931
 
1828
- class FsFormUrlDirective extends FsControlDirective {
1829
- constructor() {
1830
- super(...arguments);
1831
- this.fsFormUrlProtocol = false;
1832
- }
1932
+ class FsFormLesserDirective extends FsControlDirective {
1833
1933
  set validationMessage(value) {
1834
- this._validateMessages.url = value;
1934
+ this._validateMessages.lesser = value;
1835
1935
  }
1836
1936
  ngOnChanges() {
1837
1937
  this._control.updateValueAndValidity();
1838
1938
  }
1839
1939
  validate(control) {
1840
- if (isEnabled(this.fsFormUrl)) {
1841
- return FsValidators.url(this._control, this.fsFormUrlProtocol);
1842
- }
1843
- else {
1844
- return null;
1940
+ const lesser = parseFloat(this.fsFormLesser);
1941
+ const value = parseFloat(this._control.value);
1942
+ if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
1943
+ return { lesser: { lesser, actual: value } };
1845
1944
  }
1945
+ return FsValidators.numeric(this._control);
1846
1946
  }
1847
1947
  }
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: [
1948
+ FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1949
+ FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
1850
1950
  VALIDATE_MESSAGE_PROVIDER
1851
1951
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1852
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, decorators: [{
1952
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
1853
1953
  type: Directive,
1854
1954
  args: [{
1855
- selector: '[fsFormUrl]',
1955
+ selector: '[fsFormLesser]',
1856
1956
  providers: [
1857
1957
  VALIDATE_MESSAGE_PROVIDER
1858
1958
  ],
1859
1959
  }]
1860
- }], propDecorators: { fsFormUrl: [{
1861
- type: Input
1862
- }], fsFormUrlProtocol: [{
1960
+ }], propDecorators: { fsFormLesser: [{
1863
1961
  type: Input
1864
1962
  }], validationMessage: [{
1865
1963
  type: Input,
1866
- args: ['fsFormUrlMessage']
1964
+ args: ['fsFormLesserMessage']
1867
1965
  }] } });
1868
1966
 
1869
- class FsFormDialogCloseDirective {
1870
- constructor(_form, _dialogRef) {
1871
- this._form = _form;
1872
- this._dialogRef = _dialogRef;
1873
- this._destroy$ = new Subject();
1874
- this.type = 'button';
1967
+ class FsFormMaxDirective extends FsControlDirective {
1968
+ set validationMessage(value) {
1969
+ this._validateMessages.max = value;
1875
1970
  }
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
- }
1971
+ ngOnChanges() {
1972
+ this._control.updateValueAndValidity();
1887
1973
  }
1888
- ngOnDestroy() {
1889
- this._destroy$.next();
1890
- this._destroy$.complete();
1974
+ validate(control) {
1975
+ return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
1891
1976
  }
1892
1977
  }
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: [{
1978
+ FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1979
+ FsFormMaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
1980
+ VALIDATE_MESSAGE_PROVIDER
1981
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
1982
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, decorators: [{
1896
1983
  type: Directive,
1897
1984
  args: [{
1898
- selector: '[fsFormDialogClose],[fs-form-dialog-close]'
1985
+ selector: '[fsFormMax]',
1986
+ providers: [
1987
+ VALIDATE_MESSAGE_PROVIDER
1988
+ ],
1899
1989
  }]
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']]
1912
- }] } });
1913
-
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;
1993
- }
1994
- resetActive() {
1995
- this.active = false;
1996
- }
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;
2007
- }
2008
- this._resetClass();
2009
- }
2010
- ngOnDestroy() {
2011
- this._destroy$.next();
2012
- this._destroy$.complete();
2013
- this.form?.removeButton(this);
2014
- }
2015
- _disableShadowAnimation() {
2016
- // .mat-elevation-z2 removes the click shadow animation
2017
- //this.element.classList.add('mat-elevation-z2');
1990
+ }], propDecorators: { fsFormMax: [{
1991
+ type: Input
1992
+ }], validationMessage: [{
1993
+ type: Input,
1994
+ args: ['fsFormMaxMessage']
1995
+ }] } });
1996
+
1997
+ class FsFormMaxLengthDirective extends FsControlDirective {
1998
+ set validationMessage(value) {
1999
+ this._validateMessages.maxlength = value;
2018
2000
  }
2019
- _resetClass() {
2020
- this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
2001
+ ngOnChanges() {
2002
+ this._control.updateValueAndValidity();
2021
2003
  }
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
- }
2004
+ validate(control) {
2005
+ return Validators.maxLength(this.fsFormMaxLength)(this._control);
2046
2006
  }
2047
2007
  }
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: [{
2008
+ FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2009
+ FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
2010
+ VALIDATE_MESSAGE_PROVIDER
2011
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2012
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
2051
2013
  type: Directive,
2052
2014
  args: [{
2053
- selector: '[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]',
2015
+ selector: '[fsFormMaxLength]',
2016
+ providers: [
2017
+ VALIDATE_MESSAGE_PROVIDER
2018
+ ],
2054
2019
  }]
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: [{
2020
+ }], propDecorators: { fsFormMaxLength: [{
2066
2021
  type: Input
2067
- }], transitionStyle: [{
2068
- type: HostBinding,
2069
- args: ['style.transition']
2022
+ }], validationMessage: [{
2023
+ type: Input,
2024
+ args: ['fsFormMaxLengthMessage']
2070
2025
  }] } });
2071
2026
 
2072
- class FsFormValidateDirective extends FsControlDirective {
2073
- constructor() {
2074
- super(...arguments);
2075
- this.validateOnSubmit = false;
2027
+ class FsFormMinDirective extends FsControlDirective {
2028
+ set validationMessage(value) {
2029
+ this._validateMessages.min = value;
2076
2030
  }
2077
2031
  ngOnChanges() {
2078
2032
  this._control.updateValueAndValidity();
2079
2033
  }
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);
2034
+ validate(control) {
2035
+ return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
2085
2036
  }
2086
2037
  }
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: [
2038
+ FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2039
+ FsFormMinDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
2089
2040
  VALIDATE_MESSAGE_PROVIDER
2090
2041
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2091
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, decorators: [{
2042
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, decorators: [{
2092
2043
  type: Directive,
2093
2044
  args: [{
2094
- selector: '[validate]',
2045
+ selector: '[fsFormMin]',
2095
2046
  providers: [
2096
2047
  VALIDATE_MESSAGE_PROVIDER
2097
2048
  ],
2098
2049
  }]
2099
- }], propDecorators: { validateFn: [{
2100
- type: Input,
2101
- args: ['validate']
2102
- }], validateFnData: [{
2103
- type: Input,
2104
- args: ['validateData']
2105
- }], validateOnSubmit: [{
2050
+ }], propDecorators: { fsFormMin: [{
2106
2051
  type: Input
2052
+ }], validationMessage: [{
2053
+ type: Input,
2054
+ args: ['fsFormMinMessage']
2107
2055
  }] } });
2108
2056
 
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();
2057
+ class FsFormMinLengthDirective extends FsControlDirective {
2058
+ set validationMessage(value) {
2059
+ this._validateMessages.minlength = value;
2121
2060
  }
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
- }
2061
+ ngOnChanges() {
2062
+ this._control.updateValueAndValidity();
2143
2063
  }
2144
- ngOnDestroy() {
2145
- this._destroy$.next();
2146
- this._destroy$.complete();
2064
+ validate(control) {
2065
+ return Validators.minLength(this.fsFormMinLength)(this._control);
2147
2066
  }
2148
2067
  }
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: [{
2167
- type: Input
2168
- }], name: [{
2068
+ FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2069
+ FsFormMinLengthDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
2070
+ VALIDATE_MESSAGE_PROVIDER
2071
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2072
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
2073
+ type: Directive,
2074
+ args: [{
2075
+ selector: '[fsFormMinLength]',
2076
+ providers: [
2077
+ VALIDATE_MESSAGE_PROVIDER
2078
+ ],
2079
+ }]
2080
+ }], propDecorators: { fsFormMinLength: [{
2169
2081
  type: Input
2082
+ }], validationMessage: [{
2083
+ type: Input,
2084
+ args: ['fsFormMinLengthMessage']
2170
2085
  }] } });
2171
2086
 
2172
2087
  /**
@@ -2178,195 +2093,283 @@ class FsFormNoFsValidatorsDirective extends FsControlDirective {
2178
2093
  ngOnChanges() {
2179
2094
  this._control.updateValueAndValidity();
2180
2095
  }
2181
- _subscribeToStatusChagnes() {
2182
- if (!!this._control.validator || !!this._control.asyncValidator) {
2183
- super._subscribeToStatusChagnes();
2184
- }
2096
+ _subscribeToStatusChagnes() {
2097
+ if (!!this._control.validator || !!this._control.asyncValidator) {
2098
+ super._subscribeToStatusChagnes();
2099
+ }
2100
+ }
2101
+ }
2102
+ FsFormNoFsValidatorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2103
+ FsFormNoFsValidatorsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormGreaterEqual]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])", providers: [
2104
+ VALIDATE_MESSAGE_PROVIDER
2105
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, decorators: [{
2107
+ type: Directive,
2108
+ args: [{
2109
+ selector: '[ngModel]' +
2110
+ ':not([required])' +
2111
+ ':not([fsFormRequired])' +
2112
+ ':not([fsFormCompare])' +
2113
+ ':not([fsFormDateRange])' +
2114
+ ':not([fsFormEmail])' +
2115
+ ':not([fsFormEmails])' +
2116
+ ':not([fsFormFunction])' +
2117
+ ':not([fsFormGreater])' +
2118
+ ':not([fsFormGreaterEqual])' +
2119
+ ':not([fsFormInteger])' +
2120
+ ':not([fsFormLesser])' +
2121
+ ':not([fsFormMax])' +
2122
+ ':not([fsFormMaxLength])' +
2123
+ ':not([fsFormMin])' +
2124
+ ':not([fsFormMinLength])' +
2125
+ ':not([fsFormNumeric])' +
2126
+ ':not([fsFormPattern])' +
2127
+ ':not([fsFormPhone])' +
2128
+ ':not([fsFormUrl])' +
2129
+ ':not([validate])',
2130
+ providers: [
2131
+ VALIDATE_MESSAGE_PROVIDER
2132
+ ],
2133
+ }]
2134
+ }] });
2135
+
2136
+ class FsFormNumericDirective extends FsControlDirective {
2137
+ set validationMessage(value) {
2138
+ this._validateMessages.numeric = value;
2139
+ }
2140
+ ngOnChanges() {
2141
+ this._control.updateValueAndValidity();
2142
+ }
2143
+ validate(control) {
2144
+ if (isEnabled(this.fsFormNumeric)) {
2145
+ return FsValidators.numeric(this._control);
2146
+ }
2147
+ else {
2148
+ return null;
2149
+ }
2150
+ }
2151
+ }
2152
+ FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2153
+ FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "validationMessage"] }, providers: [
2154
+ VALIDATE_MESSAGE_PROVIDER
2155
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
2157
+ type: Directive,
2158
+ args: [{
2159
+ selector: '[fsFormNumeric]',
2160
+ providers: [
2161
+ VALIDATE_MESSAGE_PROVIDER
2162
+ ],
2163
+ }]
2164
+ }], propDecorators: { fsFormNumeric: [{
2165
+ type: Input
2166
+ }], validationMessage: [{
2167
+ type: Input,
2168
+ args: ['fsFormNumericMessage']
2169
+ }] } });
2170
+
2171
+ class FsFormPatternDirective extends FsControlDirective {
2172
+ set validationMessage(value) {
2173
+ this._validateMessages.pattern = value;
2174
+ }
2175
+ ngOnChanges() {
2176
+ this._control.updateValueAndValidity();
2177
+ }
2178
+ validate(control) {
2179
+ return Validators.pattern(this.fsFormPattern)(this._control);
2185
2180
  }
2186
2181
  }
2187
- FsFormNoFsValidatorsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2188
- FsFormNoFsValidatorsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormGreaterEqual]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])", providers: [
2182
+ FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2183
+ FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "validationMessage"] }, providers: [
2189
2184
  VALIDATE_MESSAGE_PROVIDER
2190
2185
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2191
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNoFsValidatorsDirective, decorators: [{
2186
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
2192
2187
  type: Directive,
2193
2188
  args: [{
2194
- selector: '[ngModel]' +
2195
- ':not([required])' +
2196
- ':not([fsFormRequired])' +
2197
- ':not([fsFormCompare])' +
2198
- ':not([fsFormDateRange])' +
2199
- ':not([fsFormEmail])' +
2200
- ':not([fsFormEmails])' +
2201
- ':not([fsFormFunction])' +
2202
- ':not([fsFormGreater])' +
2203
- ':not([fsFormGreaterEqual])' +
2204
- ':not([fsFormInteger])' +
2205
- ':not([fsFormLesser])' +
2206
- ':not([fsFormMax])' +
2207
- ':not([fsFormMaxLength])' +
2208
- ':not([fsFormMin])' +
2209
- ':not([fsFormMinLength])' +
2210
- ':not([fsFormNumeric])' +
2211
- ':not([fsFormPattern])' +
2212
- ':not([fsFormPhone])' +
2213
- ':not([fsFormUrl])' +
2214
- ':not([validate])',
2189
+ selector: '[fsFormPattern]',
2215
2190
  providers: [
2216
2191
  VALIDATE_MESSAGE_PROVIDER
2217
2192
  ],
2218
2193
  }]
2219
- }] });
2194
+ }], propDecorators: { fsFormPattern: [{
2195
+ type: Input
2196
+ }], validationMessage: [{
2197
+ type: Input,
2198
+ args: ['fsFormPatternMessage']
2199
+ }] } });
2220
2200
 
2221
- class FsFormGreaterEqualDirective extends FsControlDirective {
2201
+ class FsFormPhoneDirective extends FsControlDirective {
2222
2202
  set validationMessage(value) {
2223
- this._validateMessages.greater = value;
2203
+ this._validateMessages.phone = value;
2224
2204
  }
2225
2205
  ngOnChanges() {
2226
2206
  this._control.updateValueAndValidity();
2227
2207
  }
2228
2208
  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 } };
2209
+ if (isEnabled(this.fsFormPhone)) {
2210
+ return FsValidators.phone(this._control);
2211
+ }
2212
+ else {
2213
+ return null;
2233
2214
  }
2234
- return FsValidators.numeric(this._control);
2235
2215
  }
2236
2216
  }
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: [
2217
+ FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2218
+ FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
2239
2219
  VALIDATE_MESSAGE_PROVIDER
2240
2220
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2241
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, decorators: [{
2221
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
2242
2222
  type: Directive,
2243
2223
  args: [{
2244
- selector: '[fsFormGreaterEqual]',
2224
+ selector: '[fsFormPhone]',
2245
2225
  providers: [
2246
2226
  VALIDATE_MESSAGE_PROVIDER
2247
2227
  ],
2248
2228
  }]
2249
- }], propDecorators: { fsFormGreaterEqual: [{
2229
+ }], propDecorators: { fsFormPhone: [{
2250
2230
  type: Input
2251
2231
  }], validationMessage: [{
2252
2232
  type: Input,
2253
- args: ['fsFormGreaterEqualMessage']
2233
+ args: ['fsFormPhoneMessage']
2254
2234
  }] } });
2255
2235
 
2256
- class FsFormLesserEqualDirective extends FsControlDirective {
2236
+ class FsFormRequiredDirective extends FsControlDirective {
2237
+ constructor() {
2238
+ super(...arguments);
2239
+ this.required = false;
2240
+ }
2241
+ set setFsFormRequired(value) {
2242
+ this.required = isEnabled(value);
2243
+ }
2244
+ set setRequired(value) {
2245
+ this.required = isEnabled(value);
2246
+ }
2257
2247
  set validationMessage(value) {
2258
- this._validateMessages.lesser = value;
2248
+ this._validateMessages.required = value;
2259
2249
  }
2260
2250
  ngOnChanges() {
2261
2251
  this._control.updateValueAndValidity();
2262
2252
  }
2263
2253
  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 } };
2254
+ if (this.required) {
2255
+ return Validators.required(this._control);
2268
2256
  }
2269
- return FsValidators.numeric(this._control);
2257
+ return null;
2258
+ }
2259
+ render() {
2260
+ const wrapper = this.getWrapperElement();
2261
+ if (wrapper && this.getlabelSelector()) {
2262
+ const labelWrapper = wrapper.querySelector(this.getlabelSelector());
2263
+ // Adding class fs-form-label-requried adds the * to the label
2264
+ if (labelWrapper) {
2265
+ if (this.required) {
2266
+ this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
2267
+ }
2268
+ else {
2269
+ this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
2270
+ }
2271
+ }
2272
+ }
2273
+ super.render();
2270
2274
  }
2271
2275
  }
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: [
2274
- VALIDATE_MESSAGE_PROVIDER
2276
+ FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2277
+ 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: [
2278
+ VALIDATE_MESSAGE_PROVIDER,
2275
2279
  ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2276
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, decorators: [{
2280
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
2277
2281
  type: Directive,
2278
2282
  args: [{
2279
- selector: '[fsFormLesserEqual]',
2283
+ selector: '[fsFormRequired],[ngModel][required]',
2280
2284
  providers: [
2281
- VALIDATE_MESSAGE_PROVIDER
2285
+ VALIDATE_MESSAGE_PROVIDER,
2282
2286
  ],
2283
2287
  }]
2284
- }], propDecorators: { fsFormLesserEqual: [{
2285
- type: Input
2288
+ }], propDecorators: { setFsFormRequired: [{
2289
+ type: Input,
2290
+ args: ['fsFormRequired']
2291
+ }], setRequired: [{
2292
+ type: Input,
2293
+ args: ['required']
2286
2294
  }], validationMessage: [{
2287
2295
  type: Input,
2288
- args: ['fsFormLesserEqualMessage']
2296
+ args: ['fsFormRequiredMessage']
2289
2297
  }] } });
2290
2298
 
2291
- class FsFormTemplateDirective {
2292
- constructor() { }
2293
- ngAfterContentInit() {
2299
+ class FsFormUrlDirective extends FsControlDirective {
2300
+ constructor() {
2301
+ super(...arguments);
2302
+ this.fsFormUrlProtocol = true;
2303
+ }
2304
+ set validationMessage(value) {
2305
+ this._validateMessages.url = value;
2306
+ }
2307
+ ngOnChanges() {
2308
+ this._control.updateValueAndValidity();
2309
+ }
2310
+ validate(control) {
2311
+ if (isEnabled(this.fsFormUrl)) {
2312
+ return FsValidators.url(this._control, this.fsFormUrlProtocol);
2313
+ }
2314
+ return null;
2294
2315
  }
2295
2316
  }
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: [{
2317
+ FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2318
+ 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: [
2319
+ VALIDATE_MESSAGE_PROVIDER,
2320
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2321
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, decorators: [{
2299
2322
  type: Directive,
2300
2323
  args: [{
2301
- selector: '[fsFormTemplate]',
2324
+ selector: '[fsFormUrl]',
2325
+ providers: [
2326
+ VALIDATE_MESSAGE_PROVIDER,
2327
+ ],
2302
2328
  }]
2303
- }], ctorParameters: function () { return []; }, propDecorators: { models: [{
2304
- type: ViewChildren,
2305
- args: [NgModel]
2329
+ }], propDecorators: { fsFormUrl: [{
2330
+ type: Input
2331
+ }], fsFormUrlProtocol: [{
2332
+ type: Input
2333
+ }], validationMessage: [{
2334
+ type: Input,
2335
+ args: ['fsFormUrlMessage']
2306
2336
  }] } });
2307
2337
 
2308
- class FsSubmitButtonDirective extends FsButtonDirective {
2309
- }
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: [{
2313
- type: Directive,
2314
- args: [{
2315
- selector: 'dummy-selector',
2316
- }]
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
- });
2338
+ class FsFormValidateDirective extends FsControlDirective {
2339
+ constructor() {
2340
+ super(...arguments);
2341
+ this.validateOnSubmit = false;
2327
2342
  }
2328
- ngOnInit() {
2329
- debugger;
2343
+ ngOnChanges() {
2344
+ this._control.updateValueAndValidity();
2330
2345
  }
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: [{
2341
- type: Input
2342
- }], models: [{
2343
- type: ContentChildren,
2344
- args: [NgModel, { descendants: true }]
2345
- }] } });
2346
-
2347
- class FsFormTemplateOutletComponent {
2348
- constructor() { }
2349
- ngOnChanges(changes) {
2350
- if (changes.formTemplate?.currentValue) {
2346
+ validateAsync(control) {
2347
+ if (this.validateOnSubmit && !this.formDirective.validating) {
2348
+ return of(null);
2351
2349
  }
2352
- }
2353
- ngAfterContentInit() {
2354
- // const x = this.models;
2355
- // this.models.changes.subscribe((x) => {
2356
- // debugger;
2357
- // });
2350
+ return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2358
2351
  }
2359
2352
  }
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: [{
2353
+ FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2354
+ 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: [
2355
+ VALIDATE_MESSAGE_PROVIDER
2356
+ ], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
2357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, decorators: [{
2358
+ type: Directive,
2359
+ args: [{
2360
+ selector: '[validate]',
2361
+ providers: [
2362
+ VALIDATE_MESSAGE_PROVIDER
2363
+ ],
2364
+ }]
2365
+ }], propDecorators: { validateFn: [{
2366
+ type: Input,
2367
+ args: ['validate']
2368
+ }], validateFnData: [{
2369
+ type: Input,
2370
+ args: ['validateData']
2371
+ }], validateOnSubmit: [{
2366
2372
  type: Input
2367
- }], models: [{
2368
- type: ContentChildren,
2369
- args: [NgModel, { descendants: true }]
2370
2373
  }] } });
2371
2374
 
2372
2375
  class FsFormModule {
@@ -2374,7 +2377,8 @@ class FsFormModule {
2374
2377
  /**
2375
2378
  * Hack: https://github.com/angular/components/issues/20097
2376
2379
  */
2377
- ErrorStateMatcher.prototype.isErrorState = (control, form) => {
2380
+ ErrorStateMatcher.prototype
2381
+ .isErrorState = (control, form) => {
2378
2382
  return control?.invalid && control?.touched && control?.dirty;
2379
2383
  };
2380
2384
  return {
@@ -2412,10 +2416,13 @@ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
2412
2416
  FsSubmitButtonDirective,
2413
2417
  FsFormTemplateComponent,
2414
2418
  FsFormTemplateDirective,
2415
- FsFormTemplateOutletComponent], imports: [CommonModule,
2419
+ FsFormTemplateOutletComponent,
2420
+ ConfirmUnsavedComponent], imports: [CommonModule,
2416
2421
  FormsModule,
2417
2422
  MatButtonModule,
2418
- MatDialogModule], exports: [FsFormDirective,
2423
+ MatDialogModule,
2424
+ MatDialogModule,
2425
+ FsDialogModule], exports: [FsFormDirective,
2419
2426
  FsControlDirective,
2420
2427
  FsFormRequiredDirective,
2421
2428
  FsFormMinDirective,
@@ -2455,6 +2462,8 @@ FsFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
2455
2462
  FormsModule,
2456
2463
  MatButtonModule,
2457
2464
  MatDialogModule,
2465
+ MatDialogModule,
2466
+ FsDialogModule,
2458
2467
  ]] });
2459
2468
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormModule, decorators: [{
2460
2469
  type: NgModule,
@@ -2464,6 +2473,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2464
2473
  FormsModule,
2465
2474
  MatButtonModule,
2466
2475
  MatDialogModule,
2476
+ MatDialogModule,
2477
+ FsDialogModule,
2467
2478
  ],
2468
2479
  declarations: [
2469
2480
  FsFormDirective,
@@ -2496,6 +2507,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2496
2507
  FsFormTemplateComponent,
2497
2508
  FsFormTemplateDirective,
2498
2509
  FsFormTemplateOutletComponent,
2510
+ ConfirmUnsavedComponent,
2499
2511
  ],
2500
2512
  exports: [
2501
2513
  FsFormDirective,