@firestitch/form 12.4.16 → 12.4.18
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/directives/form/form.directive.d.ts +7 -5
- package/bundles/firestitch-form.umd.js +94 -87
- package/bundles/firestitch-form.umd.js.map +1 -1
- package/esm2015/app/components/form-dialog-actions/form-dialog-actions.component.js +2 -2
- package/esm2015/app/directives/form/form.directive.js +16 -9
- package/fesm2015/firestitch-form.js +80 -73
- package/fesm2015/firestitch-form.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Directive, HostBinding, HostListener,
|
|
2
|
+
import { Injectable, Directive, HostBinding, HostListener, EventEmitter, QueryList, Inject, Optional, Input, Output, ContentChildren, InjectionToken, Self, Host, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
3
3
|
import * as i4 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i1$1 from '@angular/forms';
|
|
@@ -11,12 +11,12 @@ import { MatDialogRef, MatDialogModule } from '@angular/material/dialog';
|
|
|
11
11
|
import { ErrorStateMatcher, ShowOnDirtyErrorStateMatcher } from '@angular/material/core';
|
|
12
12
|
import * as i3 from '@angular/router';
|
|
13
13
|
import { MatTabGroup } from '@angular/material/tabs';
|
|
14
|
-
import * as i2 from '@firestitch/message';
|
|
15
|
-
import { MessageMode } from '@firestitch/message';
|
|
16
|
-
import * as i1 from '@firestitch/prompt';
|
|
17
14
|
import { guid, email, isEmpty, isNumeric, phone, url } from '@firestitch/common';
|
|
18
15
|
import * as i7 from '@firestitch/drawer';
|
|
19
16
|
import { DrawerRef } from '@firestitch/drawer';
|
|
17
|
+
import * as i2 from '@firestitch/message';
|
|
18
|
+
import { MessageMode } from '@firestitch/message';
|
|
19
|
+
import * as i1 from '@firestitch/prompt';
|
|
20
20
|
import { Observable, Subject, of, BehaviorSubject, isObservable, throwError, fromEvent, iif, defer, from } from 'rxjs';
|
|
21
21
|
import { first, filter, map, take, mergeMap, tap, switchMap, mapTo, catchError, takeUntil, delay, startWith } from 'rxjs/operators';
|
|
22
22
|
import { values, keys, isObject } from 'lodash-es';
|
|
@@ -100,33 +100,9 @@ function confirmUnsaved(directives, prompt) {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.registered = false;
|
|
107
|
-
this.type = 'button';
|
|
108
|
-
}
|
|
109
|
-
click() {
|
|
110
|
-
this.clicked$.next();
|
|
111
|
-
}
|
|
112
|
-
ngOnDestroy() {
|
|
113
|
-
this.clicked$.complete();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
FsFormDialogCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
117
|
-
FsFormDialogCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", host: { listeners: { "click": "click($event.target)" }, properties: { "attr.type": "this.type" } }, ngImport: i0 });
|
|
118
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
|
|
119
|
-
type: Directive,
|
|
120
|
-
args: [{
|
|
121
|
-
selector: '[fsFormDialogClose],[fs-form-dialog-close]'
|
|
122
|
-
}]
|
|
123
|
-
}], propDecorators: { type: [{
|
|
124
|
-
type: HostBinding,
|
|
125
|
-
args: ['attr.type']
|
|
126
|
-
}], click: [{
|
|
127
|
-
type: HostListener,
|
|
128
|
-
args: ['click', ['$event.target']]
|
|
129
|
-
}] } });
|
|
103
|
+
function confirmResultContinue(result) {
|
|
104
|
+
return result === ConfirmResult.Discard || result === ConfirmResult.Save || result === ConfirmResult.Pristine;
|
|
105
|
+
}
|
|
130
106
|
|
|
131
107
|
class FsForm {
|
|
132
108
|
constructor() {
|
|
@@ -164,46 +140,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
164
140
|
}]
|
|
165
141
|
}], ctorParameters: function () { return []; } });
|
|
166
142
|
|
|
167
|
-
var FormStatus;
|
|
168
|
-
(function (FormStatus) {
|
|
169
|
-
FormStatus["Valid"] = "valid";
|
|
170
|
-
FormStatus["Invalid"] = "invalid";
|
|
171
|
-
FormStatus["Validating"] = "validating";
|
|
172
|
-
FormStatus["Submitting"] = "submitting";
|
|
173
|
-
FormStatus["Submitted"] = "submitted";
|
|
174
|
-
FormStatus["Error"] = "error";
|
|
175
|
-
FormStatus["Success"] = "success";
|
|
176
|
-
FormStatus["Completing"] = "completing";
|
|
177
|
-
})(FormStatus || (FormStatus = {}));
|
|
178
|
-
|
|
179
|
-
function confirmResultContinue(result) {
|
|
180
|
-
return result === ConfirmResult.Discard || result === ConfirmResult.Save || result === ConfirmResult.Pristine;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function getFormErrors(control, key) {
|
|
184
|
-
let errors = null;
|
|
185
|
-
if (control.invalid && control.errors) {
|
|
186
|
-
errors = {
|
|
187
|
-
[key]: Object.assign({}, control.errors),
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
if (control instanceof FormGroup) {
|
|
191
|
-
Object.entries(control.controls)
|
|
192
|
-
.forEach(([name, childControl]) => {
|
|
193
|
-
const childErrors = getFormErrors(childControl, name);
|
|
194
|
-
if (childErrors) {
|
|
195
|
-
if (!errors) {
|
|
196
|
-
errors = Object.assign({}, childErrors);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
Object.assign(errors, childErrors);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return errors;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
143
|
function getActiveRoute(route) {
|
|
208
144
|
while (route.firstChild) {
|
|
209
145
|
route = route.firstChild;
|
|
@@ -243,6 +179,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
243
179
|
}]
|
|
244
180
|
}], ctorParameters: function () { return [{ type: i1.FsPrompt }, { type: FsForm }, { type: i3.ActivatedRoute }]; } });
|
|
245
181
|
|
|
182
|
+
function getFormErrors(control, key) {
|
|
183
|
+
let errors = null;
|
|
184
|
+
if (control.invalid && control.errors) {
|
|
185
|
+
errors = {
|
|
186
|
+
[key]: Object.assign({}, control.errors),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (control instanceof FormGroup) {
|
|
190
|
+
Object.entries(control.controls)
|
|
191
|
+
.forEach(([name, childControl]) => {
|
|
192
|
+
const childErrors = getFormErrors(childControl, name);
|
|
193
|
+
if (childErrors) {
|
|
194
|
+
if (!errors) {
|
|
195
|
+
errors = Object.assign({}, childErrors);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
Object.assign(errors, childErrors);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return errors;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
class FsFormDialogCloseDirective {
|
|
207
|
+
constructor() {
|
|
208
|
+
this.clicked$ = new Subject();
|
|
209
|
+
this.registered = false;
|
|
210
|
+
this.type = 'button';
|
|
211
|
+
}
|
|
212
|
+
click() {
|
|
213
|
+
this.clicked$.next();
|
|
214
|
+
}
|
|
215
|
+
ngOnDestroy() {
|
|
216
|
+
this.clicked$.complete();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
FsFormDialogCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
220
|
+
FsFormDialogCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsFormDialogCloseDirective, selector: "[fsFormDialogClose],[fs-form-dialog-close]", host: { listeners: { "click": "click($event.target)" }, properties: { "attr.type": "this.type" } }, ngImport: i0 });
|
|
221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogCloseDirective, decorators: [{
|
|
222
|
+
type: Directive,
|
|
223
|
+
args: [{
|
|
224
|
+
selector: '[fsFormDialogClose],[fs-form-dialog-close]'
|
|
225
|
+
}]
|
|
226
|
+
}], propDecorators: { type: [{
|
|
227
|
+
type: HostBinding,
|
|
228
|
+
args: ['attr.type']
|
|
229
|
+
}], click: [{
|
|
230
|
+
type: HostListener,
|
|
231
|
+
args: ['click', ['$event.target']]
|
|
232
|
+
}] } });
|
|
233
|
+
|
|
234
|
+
var FormStatus;
|
|
235
|
+
(function (FormStatus) {
|
|
236
|
+
FormStatus["Valid"] = "valid";
|
|
237
|
+
FormStatus["Invalid"] = "invalid";
|
|
238
|
+
FormStatus["Validating"] = "validating";
|
|
239
|
+
FormStatus["Submitting"] = "submitting";
|
|
240
|
+
FormStatus["Submitted"] = "submitted";
|
|
241
|
+
FormStatus["Error"] = "error";
|
|
242
|
+
FormStatus["Success"] = "success";
|
|
243
|
+
FormStatus["Completing"] = "completing";
|
|
244
|
+
})(FormStatus || (FormStatus = {}));
|
|
245
|
+
|
|
246
246
|
class FsFormDirective {
|
|
247
247
|
constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef, _route) {
|
|
248
248
|
this.ngForm = ngForm;
|
|
@@ -275,6 +275,7 @@ class FsFormDirective {
|
|
|
275
275
|
this.submitted = new EventEmitter();
|
|
276
276
|
this.reseted = new EventEmitter();
|
|
277
277
|
this.cleared = new EventEmitter();
|
|
278
|
+
this.submitRegistered = new EventEmitter();
|
|
278
279
|
this.fsFormClass = true;
|
|
279
280
|
this._tabGroups = new QueryList();
|
|
280
281
|
this._buttons = new QueryList();
|
|
@@ -357,6 +358,10 @@ class FsFormDirective {
|
|
|
357
358
|
this._updateDirtySubmitButtons();
|
|
358
359
|
}
|
|
359
360
|
}
|
|
361
|
+
registerSubmit(fn) {
|
|
362
|
+
this.submit = fn;
|
|
363
|
+
this.submitRegistered.emit();
|
|
364
|
+
}
|
|
360
365
|
ngAfterContentInit() {
|
|
361
366
|
this._registerConfirm();
|
|
362
367
|
this._registerConfirmDialogClose();
|
|
@@ -834,7 +839,7 @@ class FsFormDirective {
|
|
|
834
839
|
}
|
|
835
840
|
}
|
|
836
841
|
FsFormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, deps: [{ token: NgForm }, { token: FsForm }, { token: i0.ElementRef }, { token: i2.FsMessage }, { token: i1.FsPrompt }, { token: i0.NgZone }, { token: MatDialogRef, optional: true }, { token: DrawerRef, optional: true }, { token: i3.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Directive });
|
|
837
|
-
FsFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", 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: "formDialogClose", predicate: FsFormDialogCloseDirective, descendants: true }, { propertyName: "_tabGroups", predicate: MatTabGroup, descendants: true }], usesOnChanges: true, ngImport: i0 });
|
|
842
|
+
FsFormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", 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", submitRegistered: "submitRegistered" }, host: { properties: { "class.fs-form": "this.fsFormClass" } }, queries: [{ propertyName: "formDialogClose", predicate: FsFormDialogCloseDirective, descendants: true }, { propertyName: "_tabGroups", predicate: MatTabGroup, descendants: true }], usesOnChanges: true, ngImport: i0 });
|
|
838
843
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, decorators: [{
|
|
839
844
|
type: Directive,
|
|
840
845
|
args: [{
|
|
@@ -900,6 +905,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
900
905
|
type: Output
|
|
901
906
|
}], cleared: [{
|
|
902
907
|
type: Output
|
|
908
|
+
}], submitRegistered: [{
|
|
909
|
+
type: Output
|
|
903
910
|
}], fsFormClass: [{
|
|
904
911
|
type: HostBinding,
|
|
905
912
|
args: ['class.fs-form']
|
|
@@ -2149,7 +2156,7 @@ class FsFormDialogActionsComponent {
|
|
|
2149
2156
|
}
|
|
2150
2157
|
}
|
|
2151
2158
|
FsFormDialogActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, deps: [{ token: FsFormDirective, optional: true }, { token: i2$1.MatDialogRef, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
2152
|
-
FsFormDialogActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", 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=\"buttons\" [ngClass]=\"{ 'save-create': save || create }\">\n <ng-container *ngIf=\"save\">\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 [disabled]=\"close && !dirty && !create\"\n [matDialogClose]=\"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 [matDialogClose]=\"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 <
|
|
2159
|
+
FsFormDialogActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", 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 [disabled]=\"close && !dirty && !create\"\n [matDialogClose]=\"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 [matDialogClose]=\"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\"\n [color]=\"dirty ? 'basic' : 'primary'\"\n (click)=\"closeClick()\">\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{float:right}\n"], components: [{ type: i1$2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: ["name", "dirtySubmit", "form"] }, { type: i2$1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2153
2160
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
|
|
2154
2161
|
type: Component,
|
|
2155
2162
|
args: [{
|