@firestitch/form 12.4.17 → 12.4.19

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, HostBinding, HostListener, Injectable, EventEmitter, QueryList, Inject, Optional, Input, Output, ContentChildren, InjectionToken, Self, Host, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
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
- class FsFormDialogCloseDirective {
104
- constructor() {
105
- this.clicked$ = new Subject();
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,14 +179,79 @@ 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
- constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef, _route) {
247
+ constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _cdRef, _dialogRef, _drawerRef, _route) {
248
248
  this.ngForm = ngForm;
249
249
  this._form = _form;
250
250
  this._element = _element;
251
251
  this._message = _message;
252
252
  this._prompt = _prompt;
253
253
  this._ngZone = _ngZone;
254
+ this._cdRef = _cdRef;
254
255
  this._dialogRef = _dialogRef;
255
256
  this._drawerRef = _drawerRef;
256
257
  this._route = _route;
@@ -275,6 +276,7 @@ class FsFormDirective {
275
276
  this.submitted = new EventEmitter();
276
277
  this.reseted = new EventEmitter();
277
278
  this.cleared = new EventEmitter();
279
+ this.submitRegistered = new EventEmitter();
278
280
  this.fsFormClass = true;
279
281
  this._tabGroups = new QueryList();
280
282
  this._buttons = new QueryList();
@@ -357,6 +359,11 @@ class FsFormDirective {
357
359
  this._updateDirtySubmitButtons();
358
360
  }
359
361
  }
362
+ registerSubmit(fn) {
363
+ this.submit = fn;
364
+ this.submitRegistered.emit();
365
+ this._cdRef.markForCheck();
366
+ }
360
367
  ngAfterContentInit() {
361
368
  this._registerConfirm();
362
369
  this._registerConfirmDialogClose();
@@ -833,8 +840,8 @@ class FsFormDirective {
833
840
  this._form.removeFormDirective(this._activatedRouteConfig.component);
834
841
  }
835
842
  }
836
- 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 });
843
+ 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: i0.ChangeDetectorRef }, { token: MatDialogRef, optional: true }, { token: DrawerRef, optional: true }, { token: i3.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Directive });
844
+ 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
845
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDirective, decorators: [{
839
846
  type: Directive,
840
847
  args: [{
@@ -843,7 +850,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
843
850
  }], ctorParameters: function () { return [{ type: i1$1.NgForm, decorators: [{
844
851
  type: Inject,
845
852
  args: [NgForm]
846
- }] }, { type: FsForm }, { type: i0.ElementRef }, { type: i2.FsMessage }, { type: i1.FsPrompt }, { type: i0.NgZone }, { type: i2$1.MatDialogRef, decorators: [{
853
+ }] }, { type: FsForm }, { type: i0.ElementRef }, { type: i2.FsMessage }, { type: i1.FsPrompt }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i2$1.MatDialogRef, decorators: [{
847
854
  type: Optional
848
855
  }, {
849
856
  type: Inject,
@@ -900,6 +907,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
900
907
  type: Output
901
908
  }], cleared: [{
902
909
  type: Output
910
+ }], submitRegistered: [{
911
+ type: Output
903
912
  }], fsFormClass: [{
904
913
  type: HostBinding,
905
914
  args: ['class.fs-form']
@@ -2149,7 +2158,7 @@ class FsFormDialogActionsComponent {
2149
2158
  }
2150
2159
  }
2151
2160
  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=\"form-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 <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 });
2161
+ 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
2162
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormDialogActionsComponent, decorators: [{
2154
2163
  type: Component,
2155
2164
  args: [{