@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.
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __metadata, __assign, __read, __spread, __param, __extends } from 'tslib';
2
- import { HostBinding, HostListener, Directive, ɵɵdefineInjectable, Injectable, EventEmitter, QueryList, Inject, ElementRef, ChangeDetectorRef, NgZone, Optional, Input, Output, ContentChildren, InjectionToken, Renderer2, Injector, Self, Host, Component, ChangeDetectionStrategy, NgModule, ɵɵinject } from '@angular/core';
2
+ import { HostBinding, HostListener, Directive, ɵɵdefineInjectable, Injectable, EventEmitter, QueryList, Inject, ElementRef, NgZone, Optional, Input, Output, ContentChildren, InjectionToken, Renderer2, Injector, Self, Host, ChangeDetectorRef, Component, ChangeDetectionStrategy, NgModule, ɵɵinject } from '@angular/core';
3
3
  import { CommonModule } from '@angular/common';
4
4
  import { FormGroup, NgForm, NgControl, Validators, FormsModule } from '@angular/forms';
5
5
  import { MatButton, MatButtonModule } from '@angular/material/button';
@@ -184,13 +184,12 @@ function getFormErrors(control, key) {
184
184
  }
185
185
 
186
186
  var FsFormDirective = /** @class */ (function () {
187
- function FsFormDirective(ngForm, _form, _element, _message, _prompt, _cdRef, _ngZone, _dialogRef, _drawerRef) {
187
+ function FsFormDirective(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef) {
188
188
  this.ngForm = ngForm;
189
189
  this._form = _form;
190
190
  this._element = _element;
191
191
  this._message = _message;
192
192
  this._prompt = _prompt;
193
- this._cdRef = _cdRef;
194
193
  this._ngZone = _ngZone;
195
194
  this._dialogRef = _dialogRef;
196
195
  this._drawerRef = _drawerRef;
@@ -696,18 +695,15 @@ var FsFormDirective = /** @class */ (function () {
696
695
  };
697
696
  FsFormDirective.prototype._updateDirtySubmitButtons = function () {
698
697
  var _this = this;
699
- if (this._submitButtons) {
700
- this._submitButtons.forEach(function (button) {
701
- button.setFormRef(_this);
702
- if (!_this.confirm || !_this.dirtySubmitButton || _this.ngForm.dirty || !button.dirtySubmit) {
703
- button.enable();
704
- }
705
- else {
706
- button.disable();
707
- }
708
- });
709
- this._cdRef.markForCheck();
710
- }
698
+ this._submitButtons
699
+ .forEach(function (submitButton) {
700
+ if (!_this.confirm || !_this.dirtySubmitButton || _this.ngForm.dirty || !submitButton.dirtySubmit) {
701
+ submitButton.enable();
702
+ }
703
+ else {
704
+ submitButton.disable();
705
+ }
706
+ });
711
707
  };
712
708
  FsFormDirective.prototype._broadcastSubmittingEvents = function () {
713
709
  this._status$.next(FormStatus.Submitting);
@@ -750,7 +746,6 @@ var FsFormDirective = /** @class */ (function () {
750
746
  { type: ElementRef },
751
747
  { type: FsMessage },
752
748
  { type: FsPrompt },
753
- { type: ChangeDetectorRef },
754
749
  { type: NgZone },
755
750
  { type: MatDialogRef, decorators: [{ type: Optional }, { type: Inject, args: [MatDialogRef,] }] },
756
751
  { type: DrawerRef, decorators: [{ type: Optional }, { type: Inject, args: [DrawerRef,] }] }
@@ -852,14 +847,13 @@ var FsFormDirective = /** @class */ (function () {
852
847
  selector: '[fsForm]',
853
848
  }),
854
849
  __param(0, Inject(NgForm)),
855
- __param(7, Optional()), __param(7, Inject(MatDialogRef)),
856
- __param(8, Optional()), __param(8, Inject(DrawerRef)),
850
+ __param(6, Optional()), __param(6, Inject(MatDialogRef)),
851
+ __param(7, Optional()), __param(7, Inject(DrawerRef)),
857
852
  __metadata("design:paramtypes", [NgForm,
858
853
  FsForm,
859
854
  ElementRef,
860
855
  FsMessage,
861
856
  FsPrompt,
862
- ChangeDetectorRef,
863
857
  NgZone,
864
858
  MatDialogRef,
865
859
  DrawerRef])
@@ -2016,10 +2010,11 @@ var FsFormUrlDirective = /** @class */ (function (_super) {
2016
2010
  }(FsControlDirective));
2017
2011
 
2018
2012
  var FsSubmitButtonDirective = /** @class */ (function () {
2019
- function FsSubmitButtonDirective(_matButton, _form, _elementRef) {
2013
+ function FsSubmitButtonDirective(_matButton, _form, _elementRef, _cdRef) {
2020
2014
  this._matButton = _matButton;
2021
2015
  this._form = _form;
2022
2016
  this._elementRef = _elementRef;
2017
+ this._cdRef = _cdRef;
2023
2018
  this.dirtySubmit = true;
2024
2019
  this.transitionStyle = null;
2025
2020
  this.active = false;
@@ -2027,22 +2022,21 @@ var FsSubmitButtonDirective = /** @class */ (function () {
2027
2022
  }
2028
2023
  FsSubmitButtonDirective.prototype.ngOnInit = function () {
2029
2024
  var _this = this;
2030
- this._form.addSubmitButton(this);
2031
- fromEvent(this.element, 'click')
2032
- .pipe(takeUntil(this._destroy$))
2033
- .subscribe(function () {
2034
- _this.active = true;
2035
- });
2036
- };
2037
- FsSubmitButtonDirective.prototype.setFormRef = function (formRef) {
2038
- var _this = this;
2039
- if (formRef) {
2040
- this.transitionStyle = 'none';
2041
- }
2042
- if (formRef && this.dirtySubmit) {
2043
- if (formRef.dirtySubmitButton) {
2044
- this.disable();
2025
+ if (this._form) {
2026
+ this._form.addSubmitButton(this);
2027
+ fromEvent(this.element, 'click')
2028
+ .pipe(takeUntil(this._destroy$))
2029
+ .subscribe(function () {
2030
+ _this.active = true;
2031
+ });
2032
+ if (this.dirtySubmit) {
2033
+ if (this._form.dirtySubmitButton) {
2034
+ if (!this._form.ngForm.dirty) {
2035
+ this.disable();
2036
+ }
2037
+ }
2045
2038
  }
2039
+ this.transitionStyle = 'none';
2046
2040
  setTimeout(function () {
2047
2041
  _this.transitionStyle = null;
2048
2042
  }, 500);
@@ -2051,12 +2045,14 @@ var FsSubmitButtonDirective = /** @class */ (function () {
2051
2045
  FsSubmitButtonDirective.prototype.disable = function () {
2052
2046
  if (this._matButton) {
2053
2047
  this._matButton.disabled = true;
2048
+ this._cdRef.markForCheck();
2054
2049
  }
2055
2050
  };
2056
2051
  FsSubmitButtonDirective.prototype.enable = function () {
2057
2052
  if (this._matButton) {
2058
2053
  this._matButton.disabled = false;
2059
2054
  this._matButton.disableRipple = true;
2055
+ this._cdRef.markForCheck();
2060
2056
  }
2061
2057
  };
2062
2058
  FsSubmitButtonDirective.prototype.process = function () {
@@ -2121,7 +2117,8 @@ var FsSubmitButtonDirective = /** @class */ (function () {
2121
2117
  FsSubmitButtonDirective.ctorParameters = function () { return [
2122
2118
  { type: MatButton, decorators: [{ type: Optional }, { type: Host }] },
2123
2119
  { type: FsFormDirective, decorators: [{ type: Optional }] },
2124
- { type: ElementRef }
2120
+ { type: ElementRef },
2121
+ { type: ChangeDetectorRef }
2125
2122
  ]; };
2126
2123
  __decorate([
2127
2124
  Input(),
@@ -2137,13 +2134,14 @@ var FsSubmitButtonDirective = /** @class */ (function () {
2137
2134
  ], FsSubmitButtonDirective.prototype, "transitionStyle", void 0);
2138
2135
  FsSubmitButtonDirective = __decorate([
2139
2136
  Directive({
2140
- selector: 'form button[type="submit"],form button:not([type])',
2137
+ selector: 'button[type="submit"]',
2141
2138
  }),
2142
2139
  __param(0, Optional()), __param(0, Host()),
2143
2140
  __param(1, Optional()),
2144
2141
  __metadata("design:paramtypes", [MatButton,
2145
2142
  FsFormDirective,
2146
- ElementRef])
2143
+ ElementRef,
2144
+ ChangeDetectorRef])
2147
2145
  ], FsSubmitButtonDirective);
2148
2146
  return FsSubmitButtonDirective;
2149
2147
  }());
@@ -2182,8 +2180,9 @@ var FsFormDialogActionsComponent = /** @class */ (function () {
2182
2180
  function FsFormDialogActionsComponent(_form, _cdRef) {
2183
2181
  this._form = _form;
2184
2182
  this._cdRef = _cdRef;
2183
+ this.save = true;
2185
2184
  this.create = false;
2186
- this.close = true;
2185
+ this.close = false;
2187
2186
  this.dirty = false;
2188
2187
  this._destroy$ = new Subject();
2189
2188
  }
@@ -2210,6 +2209,10 @@ var FsFormDialogActionsComponent = /** @class */ (function () {
2210
2209
  { type: FsFormDirective, decorators: [{ type: Optional }] },
2211
2210
  { type: ChangeDetectorRef }
2212
2211
  ]; };
2212
+ __decorate([
2213
+ Input(),
2214
+ __metadata("design:type", Object)
2215
+ ], FsFormDialogActionsComponent.prototype, "save", void 0);
2213
2216
  __decorate([
2214
2217
  Input(),
2215
2218
  __metadata("design:type", Object)
@@ -2218,11 +2221,16 @@ var FsFormDialogActionsComponent = /** @class */ (function () {
2218
2221
  Input(),
2219
2222
  __metadata("design:type", Object)
2220
2223
  ], FsFormDialogActionsComponent.prototype, "close", void 0);
2224
+ __decorate([
2225
+ Input(),
2226
+ __metadata("design:type", String)
2227
+ ], FsFormDialogActionsComponent.prototype, "name", void 0);
2221
2228
  FsFormDialogActionsComponent = __decorate([
2222
2229
  Component({
2223
2230
  selector: 'fs-form-dialog-actions',
2224
- 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",
2225
- changeDetection: ChangeDetectionStrategy.OnPush
2231
+ 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>",
2232
+ changeDetection: ChangeDetectionStrategy.OnPush,
2233
+ 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}"]
2226
2234
  }),
2227
2235
  __param(0, Optional()),
2228
2236
  __metadata("design:paramtypes", [FsFormDirective,