@firestitch/form 13.2.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +28 -32
- 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/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/public_api.mjs +16 -16
- package/fesm2015/firestitch-form.mjs +1173 -1153
- package/fesm2015/firestitch-form.mjs.map +1 -1
- package/fesm2020/firestitch-form.mjs +1173 -1155
- 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;
|
|
@@ -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
|
-
|
|
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
|
+
}
|
|
1354
1201
|
}
|
|
1355
|
-
|
|
1356
|
-
this.
|
|
1357
|
-
|
|
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,205 @@ 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
|
+
else {
|
|
1594
|
+
return { numeric: true };
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
static integer(control) {
|
|
1598
|
+
if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
|
|
1599
|
+
return null;
|
|
1600
|
+
}
|
|
1601
|
+
else {
|
|
1602
|
+
return { integer: true };
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
static phone(control) {
|
|
1606
|
+
if (!control.value || phone(control.value)) {
|
|
1607
|
+
return null;
|
|
1608
|
+
}
|
|
1609
|
+
return { phone: true };
|
|
1610
|
+
}
|
|
1611
|
+
static url(control, protocolRequired = false) {
|
|
1612
|
+
if (!control.value) {
|
|
1613
|
+
return null;
|
|
1614
|
+
}
|
|
1615
|
+
if (!url(control.value)) {
|
|
1616
|
+
return { url: true };
|
|
1617
|
+
}
|
|
1618
|
+
if (protocolRequired) {
|
|
1619
|
+
const pattern = new RegExp(/^http(s)?:\/\//gm);
|
|
1620
|
+
if (!String(control.value).match(pattern)) {
|
|
1621
|
+
return { urlProtocol: true };
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
return null;
|
|
1625
|
+
}
|
|
1626
|
+
static dateRange(control) {
|
|
1627
|
+
if (!control.value) {
|
|
1628
|
+
return null;
|
|
1629
|
+
}
|
|
1630
|
+
if (isObject(control.value)) {
|
|
1631
|
+
const start = control.value.start;
|
|
1632
|
+
const end = control.value.end;
|
|
1633
|
+
if ((!start && !end) || (isValid(start) && isValid(end))) {
|
|
1634
|
+
return null;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
return { dateRange: true };
|
|
1638
|
+
}
|
|
1639
|
+
static func(control, formFunction, data) {
|
|
1640
|
+
let result;
|
|
1641
|
+
let stream$;
|
|
1642
|
+
try {
|
|
1643
|
+
result = formFunction(control, data);
|
|
1644
|
+
}
|
|
1645
|
+
catch (err) {
|
|
1646
|
+
err = err instanceof Error ? err.message : err;
|
|
1647
|
+
stream$ = throwError(err);
|
|
1648
|
+
}
|
|
1649
|
+
if (!stream$) {
|
|
1650
|
+
if (result instanceof Promise) {
|
|
1651
|
+
stream$ = from(result);
|
|
1652
|
+
}
|
|
1653
|
+
else if (isObservable(result)) {
|
|
1654
|
+
stream$ = result;
|
|
1655
|
+
}
|
|
1656
|
+
else {
|
|
1657
|
+
stream$ = of(null);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
return stream$
|
|
1661
|
+
.pipe(mapTo(null), catchError((err) => {
|
|
1662
|
+
return of({ validationError: err });
|
|
1663
|
+
}), take(1));
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
function isEnabled(value) {
|
|
1668
|
+
return value !== 'false' && (value || value === '');
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
class FsFormDateRangeDirective extends FsControlDirective {
|
|
1592
1672
|
set validationMessage(value) {
|
|
1593
|
-
this._validateMessages.
|
|
1673
|
+
this._validateMessages.dateRange = value;
|
|
1594
1674
|
}
|
|
1595
1675
|
ngOnChanges() {
|
|
1596
1676
|
this._control.updateValueAndValidity();
|
|
1597
1677
|
}
|
|
1598
1678
|
validate(control) {
|
|
1599
|
-
if (isEnabled(this.
|
|
1600
|
-
return FsValidators.
|
|
1679
|
+
if (isEnabled(this.fsFormDateRange)) {
|
|
1680
|
+
return FsValidators.dateRange(this._control);
|
|
1601
1681
|
}
|
|
1602
1682
|
else {
|
|
1603
1683
|
return null;
|
|
1604
1684
|
}
|
|
1605
1685
|
}
|
|
1606
1686
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1687
|
+
FsFormDateRangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1688
|
+
FsFormDateRangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormDateRangeDirective, selector: "[fsFormDateRange]", inputs: { fsFormDateRange: "fsFormDateRange", validationMessage: ["fsFormDateRangeMessage", "validationMessage"] }, providers: [
|
|
1609
1689
|
VALIDATE_MESSAGE_PROVIDER
|
|
1610
1690
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1611
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1691
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormDateRangeDirective, decorators: [{
|
|
1612
1692
|
type: Directive,
|
|
1613
1693
|
args: [{
|
|
1614
|
-
selector: '[
|
|
1694
|
+
selector: '[fsFormDateRange]',
|
|
1615
1695
|
providers: [
|
|
1616
1696
|
VALIDATE_MESSAGE_PROVIDER
|
|
1617
1697
|
],
|
|
1618
1698
|
}]
|
|
1619
|
-
}], propDecorators: {
|
|
1699
|
+
}], propDecorators: { fsFormDateRange: [{
|
|
1620
1700
|
type: Input
|
|
1621
1701
|
}], validationMessage: [{
|
|
1622
1702
|
type: Input,
|
|
1623
|
-
args: ['
|
|
1703
|
+
args: ['fsFormDateRangeMessage']
|
|
1624
1704
|
}] } });
|
|
1625
1705
|
|
|
1626
|
-
class
|
|
1706
|
+
class FsFormEmailDirective extends FsControlDirective {
|
|
1627
1707
|
set validationMessage(value) {
|
|
1628
|
-
this._validateMessages.
|
|
1708
|
+
this._validateMessages.email = value;
|
|
1629
1709
|
}
|
|
1630
1710
|
ngOnChanges() {
|
|
1631
1711
|
this._control.updateValueAndValidity();
|
|
1632
1712
|
}
|
|
1633
1713
|
validate(control) {
|
|
1634
|
-
if (isEnabled(this.
|
|
1635
|
-
return FsValidators.
|
|
1714
|
+
if (isEnabled(this.fsFormEmail)) {
|
|
1715
|
+
return FsValidators.email(this._control);
|
|
1636
1716
|
}
|
|
1637
1717
|
else {
|
|
1638
1718
|
return null;
|
|
1639
1719
|
}
|
|
1640
1720
|
}
|
|
1641
1721
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1722
|
+
FsFormEmailDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1723
|
+
FsFormEmailDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailDirective, selector: "[fsFormEmail]", inputs: { fsFormEmail: "fsFormEmail", validationMessage: ["fsFormEmailMessage", "validationMessage"] }, providers: [
|
|
1644
1724
|
VALIDATE_MESSAGE_PROVIDER
|
|
1645
1725
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1646
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1726
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailDirective, decorators: [{
|
|
1647
1727
|
type: Directive,
|
|
1648
1728
|
args: [{
|
|
1649
|
-
selector: '[
|
|
1729
|
+
selector: '[fsFormEmail]',
|
|
1650
1730
|
providers: [
|
|
1651
1731
|
VALIDATE_MESSAGE_PROVIDER
|
|
1652
1732
|
],
|
|
1653
1733
|
}]
|
|
1654
|
-
}], propDecorators: {
|
|
1734
|
+
}], propDecorators: { fsFormEmail: [{
|
|
1655
1735
|
type: Input
|
|
1656
1736
|
}], validationMessage: [{
|
|
1657
1737
|
type: Input,
|
|
1658
|
-
args: ['
|
|
1738
|
+
args: ['fsFormEmailMessage']
|
|
1659
1739
|
}] } });
|
|
1660
1740
|
|
|
1661
|
-
class
|
|
1741
|
+
class FsFormEmailsDirective extends FsControlDirective {
|
|
1662
1742
|
set validationMessage(value) {
|
|
1663
|
-
this._validateMessages.
|
|
1743
|
+
this._validateMessages.emails = value;
|
|
1664
1744
|
}
|
|
1665
1745
|
ngOnChanges() {
|
|
1666
1746
|
this._control.updateValueAndValidity();
|
|
1667
1747
|
}
|
|
1668
1748
|
validate(control) {
|
|
1669
|
-
|
|
1749
|
+
if (isEnabled(this.fsFormEmails)) {
|
|
1750
|
+
return FsValidators.emails(this._control);
|
|
1751
|
+
}
|
|
1752
|
+
else {
|
|
1753
|
+
return null;
|
|
1754
|
+
}
|
|
1670
1755
|
}
|
|
1671
1756
|
}
|
|
1672
|
-
|
|
1673
|
-
|
|
1757
|
+
FsFormEmailsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1758
|
+
FsFormEmailsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormEmailsDirective, selector: "[fsFormEmails]", inputs: { fsFormEmails: "fsFormEmails", validationMessage: ["fsFormEmailsMessage", "validationMessage"] }, providers: [
|
|
1674
1759
|
VALIDATE_MESSAGE_PROVIDER
|
|
1675
1760
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1676
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1761
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormEmailsDirective, decorators: [{
|
|
1677
1762
|
type: Directive,
|
|
1678
1763
|
args: [{
|
|
1679
|
-
selector: '[
|
|
1764
|
+
selector: '[fsFormEmails]',
|
|
1680
1765
|
providers: [
|
|
1681
1766
|
VALIDATE_MESSAGE_PROVIDER
|
|
1682
1767
|
],
|
|
1683
1768
|
}]
|
|
1684
|
-
}], propDecorators: {
|
|
1769
|
+
}], propDecorators: { fsFormEmails: [{
|
|
1685
1770
|
type: Input
|
|
1686
1771
|
}], validationMessage: [{
|
|
1687
1772
|
type: Input,
|
|
1688
|
-
args: ['
|
|
1773
|
+
args: ['fsFormEmailsMessage']
|
|
1689
1774
|
}] } });
|
|
1690
1775
|
|
|
1691
1776
|
class FsFormFunctionDirective extends FsControlDirective {
|
|
@@ -1705,14 +1790,14 @@ class FsFormFunctionDirective extends FsControlDirective {
|
|
|
1705
1790
|
}
|
|
1706
1791
|
FsFormFunctionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1707
1792
|
FsFormFunctionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormFunctionDirective, selector: "[fsFormFunction]", inputs: { fsFormFunction: "fsFormFunction", fsFormFunctionData: "fsFormFunctionData", validateOnSubmit: "validateOnSubmit" }, providers: [
|
|
1708
|
-
VALIDATE_MESSAGE_PROVIDER
|
|
1793
|
+
VALIDATE_MESSAGE_PROVIDER,
|
|
1709
1794
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1710
1795
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormFunctionDirective, decorators: [{
|
|
1711
1796
|
type: Directive,
|
|
1712
1797
|
args: [{
|
|
1713
1798
|
selector: '[fsFormFunction]',
|
|
1714
1799
|
providers: [
|
|
1715
|
-
VALIDATE_MESSAGE_PROVIDER
|
|
1800
|
+
VALIDATE_MESSAGE_PROVIDER,
|
|
1716
1801
|
],
|
|
1717
1802
|
}]
|
|
1718
1803
|
}], propDecorators: { fsFormFunction: [{
|
|
@@ -1723,7 +1808,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
1723
1808
|
type: Input
|
|
1724
1809
|
}] } });
|
|
1725
1810
|
|
|
1726
|
-
class
|
|
1811
|
+
class FsFormGreaterEqualDirective extends FsControlDirective {
|
|
1727
1812
|
set validationMessage(value) {
|
|
1728
1813
|
this._validateMessages.greater = value;
|
|
1729
1814
|
}
|
|
@@ -1731,452 +1816,289 @@ class FsFormGreaterDirective extends FsControlDirective {
|
|
|
1731
1816
|
this._control.updateValueAndValidity();
|
|
1732
1817
|
}
|
|
1733
1818
|
validate(control) {
|
|
1734
|
-
const greater = parseFloat(this.
|
|
1819
|
+
const greater = parseFloat(this.fsFormGreaterEqual);
|
|
1735
1820
|
const value = parseFloat(this._control.value);
|
|
1736
|
-
if (!isNaN(greater) && !isNaN(value) && value
|
|
1737
|
-
return {
|
|
1821
|
+
if (!isNaN(greater) && !isNaN(value) && value < greater) {
|
|
1822
|
+
return { greaterEqual: { greater, actual: value } };
|
|
1738
1823
|
}
|
|
1739
1824
|
return FsValidators.numeric(this._control);
|
|
1740
1825
|
}
|
|
1741
1826
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1827
|
+
FsFormGreaterEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1828
|
+
FsFormGreaterEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterEqualDirective, selector: "[fsFormGreaterEqual]", inputs: { fsFormGreaterEqual: "fsFormGreaterEqual", validationMessage: ["fsFormGreaterEqualMessage", "validationMessage"] }, providers: [
|
|
1744
1829
|
VALIDATE_MESSAGE_PROVIDER
|
|
1745
1830
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1746
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1831
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterEqualDirective, decorators: [{
|
|
1747
1832
|
type: Directive,
|
|
1748
1833
|
args: [{
|
|
1749
|
-
selector: '[
|
|
1834
|
+
selector: '[fsFormGreaterEqual]',
|
|
1750
1835
|
providers: [
|
|
1751
1836
|
VALIDATE_MESSAGE_PROVIDER
|
|
1752
1837
|
],
|
|
1753
1838
|
}]
|
|
1754
|
-
}], propDecorators: {
|
|
1839
|
+
}], propDecorators: { fsFormGreaterEqual: [{
|
|
1755
1840
|
type: Input
|
|
1756
1841
|
}], validationMessage: [{
|
|
1757
1842
|
type: Input,
|
|
1758
|
-
args: ['
|
|
1843
|
+
args: ['fsFormGreaterEqualMessage']
|
|
1759
1844
|
}] } });
|
|
1760
1845
|
|
|
1761
|
-
class
|
|
1846
|
+
class FsFormGreaterDirective extends FsControlDirective {
|
|
1762
1847
|
set validationMessage(value) {
|
|
1763
|
-
this._validateMessages.
|
|
1848
|
+
this._validateMessages.greater = value;
|
|
1764
1849
|
}
|
|
1765
1850
|
ngOnChanges() {
|
|
1766
1851
|
this._control.updateValueAndValidity();
|
|
1767
1852
|
}
|
|
1768
1853
|
validate(control) {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
return null;
|
|
1854
|
+
const greater = parseFloat(this.fsFormGreater);
|
|
1855
|
+
const value = parseFloat(this._control.value);
|
|
1856
|
+
if (!isNaN(greater) && !isNaN(value) && value <= greater) {
|
|
1857
|
+
return { greater: { greater, actual: value } };
|
|
1774
1858
|
}
|
|
1859
|
+
return FsValidators.numeric(this._control);
|
|
1775
1860
|
}
|
|
1776
1861
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1862
|
+
FsFormGreaterDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1863
|
+
FsFormGreaterDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormGreaterDirective, selector: "[fsFormGreater]", inputs: { fsFormGreater: "fsFormGreater", validationMessage: ["fsFormGreaterMessage", "validationMessage"] }, providers: [
|
|
1779
1864
|
VALIDATE_MESSAGE_PROVIDER
|
|
1780
1865
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1781
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1866
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormGreaterDirective, decorators: [{
|
|
1782
1867
|
type: Directive,
|
|
1783
1868
|
args: [{
|
|
1784
|
-
selector: '[
|
|
1869
|
+
selector: '[fsFormGreater]',
|
|
1785
1870
|
providers: [
|
|
1786
1871
|
VALIDATE_MESSAGE_PROVIDER
|
|
1787
1872
|
],
|
|
1788
1873
|
}]
|
|
1789
|
-
}], propDecorators: {
|
|
1874
|
+
}], propDecorators: { fsFormGreater: [{
|
|
1790
1875
|
type: Input
|
|
1791
1876
|
}], validationMessage: [{
|
|
1792
1877
|
type: Input,
|
|
1793
|
-
args: ['
|
|
1878
|
+
args: ['fsFormGreaterMessage']
|
|
1794
1879
|
}] } });
|
|
1795
1880
|
|
|
1796
|
-
class
|
|
1881
|
+
class FsFormIntegerDirective extends FsControlDirective {
|
|
1797
1882
|
set validationMessage(value) {
|
|
1798
|
-
this._validateMessages.
|
|
1883
|
+
this._validateMessages.integer = value;
|
|
1799
1884
|
}
|
|
1800
1885
|
ngOnChanges() {
|
|
1801
1886
|
this._control.updateValueAndValidity();
|
|
1802
1887
|
}
|
|
1803
1888
|
validate(control) {
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
|
|
1807
|
-
return { lesser: { lesser, actual: value } };
|
|
1889
|
+
if (isEnabled(this.fsFormInteger)) {
|
|
1890
|
+
return FsValidators.integer(this._control);
|
|
1808
1891
|
}
|
|
1809
|
-
return
|
|
1892
|
+
return null;
|
|
1810
1893
|
}
|
|
1811
1894
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
VALIDATE_MESSAGE_PROVIDER
|
|
1895
|
+
FsFormIntegerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1896
|
+
FsFormIntegerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormIntegerDirective, selector: "[fsFormInteger]", inputs: { fsFormInteger: "fsFormInteger", validationMessage: ["fsFormIntegerMessage", "validationMessage"] }, providers: [
|
|
1897
|
+
VALIDATE_MESSAGE_PROVIDER,
|
|
1815
1898
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1816
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1899
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormIntegerDirective, decorators: [{
|
|
1817
1900
|
type: Directive,
|
|
1818
1901
|
args: [{
|
|
1819
|
-
selector: '[
|
|
1902
|
+
selector: '[fsFormInteger]',
|
|
1820
1903
|
providers: [
|
|
1821
|
-
VALIDATE_MESSAGE_PROVIDER
|
|
1904
|
+
VALIDATE_MESSAGE_PROVIDER,
|
|
1822
1905
|
],
|
|
1823
1906
|
}]
|
|
1824
|
-
}], propDecorators: {
|
|
1907
|
+
}], propDecorators: { fsFormInteger: [{
|
|
1825
1908
|
type: Input
|
|
1826
1909
|
}], validationMessage: [{
|
|
1827
1910
|
type: Input,
|
|
1828
|
-
args: ['
|
|
1911
|
+
args: ['fsFormIntegerMessage']
|
|
1829
1912
|
}] } });
|
|
1830
1913
|
|
|
1831
|
-
class
|
|
1832
|
-
constructor() {
|
|
1833
|
-
super(...arguments);
|
|
1834
|
-
this.fsFormUrlProtocol = false;
|
|
1835
|
-
}
|
|
1914
|
+
class FsFormLesserEqualDirective extends FsControlDirective {
|
|
1836
1915
|
set validationMessage(value) {
|
|
1837
|
-
this._validateMessages.
|
|
1916
|
+
this._validateMessages.lesser = value;
|
|
1838
1917
|
}
|
|
1839
1918
|
ngOnChanges() {
|
|
1840
1919
|
this._control.updateValueAndValidity();
|
|
1841
1920
|
}
|
|
1842
1921
|
validate(control) {
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
return null;
|
|
1922
|
+
const lesser = parseFloat(this.fsFormLesserEqual);
|
|
1923
|
+
const value = parseFloat(this._control.value);
|
|
1924
|
+
if (!isNaN(lesser) && !isNaN(value) && value > lesser) {
|
|
1925
|
+
return { lesserEqual: { lesser, actual: value } };
|
|
1848
1926
|
}
|
|
1927
|
+
return FsValidators.numeric(this._control);
|
|
1849
1928
|
}
|
|
1850
1929
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1930
|
+
FsFormLesserEqualDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1931
|
+
FsFormLesserEqualDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserEqualDirective, selector: "[fsFormLesserEqual]", inputs: { fsFormLesserEqual: "fsFormLesserEqual", validationMessage: ["fsFormLesserEqualMessage", "validationMessage"] }, providers: [
|
|
1853
1932
|
VALIDATE_MESSAGE_PROVIDER
|
|
1854
1933
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1855
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
1934
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserEqualDirective, decorators: [{
|
|
1856
1935
|
type: Directive,
|
|
1857
1936
|
args: [{
|
|
1858
|
-
selector: '[
|
|
1937
|
+
selector: '[fsFormLesserEqual]',
|
|
1859
1938
|
providers: [
|
|
1860
1939
|
VALIDATE_MESSAGE_PROVIDER
|
|
1861
1940
|
],
|
|
1862
1941
|
}]
|
|
1863
|
-
}], propDecorators: {
|
|
1864
|
-
type: Input
|
|
1865
|
-
}], fsFormUrlProtocol: [{
|
|
1942
|
+
}], propDecorators: { fsFormLesserEqual: [{
|
|
1866
1943
|
type: Input
|
|
1867
1944
|
}], validationMessage: [{
|
|
1868
1945
|
type: Input,
|
|
1869
|
-
args: ['
|
|
1870
|
-
}] } });
|
|
1871
|
-
|
|
1872
|
-
class FsFormDialogCloseDirective {
|
|
1873
|
-
constructor(_form, _dialogRef) {
|
|
1874
|
-
this._form = _form;
|
|
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']]
|
|
1946
|
+
args: ['fsFormLesserEqualMessage']
|
|
1917
1947
|
}] } });
|
|
1918
1948
|
|
|
1919
|
-
class
|
|
1920
|
-
|
|
1921
|
-
this.
|
|
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
|
-
}
|
|
1949
|
+
class FsFormLesserDirective extends FsControlDirective {
|
|
1950
|
+
set validationMessage(value) {
|
|
1951
|
+
this._validateMessages.lesser = value;
|
|
1976
1952
|
}
|
|
1977
|
-
|
|
1978
|
-
this.
|
|
1979
|
-
if (this._matButton) {
|
|
1980
|
-
this._matButton.disableRipple = false;
|
|
1981
|
-
}
|
|
1953
|
+
ngOnChanges() {
|
|
1954
|
+
this._control.updateValueAndValidity();
|
|
1982
1955
|
}
|
|
1983
|
-
|
|
1984
|
-
this.
|
|
1985
|
-
|
|
1986
|
-
|
|
1956
|
+
validate(control) {
|
|
1957
|
+
const lesser = parseFloat(this.fsFormLesser);
|
|
1958
|
+
const value = parseFloat(this._control.value);
|
|
1959
|
+
if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
|
|
1960
|
+
return { lesser: { lesser, actual: value } };
|
|
1987
1961
|
}
|
|
1962
|
+
return FsValidators.numeric(this._control);
|
|
1988
1963
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
1964
|
+
}
|
|
1965
|
+
FsFormLesserDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1966
|
+
FsFormLesserDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormLesserDirective, selector: "[fsFormLesser]", inputs: { fsFormLesser: "fsFormLesser", validationMessage: ["fsFormLesserMessage", "validationMessage"] }, providers: [
|
|
1967
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
1968
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1969
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormLesserDirective, decorators: [{
|
|
1970
|
+
type: Directive,
|
|
1971
|
+
args: [{
|
|
1972
|
+
selector: '[fsFormLesser]',
|
|
1973
|
+
providers: [
|
|
1974
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
1975
|
+
],
|
|
1976
|
+
}]
|
|
1977
|
+
}], propDecorators: { fsFormLesser: [{
|
|
1978
|
+
type: Input
|
|
1979
|
+
}], validationMessage: [{
|
|
1980
|
+
type: Input,
|
|
1981
|
+
args: ['fsFormLesserMessage']
|
|
1982
|
+
}] } });
|
|
1983
|
+
|
|
1984
|
+
class FsFormMaxDirective extends FsControlDirective {
|
|
1985
|
+
set validationMessage(value) {
|
|
1986
|
+
this._validateMessages.max = value;
|
|
2001
1987
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
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();
|
|
1988
|
+
ngOnChanges() {
|
|
1989
|
+
this._control.updateValueAndValidity();
|
|
2014
1990
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
this._destroy$.next();
|
|
2018
|
-
this._destroy$.complete();
|
|
2019
|
-
(_a = this.form) === null || _a === void 0 ? void 0 : _a.removeButton(this);
|
|
1991
|
+
validate(control) {
|
|
1992
|
+
return FsValidators.numeric(this._control) || Validators.max(this.fsFormMax)(this._control);
|
|
2020
1993
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
1994
|
+
}
|
|
1995
|
+
FsFormMaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1996
|
+
FsFormMaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxDirective, selector: "[fsFormMax]", inputs: { fsFormMax: "fsFormMax", validationMessage: ["fsFormMaxMessage", "validationMessage"] }, providers: [
|
|
1997
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
1998
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1999
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxDirective, decorators: [{
|
|
2000
|
+
type: Directive,
|
|
2001
|
+
args: [{
|
|
2002
|
+
selector: '[fsFormMax]',
|
|
2003
|
+
providers: [
|
|
2004
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2005
|
+
],
|
|
2006
|
+
}]
|
|
2007
|
+
}], propDecorators: { fsFormMax: [{
|
|
2008
|
+
type: Input
|
|
2009
|
+
}], validationMessage: [{
|
|
2010
|
+
type: Input,
|
|
2011
|
+
args: ['fsFormMaxMessage']
|
|
2012
|
+
}] } });
|
|
2013
|
+
|
|
2014
|
+
class FsFormMaxLengthDirective extends FsControlDirective {
|
|
2015
|
+
set validationMessage(value) {
|
|
2016
|
+
this._validateMessages.maxlength = value;
|
|
2024
2017
|
}
|
|
2025
|
-
|
|
2026
|
-
this.
|
|
2018
|
+
ngOnChanges() {
|
|
2019
|
+
this._control.updateValueAndValidity();
|
|
2027
2020
|
}
|
|
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
|
-
}
|
|
2021
|
+
validate(control) {
|
|
2022
|
+
return Validators.maxLength(this.fsFormMaxLength)(this._control);
|
|
2052
2023
|
}
|
|
2053
2024
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2025
|
+
FsFormMaxLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2026
|
+
FsFormMaxLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMaxLengthDirective, selector: "[fsFormMaxLength]", inputs: { fsFormMaxLength: "fsFormMaxLength", validationMessage: ["fsFormMaxLengthMessage", "validationMessage"] }, providers: [
|
|
2027
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2028
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2029
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMaxLengthDirective, decorators: [{
|
|
2057
2030
|
type: Directive,
|
|
2058
2031
|
args: [{
|
|
2059
|
-
selector: '[
|
|
2032
|
+
selector: '[fsFormMaxLength]',
|
|
2033
|
+
providers: [
|
|
2034
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2035
|
+
],
|
|
2060
2036
|
}]
|
|
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: [{
|
|
2037
|
+
}], propDecorators: { fsFormMaxLength: [{
|
|
2074
2038
|
type: Input
|
|
2075
|
-
}],
|
|
2076
|
-
type:
|
|
2077
|
-
args: ['
|
|
2039
|
+
}], validationMessage: [{
|
|
2040
|
+
type: Input,
|
|
2041
|
+
args: ['fsFormMaxLengthMessage']
|
|
2078
2042
|
}] } });
|
|
2079
2043
|
|
|
2080
|
-
class
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
this.validateOnSubmit = false;
|
|
2044
|
+
class FsFormMinDirective extends FsControlDirective {
|
|
2045
|
+
set validationMessage(value) {
|
|
2046
|
+
this._validateMessages.min = value;
|
|
2084
2047
|
}
|
|
2085
2048
|
ngOnChanges() {
|
|
2086
2049
|
this._control.updateValueAndValidity();
|
|
2087
2050
|
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
return of(null);
|
|
2091
|
-
}
|
|
2092
|
-
return FsValidators.func(this._control, this.validateFn, this.validateFnData);
|
|
2051
|
+
validate(control) {
|
|
2052
|
+
return FsValidators.numeric(this._control) || Validators.min(parseFloat(this.fsFormMin))(this._control);
|
|
2093
2053
|
}
|
|
2094
2054
|
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2055
|
+
FsFormMinDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2056
|
+
FsFormMinDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinDirective, selector: "[fsFormMin]", inputs: { fsFormMin: "fsFormMin", validationMessage: ["fsFormMinMessage", "validationMessage"] }, providers: [
|
|
2097
2057
|
VALIDATE_MESSAGE_PROVIDER
|
|
2098
2058
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2099
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
2059
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinDirective, decorators: [{
|
|
2100
2060
|
type: Directive,
|
|
2101
2061
|
args: [{
|
|
2102
|
-
selector: '[
|
|
2062
|
+
selector: '[fsFormMin]',
|
|
2103
2063
|
providers: [
|
|
2104
2064
|
VALIDATE_MESSAGE_PROVIDER
|
|
2105
2065
|
],
|
|
2106
2066
|
}]
|
|
2107
|
-
}], propDecorators: {
|
|
2108
|
-
type: Input,
|
|
2109
|
-
args: ['validate']
|
|
2110
|
-
}], validateFnData: [{
|
|
2111
|
-
type: Input,
|
|
2112
|
-
args: ['validateData']
|
|
2113
|
-
}], validateOnSubmit: [{
|
|
2067
|
+
}], propDecorators: { fsFormMin: [{
|
|
2114
2068
|
type: Input
|
|
2069
|
+
}], validationMessage: [{
|
|
2070
|
+
type: Input,
|
|
2071
|
+
args: ['fsFormMinMessage']
|
|
2115
2072
|
}] } });
|
|
2116
2073
|
|
|
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();
|
|
2074
|
+
class FsFormMinLengthDirective extends FsControlDirective {
|
|
2075
|
+
set validationMessage(value) {
|
|
2076
|
+
this._validateMessages.minlength = value;
|
|
2129
2077
|
}
|
|
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
|
-
}
|
|
2078
|
+
ngOnChanges() {
|
|
2079
|
+
this._control.updateValueAndValidity();
|
|
2151
2080
|
}
|
|
2152
|
-
|
|
2153
|
-
this.
|
|
2154
|
-
this._destroy$.complete();
|
|
2081
|
+
validate(control) {
|
|
2082
|
+
return Validators.minLength(this.fsFormMinLength)(this._control);
|
|
2155
2083
|
}
|
|
2156
2084
|
}
|
|
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: [{
|
|
2085
|
+
FsFormMinLengthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2086
|
+
FsFormMinLengthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormMinLengthDirective, selector: "[fsFormMinLength]", inputs: { fsFormMinLength: "fsFormMinLength", validationMessage: ["fsFormMinLengthMessage", "validationMessage"] }, providers: [
|
|
2087
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2088
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2089
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormMinLengthDirective, decorators: [{
|
|
2090
|
+
type: Directive,
|
|
2091
|
+
args: [{
|
|
2092
|
+
selector: '[fsFormMinLength]',
|
|
2093
|
+
providers: [
|
|
2094
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2095
|
+
],
|
|
2096
|
+
}]
|
|
2097
|
+
}], propDecorators: { fsFormMinLength: [{
|
|
2179
2098
|
type: Input
|
|
2099
|
+
}], validationMessage: [{
|
|
2100
|
+
type: Input,
|
|
2101
|
+
args: ['fsFormMinLengthMessage']
|
|
2180
2102
|
}] } });
|
|
2181
2103
|
|
|
2182
2104
|
/**
|
|
@@ -2226,158 +2148,247 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
2226
2148
|
VALIDATE_MESSAGE_PROVIDER
|
|
2227
2149
|
],
|
|
2228
2150
|
}]
|
|
2229
|
-
}] });
|
|
2151
|
+
}] });
|
|
2152
|
+
|
|
2153
|
+
class FsFormNumericDirective extends FsControlDirective {
|
|
2154
|
+
set validationMessage(value) {
|
|
2155
|
+
this._validateMessages.numeric = value;
|
|
2156
|
+
}
|
|
2157
|
+
ngOnChanges() {
|
|
2158
|
+
this._control.updateValueAndValidity();
|
|
2159
|
+
}
|
|
2160
|
+
validate(control) {
|
|
2161
|
+
if (isEnabled(this.fsFormNumeric)) {
|
|
2162
|
+
return FsValidators.numeric(this._control);
|
|
2163
|
+
}
|
|
2164
|
+
else {
|
|
2165
|
+
return null;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
FsFormNumericDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2170
|
+
FsFormNumericDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormNumericDirective, selector: "[fsFormNumeric]", inputs: { fsFormNumeric: "fsFormNumeric", validationMessage: ["fsFormNumericMessage", "validationMessage"] }, providers: [
|
|
2171
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2172
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2173
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormNumericDirective, decorators: [{
|
|
2174
|
+
type: Directive,
|
|
2175
|
+
args: [{
|
|
2176
|
+
selector: '[fsFormNumeric]',
|
|
2177
|
+
providers: [
|
|
2178
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2179
|
+
],
|
|
2180
|
+
}]
|
|
2181
|
+
}], propDecorators: { fsFormNumeric: [{
|
|
2182
|
+
type: Input
|
|
2183
|
+
}], validationMessage: [{
|
|
2184
|
+
type: Input,
|
|
2185
|
+
args: ['fsFormNumericMessage']
|
|
2186
|
+
}] } });
|
|
2230
2187
|
|
|
2231
|
-
class
|
|
2188
|
+
class FsFormPatternDirective extends FsControlDirective {
|
|
2232
2189
|
set validationMessage(value) {
|
|
2233
|
-
this._validateMessages.
|
|
2190
|
+
this._validateMessages.pattern = value;
|
|
2234
2191
|
}
|
|
2235
2192
|
ngOnChanges() {
|
|
2236
2193
|
this._control.updateValueAndValidity();
|
|
2237
2194
|
}
|
|
2238
2195
|
validate(control) {
|
|
2239
|
-
|
|
2240
|
-
const value = parseFloat(this._control.value);
|
|
2241
|
-
if (!isNaN(greater) && !isNaN(value) && value < greater) {
|
|
2242
|
-
return { greaterEqual: { greater, actual: value } };
|
|
2243
|
-
}
|
|
2244
|
-
return FsValidators.numeric(this._control);
|
|
2196
|
+
return Validators.pattern(this.fsFormPattern)(this._control);
|
|
2245
2197
|
}
|
|
2246
2198
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2199
|
+
FsFormPatternDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2200
|
+
FsFormPatternDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPatternDirective, selector: "[fsFormPattern]", inputs: { fsFormPattern: "fsFormPattern", validationMessage: ["fsFormPatternMessage", "validationMessage"] }, providers: [
|
|
2249
2201
|
VALIDATE_MESSAGE_PROVIDER
|
|
2250
2202
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2251
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
2203
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPatternDirective, decorators: [{
|
|
2252
2204
|
type: Directive,
|
|
2253
2205
|
args: [{
|
|
2254
|
-
selector: '[
|
|
2206
|
+
selector: '[fsFormPattern]',
|
|
2255
2207
|
providers: [
|
|
2256
2208
|
VALIDATE_MESSAGE_PROVIDER
|
|
2257
2209
|
],
|
|
2258
2210
|
}]
|
|
2259
|
-
}], propDecorators: {
|
|
2211
|
+
}], propDecorators: { fsFormPattern: [{
|
|
2260
2212
|
type: Input
|
|
2261
2213
|
}], validationMessage: [{
|
|
2262
2214
|
type: Input,
|
|
2263
|
-
args: ['
|
|
2215
|
+
args: ['fsFormPatternMessage']
|
|
2264
2216
|
}] } });
|
|
2265
2217
|
|
|
2266
|
-
class
|
|
2218
|
+
class FsFormPhoneDirective extends FsControlDirective {
|
|
2267
2219
|
set validationMessage(value) {
|
|
2268
|
-
this._validateMessages.
|
|
2220
|
+
this._validateMessages.phone = value;
|
|
2269
2221
|
}
|
|
2270
2222
|
ngOnChanges() {
|
|
2271
2223
|
this._control.updateValueAndValidity();
|
|
2272
2224
|
}
|
|
2273
2225
|
validate(control) {
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2226
|
+
if (isEnabled(this.fsFormPhone)) {
|
|
2227
|
+
return FsValidators.phone(this._control);
|
|
2228
|
+
}
|
|
2229
|
+
else {
|
|
2230
|
+
return null;
|
|
2278
2231
|
}
|
|
2279
|
-
return FsValidators.numeric(this._control);
|
|
2280
2232
|
}
|
|
2281
2233
|
}
|
|
2282
|
-
|
|
2283
|
-
|
|
2234
|
+
FsFormPhoneDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2235
|
+
FsFormPhoneDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FsFormPhoneDirective, selector: "[fsFormPhone]", inputs: { fsFormPhone: "fsFormPhone", validationMessage: ["fsFormPhoneMessage", "validationMessage"] }, providers: [
|
|
2284
2236
|
VALIDATE_MESSAGE_PROVIDER
|
|
2285
2237
|
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2286
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type:
|
|
2238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormPhoneDirective, decorators: [{
|
|
2287
2239
|
type: Directive,
|
|
2288
2240
|
args: [{
|
|
2289
|
-
selector: '[
|
|
2241
|
+
selector: '[fsFormPhone]',
|
|
2290
2242
|
providers: [
|
|
2291
2243
|
VALIDATE_MESSAGE_PROVIDER
|
|
2292
2244
|
],
|
|
2293
2245
|
}]
|
|
2294
|
-
}], propDecorators: {
|
|
2246
|
+
}], propDecorators: { fsFormPhone: [{
|
|
2295
2247
|
type: Input
|
|
2296
2248
|
}], validationMessage: [{
|
|
2297
2249
|
type: Input,
|
|
2298
|
-
args: ['
|
|
2250
|
+
args: ['fsFormPhoneMessage']
|
|
2299
2251
|
}] } });
|
|
2300
2252
|
|
|
2301
|
-
class
|
|
2302
|
-
constructor() {
|
|
2303
|
-
|
|
2253
|
+
class FsFormRequiredDirective extends FsControlDirective {
|
|
2254
|
+
constructor() {
|
|
2255
|
+
super(...arguments);
|
|
2256
|
+
this.required = false;
|
|
2257
|
+
}
|
|
2258
|
+
set setFsFormRequired(value) {
|
|
2259
|
+
this.required = isEnabled(value);
|
|
2260
|
+
}
|
|
2261
|
+
set setRequired(value) {
|
|
2262
|
+
this.required = isEnabled(value);
|
|
2263
|
+
}
|
|
2264
|
+
set validationMessage(value) {
|
|
2265
|
+
this._validateMessages.required = value;
|
|
2266
|
+
}
|
|
2267
|
+
ngOnChanges() {
|
|
2268
|
+
this._control.updateValueAndValidity();
|
|
2269
|
+
}
|
|
2270
|
+
validate(control) {
|
|
2271
|
+
if (this.required) {
|
|
2272
|
+
return Validators.required(this._control);
|
|
2273
|
+
}
|
|
2274
|
+
return null;
|
|
2275
|
+
}
|
|
2276
|
+
render() {
|
|
2277
|
+
const wrapper = this.getWrapperElement();
|
|
2278
|
+
if (wrapper && this.getlabelSelector()) {
|
|
2279
|
+
const labelWrapper = wrapper.querySelector(this.getlabelSelector());
|
|
2280
|
+
// Adding class fs-form-label-requried adds the * to the label
|
|
2281
|
+
if (labelWrapper) {
|
|
2282
|
+
if (this.required) {
|
|
2283
|
+
this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
|
|
2284
|
+
}
|
|
2285
|
+
else {
|
|
2286
|
+
this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
super.render();
|
|
2304
2291
|
}
|
|
2305
2292
|
}
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2293
|
+
FsFormRequiredDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2294
|
+
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: [
|
|
2295
|
+
VALIDATE_MESSAGE_PROVIDER,
|
|
2296
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2297
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormRequiredDirective, decorators: [{
|
|
2309
2298
|
type: Directive,
|
|
2310
2299
|
args: [{
|
|
2311
|
-
selector: '[
|
|
2300
|
+
selector: '[fsFormRequired],[ngModel][required]',
|
|
2301
|
+
providers: [
|
|
2302
|
+
VALIDATE_MESSAGE_PROVIDER,
|
|
2303
|
+
],
|
|
2312
2304
|
}]
|
|
2313
|
-
}],
|
|
2314
|
-
type:
|
|
2315
|
-
args: [
|
|
2305
|
+
}], propDecorators: { setFsFormRequired: [{
|
|
2306
|
+
type: Input,
|
|
2307
|
+
args: ['fsFormRequired']
|
|
2308
|
+
}], setRequired: [{
|
|
2309
|
+
type: Input,
|
|
2310
|
+
args: ['required']
|
|
2311
|
+
}], validationMessage: [{
|
|
2312
|
+
type: Input,
|
|
2313
|
+
args: ['fsFormRequiredMessage']
|
|
2316
2314
|
}] } });
|
|
2317
2315
|
|
|
2318
|
-
class
|
|
2316
|
+
class FsFormUrlDirective extends FsControlDirective {
|
|
2317
|
+
constructor() {
|
|
2318
|
+
super(...arguments);
|
|
2319
|
+
this.fsFormUrlProtocol = false;
|
|
2320
|
+
}
|
|
2321
|
+
set validationMessage(value) {
|
|
2322
|
+
this._validateMessages.url = value;
|
|
2323
|
+
}
|
|
2324
|
+
ngOnChanges() {
|
|
2325
|
+
this._control.updateValueAndValidity();
|
|
2326
|
+
}
|
|
2327
|
+
validate(control) {
|
|
2328
|
+
if (isEnabled(this.fsFormUrl)) {
|
|
2329
|
+
return FsValidators.url(this._control, this.fsFormUrlProtocol);
|
|
2330
|
+
}
|
|
2331
|
+
else {
|
|
2332
|
+
return null;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2319
2335
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2336
|
+
FsFormUrlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2337
|
+
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: [
|
|
2338
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2339
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2340
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormUrlDirective, decorators: [{
|
|
2323
2341
|
type: Directive,
|
|
2324
2342
|
args: [{
|
|
2325
|
-
selector: '
|
|
2343
|
+
selector: '[fsFormUrl]',
|
|
2344
|
+
providers: [
|
|
2345
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2346
|
+
],
|
|
2326
2347
|
}]
|
|
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
|
-
});
|
|
2337
|
-
}
|
|
2338
|
-
ngOnInit() {
|
|
2339
|
-
debugger;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
FsFormTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2343
|
-
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 });
|
|
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: [{
|
|
2348
|
+
}], propDecorators: { fsFormUrl: [{
|
|
2351
2349
|
type: Input
|
|
2352
|
-
}],
|
|
2353
|
-
type:
|
|
2354
|
-
|
|
2350
|
+
}], fsFormUrlProtocol: [{
|
|
2351
|
+
type: Input
|
|
2352
|
+
}], validationMessage: [{
|
|
2353
|
+
type: Input,
|
|
2354
|
+
args: ['fsFormUrlMessage']
|
|
2355
2355
|
}] } });
|
|
2356
2356
|
|
|
2357
|
-
class
|
|
2358
|
-
constructor() {
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
if ((_a = changes.formTemplate) === null || _a === void 0 ? void 0 : _a.currentValue) {
|
|
2362
|
-
}
|
|
2357
|
+
class FsFormValidateDirective extends FsControlDirective {
|
|
2358
|
+
constructor() {
|
|
2359
|
+
super(...arguments);
|
|
2360
|
+
this.validateOnSubmit = false;
|
|
2363
2361
|
}
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2362
|
+
ngOnChanges() {
|
|
2363
|
+
this._control.updateValueAndValidity();
|
|
2364
|
+
}
|
|
2365
|
+
validateAsync(control) {
|
|
2366
|
+
if (this.validateOnSubmit && !this.formDirective.validating) {
|
|
2367
|
+
return of(null);
|
|
2368
|
+
}
|
|
2369
|
+
return FsValidators.func(this._control, this.validateFn, this.validateFnData);
|
|
2369
2370
|
}
|
|
2370
2371
|
}
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2372
|
+
FsFormValidateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2373
|
+
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: [
|
|
2374
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2375
|
+
], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
2376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormValidateDirective, decorators: [{
|
|
2377
|
+
type: Directive,
|
|
2378
|
+
args: [{
|
|
2379
|
+
selector: '[validate]',
|
|
2380
|
+
providers: [
|
|
2381
|
+
VALIDATE_MESSAGE_PROVIDER
|
|
2382
|
+
],
|
|
2383
|
+
}]
|
|
2384
|
+
}], propDecorators: { validateFn: [{
|
|
2385
|
+
type: Input,
|
|
2386
|
+
args: ['validate']
|
|
2387
|
+
}], validateFnData: [{
|
|
2388
|
+
type: Input,
|
|
2389
|
+
args: ['validateData']
|
|
2390
|
+
}], validateOnSubmit: [{
|
|
2377
2391
|
type: Input
|
|
2378
|
-
}], models: [{
|
|
2379
|
-
type: ContentChildren,
|
|
2380
|
-
args: [NgModel, { descendants: true }]
|
|
2381
2392
|
}] } });
|
|
2382
2393
|
|
|
2383
2394
|
class FsFormModule {
|
|
@@ -2385,7 +2396,8 @@ class FsFormModule {
|
|
|
2385
2396
|
/**
|
|
2386
2397
|
* Hack: https://github.com/angular/components/issues/20097
|
|
2387
2398
|
*/
|
|
2388
|
-
ErrorStateMatcher.prototype
|
|
2399
|
+
ErrorStateMatcher.prototype
|
|
2400
|
+
.isErrorState = (control, form) => {
|
|
2389
2401
|
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
2402
|
};
|
|
2391
2403
|
return {
|
|
@@ -2423,10 +2435,13 @@ FsFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
|
|
|
2423
2435
|
FsSubmitButtonDirective,
|
|
2424
2436
|
FsFormTemplateComponent,
|
|
2425
2437
|
FsFormTemplateDirective,
|
|
2426
|
-
FsFormTemplateOutletComponent
|
|
2438
|
+
FsFormTemplateOutletComponent,
|
|
2439
|
+
ConfirmUnsavedComponent], imports: [CommonModule,
|
|
2427
2440
|
FormsModule,
|
|
2428
2441
|
MatButtonModule,
|
|
2429
|
-
MatDialogModule
|
|
2442
|
+
MatDialogModule,
|
|
2443
|
+
MatDialogModule,
|
|
2444
|
+
FsDialogModule], exports: [FsFormDirective,
|
|
2430
2445
|
FsControlDirective,
|
|
2431
2446
|
FsFormRequiredDirective,
|
|
2432
2447
|
FsFormMinDirective,
|
|
@@ -2466,6 +2481,8 @@ FsFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
|
2466
2481
|
FormsModule,
|
|
2467
2482
|
MatButtonModule,
|
|
2468
2483
|
MatDialogModule,
|
|
2484
|
+
MatDialogModule,
|
|
2485
|
+
FsDialogModule,
|
|
2469
2486
|
]] });
|
|
2470
2487
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsFormModule, decorators: [{
|
|
2471
2488
|
type: NgModule,
|
|
@@ -2475,6 +2492,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
2475
2492
|
FormsModule,
|
|
2476
2493
|
MatButtonModule,
|
|
2477
2494
|
MatDialogModule,
|
|
2495
|
+
MatDialogModule,
|
|
2496
|
+
FsDialogModule,
|
|
2478
2497
|
],
|
|
2479
2498
|
declarations: [
|
|
2480
2499
|
FsFormDirective,
|
|
@@ -2507,6 +2526,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
2507
2526
|
FsFormTemplateComponent,
|
|
2508
2527
|
FsFormTemplateDirective,
|
|
2509
2528
|
FsFormTemplateOutletComponent,
|
|
2529
|
+
ConfirmUnsavedComponent,
|
|
2510
2530
|
],
|
|
2511
2531
|
exports: [
|
|
2512
2532
|
FsFormDirective,
|