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