@firestitch/form 9.6.7 → 9.7.2

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.
@@ -3,8 +3,10 @@ import { FsFormDirective } from '../../directives/form/form.directive';
3
3
  export declare class FsFormDialogActionsComponent implements OnInit, OnDestroy {
4
4
  private _form;
5
5
  private _cdRef;
6
+ save: boolean;
6
7
  create: boolean;
7
8
  close: boolean;
9
+ name: string;
8
10
  dirty: boolean;
9
11
  private _destroy$;
10
12
  constructor(_form: FsFormDirective, _cdRef: ChangeDetectorRef);
@@ -1,4 +1,4 @@
1
- import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, OnInit, QueryList, SimpleChanges } from '@angular/core';
1
+ import { AfterContentInit, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, OnInit, QueryList, SimpleChanges } from '@angular/core';
2
2
  import { NgForm } from '@angular/forms';
3
3
  import { MatDialogRef } from '@angular/material/dialog';
4
4
  import { MatTabGroup } from '@angular/material/tabs';
@@ -18,7 +18,6 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
18
18
  private _element;
19
19
  private _message;
20
20
  private _prompt;
21
- private _cdRef;
22
21
  private _ngZone;
23
22
  private _dialogRef;
24
23
  private _drawerRef;
@@ -52,7 +51,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
52
51
  private _snapshot;
53
52
  private _status$;
54
53
  private _destroy$;
55
- constructor(ngForm: NgForm, _form: FsForm, _element: ElementRef, _message: FsMessage, _prompt: FsPrompt, _cdRef: ChangeDetectorRef, _ngZone: NgZone, _dialogRef: MatDialogRef<any>, _drawerRef: DrawerRef<any>);
54
+ constructor(ngForm: NgForm, _form: FsForm, _element: ElementRef, _message: FsMessage, _prompt: FsPrompt, _ngZone: NgZone, _dialogRef: MatDialogRef<any>, _drawerRef: DrawerRef<any>);
56
55
  get submitting(): boolean;
57
56
  get completing(): boolean;
58
57
  private get _submitEvent();
@@ -1,18 +1,18 @@
1
- import { OnInit, ElementRef, OnDestroy } from '@angular/core';
1
+ import { OnInit, ElementRef, OnDestroy, ChangeDetectorRef } from '@angular/core';
2
2
  import { MatButton } from '@angular/material/button';
3
3
  import { FsFormDirective } from '../directives/form/form.directive';
4
4
  export declare class FsSubmitButtonDirective implements OnInit, OnDestroy {
5
5
  private _matButton;
6
6
  private _form;
7
7
  private _elementRef;
8
+ private _cdRef;
8
9
  name: any;
9
10
  dirtySubmit: boolean;
10
11
  transitionStyle: any;
11
12
  active: boolean;
12
13
  private _destroy$;
13
- constructor(_matButton: MatButton, _form: FsFormDirective, _elementRef: ElementRef);
14
+ constructor(_matButton: MatButton, _form: FsFormDirective, _elementRef: ElementRef, _cdRef: ChangeDetectorRef);
14
15
  ngOnInit(): void;
15
- setFormRef(formRef: FsFormDirective): void;
16
16
  disable(): void;
17
17
  enable(): void;
18
18
  process(): void;
@@ -386,13 +386,12 @@
386
386
  }
387
387
 
388
388
  var FsFormDirective = /** @class */ (function () {
389
- function FsFormDirective(ngForm, _form, _element, _message, _prompt, _cdRef, _ngZone, _dialogRef, _drawerRef) {
389
+ function FsFormDirective(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef) {
390
390
  this.ngForm = ngForm;
391
391
  this._form = _form;
392
392
  this._element = _element;
393
393
  this._message = _message;
394
394
  this._prompt = _prompt;
395
- this._cdRef = _cdRef;
396
395
  this._ngZone = _ngZone;
397
396
  this._dialogRef = _dialogRef;
398
397
  this._drawerRef = _drawerRef;
@@ -898,18 +897,15 @@
898
897
  };
899
898
  FsFormDirective.prototype._updateDirtySubmitButtons = function () {
900
899
  var _this = this;
901
- if (this._submitButtons) {
902
- this._submitButtons.forEach(function (button) {
903
- button.setFormRef(_this);
904
- if (!_this.confirm || !_this.dirtySubmitButton || _this.ngForm.dirty || !button.dirtySubmit) {
905
- button.enable();
906
- }
907
- else {
908
- button.disable();
909
- }
910
- });
911
- this._cdRef.markForCheck();
912
- }
900
+ this._submitButtons
901
+ .forEach(function (submitButton) {
902
+ if (!_this.confirm || !_this.dirtySubmitButton || _this.ngForm.dirty || !submitButton.dirtySubmit) {
903
+ submitButton.enable();
904
+ }
905
+ else {
906
+ submitButton.disable();
907
+ }
908
+ });
913
909
  };
914
910
  FsFormDirective.prototype._broadcastSubmittingEvents = function () {
915
911
  this._status$.next(exports.FormStatus.Submitting);
@@ -952,7 +948,6 @@
952
948
  { type: core.ElementRef },
953
949
  { type: message.FsMessage },
954
950
  { type: prompt.FsPrompt },
955
- { type: core.ChangeDetectorRef },
956
951
  { type: core.NgZone },
957
952
  { type: dialog.MatDialogRef, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MatDialogRef,] }] },
958
953
  { type: drawer.DrawerRef, decorators: [{ type: core.Optional }, { type: core.Inject, args: [drawer.DrawerRef,] }] }
@@ -1054,14 +1049,13 @@
1054
1049
  selector: '[fsForm]',
1055
1050
  }),
1056
1051
  __param(0, core.Inject(forms.NgForm)),
1057
- __param(7, core.Optional()), __param(7, core.Inject(dialog.MatDialogRef)),
1058
- __param(8, core.Optional()), __param(8, core.Inject(drawer.DrawerRef)),
1052
+ __param(6, core.Optional()), __param(6, core.Inject(dialog.MatDialogRef)),
1053
+ __param(7, core.Optional()), __param(7, core.Inject(drawer.DrawerRef)),
1059
1054
  __metadata("design:paramtypes", [forms.NgForm,
1060
1055
  FsForm,
1061
1056
  core.ElementRef,
1062
1057
  message.FsMessage,
1063
1058
  prompt.FsPrompt,
1064
- core.ChangeDetectorRef,
1065
1059
  core.NgZone,
1066
1060
  dialog.MatDialogRef,
1067
1061
  drawer.DrawerRef])
@@ -2218,10 +2212,11 @@
2218
2212
  }(FsControlDirective));
2219
2213
 
2220
2214
  var FsSubmitButtonDirective = /** @class */ (function () {
2221
- function FsSubmitButtonDirective(_matButton, _form, _elementRef) {
2215
+ function FsSubmitButtonDirective(_matButton, _form, _elementRef, _cdRef) {
2222
2216
  this._matButton = _matButton;
2223
2217
  this._form = _form;
2224
2218
  this._elementRef = _elementRef;
2219
+ this._cdRef = _cdRef;
2225
2220
  this.dirtySubmit = true;
2226
2221
  this.transitionStyle = null;
2227
2222
  this.active = false;
@@ -2229,22 +2224,21 @@
2229
2224
  }
2230
2225
  FsSubmitButtonDirective.prototype.ngOnInit = function () {
2231
2226
  var _this = this;
2232
- this._form.addSubmitButton(this);
2233
- rxjs.fromEvent(this.element, 'click')
2234
- .pipe(operators.takeUntil(this._destroy$))
2235
- .subscribe(function () {
2236
- _this.active = true;
2237
- });
2238
- };
2239
- FsSubmitButtonDirective.prototype.setFormRef = function (formRef) {
2240
- var _this = this;
2241
- if (formRef) {
2242
- this.transitionStyle = 'none';
2243
- }
2244
- if (formRef && this.dirtySubmit) {
2245
- if (formRef.dirtySubmitButton) {
2246
- this.disable();
2227
+ if (this._form) {
2228
+ this._form.addSubmitButton(this);
2229
+ rxjs.fromEvent(this.element, 'click')
2230
+ .pipe(operators.takeUntil(this._destroy$))
2231
+ .subscribe(function () {
2232
+ _this.active = true;
2233
+ });
2234
+ if (this.dirtySubmit) {
2235
+ if (this._form.dirtySubmitButton) {
2236
+ if (!this._form.ngForm.dirty) {
2237
+ this.disable();
2238
+ }
2239
+ }
2247
2240
  }
2241
+ this.transitionStyle = 'none';
2248
2242
  setTimeout(function () {
2249
2243
  _this.transitionStyle = null;
2250
2244
  }, 500);
@@ -2253,12 +2247,14 @@
2253
2247
  FsSubmitButtonDirective.prototype.disable = function () {
2254
2248
  if (this._matButton) {
2255
2249
  this._matButton.disabled = true;
2250
+ this._cdRef.markForCheck();
2256
2251
  }
2257
2252
  };
2258
2253
  FsSubmitButtonDirective.prototype.enable = function () {
2259
2254
  if (this._matButton) {
2260
2255
  this._matButton.disabled = false;
2261
2256
  this._matButton.disableRipple = true;
2257
+ this._cdRef.markForCheck();
2262
2258
  }
2263
2259
  };
2264
2260
  FsSubmitButtonDirective.prototype.process = function () {
@@ -2323,7 +2319,8 @@
2323
2319
  FsSubmitButtonDirective.ctorParameters = function () { return [
2324
2320
  { type: button.MatButton, decorators: [{ type: core.Optional }, { type: core.Host }] },
2325
2321
  { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2326
- { type: core.ElementRef }
2322
+ { type: core.ElementRef },
2323
+ { type: core.ChangeDetectorRef }
2327
2324
  ]; };
2328
2325
  __decorate([
2329
2326
  core.Input(),
@@ -2339,13 +2336,14 @@
2339
2336
  ], FsSubmitButtonDirective.prototype, "transitionStyle", void 0);
2340
2337
  FsSubmitButtonDirective = __decorate([
2341
2338
  core.Directive({
2342
- selector: 'form button[type="submit"],form button:not([type])',
2339
+ selector: 'button[type="submit"]',
2343
2340
  }),
2344
2341
  __param(0, core.Optional()), __param(0, core.Host()),
2345
2342
  __param(1, core.Optional()),
2346
2343
  __metadata("design:paramtypes", [button.MatButton,
2347
2344
  FsFormDirective,
2348
- core.ElementRef])
2345
+ core.ElementRef,
2346
+ core.ChangeDetectorRef])
2349
2347
  ], FsSubmitButtonDirective);
2350
2348
  return FsSubmitButtonDirective;
2351
2349
  }());
@@ -2384,8 +2382,9 @@
2384
2382
  function FsFormDialogActionsComponent(_form, _cdRef) {
2385
2383
  this._form = _form;
2386
2384
  this._cdRef = _cdRef;
2385
+ this.save = true;
2387
2386
  this.create = false;
2388
- this.close = true;
2387
+ this.close = false;
2389
2388
  this.dirty = false;
2390
2389
  this._destroy$ = new rxjs.Subject();
2391
2390
  }
@@ -2412,6 +2411,10 @@
2412
2411
  { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2413
2412
  { type: core.ChangeDetectorRef }
2414
2413
  ]; };
2414
+ __decorate([
2415
+ core.Input(),
2416
+ __metadata("design:type", Object)
2417
+ ], FsFormDialogActionsComponent.prototype, "save", void 0);
2415
2418
  __decorate([
2416
2419
  core.Input(),
2417
2420
  __metadata("design:type", Object)
@@ -2420,11 +2423,16 @@
2420
2423
  core.Input(),
2421
2424
  __metadata("design:type", Object)
2422
2425
  ], FsFormDialogActionsComponent.prototype, "close", void 0);
2426
+ __decorate([
2427
+ core.Input(),
2428
+ __metadata("design:type", String)
2429
+ ], FsFormDialogActionsComponent.prototype, "name", void 0);
2423
2430
  FsFormDialogActionsComponent = __decorate([
2424
2431
  core.Component({
2425
2432
  selector: 'fs-form-dialog-actions',
2426
- template: "<button \r\n mat-button \r\n type=\"button\"\r\n color=\"primary\" \r\n *ngIf=\"close && !dirty && !create\"\r\n [matDialogClose]=\"null\">\r\n Close\r\n</button>\r\n<button \r\n mat-button \r\n *ngIf=\"dirty || create || !close\"\r\n type=\"submit\"\r\n color=\"primary\" \r\n name=\"save\">\r\n {{create ? 'Create' : 'Save'}}\r\n</button>\r\n<ng-content></ng-content>\r\n<button \r\n mat-button \r\n type=\"button\"\r\n *ngIf=\"dirty || create || !close\"\r\n [matDialogClose]=\"null\">\r\n Cancel\r\n</button>\r\n",
2427
- changeDetection: core.ChangeDetectionStrategy.OnPush
2433
+ template: "<div class=\"buttons\">\r\n <ng-container *ngIf=\"save\">\r\n <button \r\n mat-button \r\n type=\"submit\"\r\n color=\"primary\" \r\n [name]=\"name\">\r\n {{create ? 'Create' : 'Save'}}\r\n </button>\r\n <button \r\n mat-button \r\n type=\"button\"\r\n [disabled]=\"!dirty && !create\"\r\n [matDialogClose]=\"null\">\r\n Cancel\r\n </button>\r\n </ng-container>\r\n\r\n <ng-content></ng-content>\r\n <div class=\"close\" *ngIf=\"close\">\r\n <button \r\n mat-button \r\n type=\"button\"\r\n [color]=\"dirty ? 'basic' : 'primary'\"\r\n [matDialogClose]=\"null\">\r\n Close\r\n </button>\r\n </div>\r\n</div>",
2434
+ changeDetection: core.ChangeDetectionStrategy.OnPush,
2435
+ styles: [".buttons{display:flex;flex-grow:1;align-items:center}.buttons .close{display:flex;flex-grow:1;justify-content:flex-end}:host{display:flex;flex-grow:1}"]
2428
2436
  }),
2429
2437
  __param(0, core.Optional()),
2430
2438
  __metadata("design:paramtypes", [FsFormDirective,