@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.
- package/app/components/form-dialog-actions/form-dialog-actions.component.d.ts +2 -0
- package/app/directives/form/form.directive.d.ts +2 -3
- package/app/directives/submit-button.directive.d.ts +3 -3
- package/bundles/firestitch-form.umd.js +48 -40
- package/bundles/firestitch-form.umd.js.map +1 -1
- package/bundles/firestitch-form.umd.min.js +2 -2
- package/bundles/firestitch-form.umd.min.js.map +1 -1
- package/esm2015/app/components/form-dialog-actions/form-dialog-actions.component.js +14 -4
- package/esm2015/app/directives/form/form.directive.js +14 -20
- package/esm2015/app/directives/submit-button.directive.js +25 -20
- package/esm5/app/components/form-dialog-actions/form-dialog-actions.component.js +14 -4
- package/esm5/app/directives/form/form.directive.js +14 -20
- package/esm5/app/directives/submit-button.directive.js +25 -21
- package/fesm2015/firestitch-form.js +49 -40
- package/fesm2015/firestitch-form.js.map +1 -1
- package/fesm5/firestitch-form.js +49 -41
- package/fesm5/firestitch-form.js.map +1 -1
- package/firestitch-form.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
2
|
-
import { HostBinding, HostListener, Directive, ɵɵdefineInjectable, Injectable, EventEmitter, QueryList, Inject, ElementRef,
|
|
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';
|
|
@@ -180,13 +180,12 @@ function getFormErrors(control, key) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
let FsFormDirective = class FsFormDirective {
|
|
183
|
-
constructor(ngForm, _form, _element, _message, _prompt,
|
|
183
|
+
constructor(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef) {
|
|
184
184
|
this.ngForm = ngForm;
|
|
185
185
|
this._form = _form;
|
|
186
186
|
this._element = _element;
|
|
187
187
|
this._message = _message;
|
|
188
188
|
this._prompt = _prompt;
|
|
189
|
-
this._cdRef = _cdRef;
|
|
190
189
|
this._ngZone = _ngZone;
|
|
191
190
|
this._dialogRef = _dialogRef;
|
|
192
191
|
this._drawerRef = _drawerRef;
|
|
@@ -652,18 +651,15 @@ let FsFormDirective = class FsFormDirective {
|
|
|
652
651
|
});
|
|
653
652
|
}
|
|
654
653
|
_updateDirtySubmitButtons() {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
});
|
|
665
|
-
this._cdRef.markForCheck();
|
|
666
|
-
}
|
|
654
|
+
this._submitButtons
|
|
655
|
+
.forEach((submitButton) => {
|
|
656
|
+
if (!this.confirm || !this.dirtySubmitButton || this.ngForm.dirty || !submitButton.dirtySubmit) {
|
|
657
|
+
submitButton.enable();
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
submitButton.disable();
|
|
661
|
+
}
|
|
662
|
+
});
|
|
667
663
|
}
|
|
668
664
|
_broadcastSubmittingEvents() {
|
|
669
665
|
this._status$.next(FormStatus.Submitting);
|
|
@@ -707,7 +703,6 @@ FsFormDirective.ctorParameters = () => [
|
|
|
707
703
|
{ type: ElementRef },
|
|
708
704
|
{ type: FsMessage },
|
|
709
705
|
{ type: FsPrompt },
|
|
710
|
-
{ type: ChangeDetectorRef },
|
|
711
706
|
{ type: NgZone },
|
|
712
707
|
{ type: MatDialogRef, decorators: [{ type: Optional }, { type: Inject, args: [MatDialogRef,] }] },
|
|
713
708
|
{ type: DrawerRef, decorators: [{ type: Optional }, { type: Inject, args: [DrawerRef,] }] }
|
|
@@ -809,14 +804,13 @@ FsFormDirective = __decorate([
|
|
|
809
804
|
selector: '[fsForm]',
|
|
810
805
|
}),
|
|
811
806
|
__param(0, Inject(NgForm)),
|
|
812
|
-
__param(
|
|
813
|
-
__param(
|
|
807
|
+
__param(6, Optional()), __param(6, Inject(MatDialogRef)),
|
|
808
|
+
__param(7, Optional()), __param(7, Inject(DrawerRef)),
|
|
814
809
|
__metadata("design:paramtypes", [NgForm,
|
|
815
810
|
FsForm,
|
|
816
811
|
ElementRef,
|
|
817
812
|
FsMessage,
|
|
818
813
|
FsPrompt,
|
|
819
|
-
ChangeDetectorRef,
|
|
820
814
|
NgZone,
|
|
821
815
|
MatDialogRef,
|
|
822
816
|
DrawerRef])
|
|
@@ -1806,31 +1800,32 @@ FsFormUrlDirective = __decorate([
|
|
|
1806
1800
|
], FsFormUrlDirective);
|
|
1807
1801
|
|
|
1808
1802
|
let FsSubmitButtonDirective = class FsSubmitButtonDirective {
|
|
1809
|
-
constructor(_matButton, _form, _elementRef) {
|
|
1803
|
+
constructor(_matButton, _form, _elementRef, _cdRef) {
|
|
1810
1804
|
this._matButton = _matButton;
|
|
1811
1805
|
this._form = _form;
|
|
1812
1806
|
this._elementRef = _elementRef;
|
|
1807
|
+
this._cdRef = _cdRef;
|
|
1813
1808
|
this.dirtySubmit = true;
|
|
1814
1809
|
this.transitionStyle = null;
|
|
1815
1810
|
this.active = false;
|
|
1816
1811
|
this._destroy$ = new Subject();
|
|
1817
1812
|
}
|
|
1818
1813
|
ngOnInit() {
|
|
1819
|
-
this._form
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
this.disable();
|
|
1814
|
+
if (this._form) {
|
|
1815
|
+
this._form.addSubmitButton(this);
|
|
1816
|
+
fromEvent(this.element, 'click')
|
|
1817
|
+
.pipe(takeUntil(this._destroy$))
|
|
1818
|
+
.subscribe(() => {
|
|
1819
|
+
this.active = true;
|
|
1820
|
+
});
|
|
1821
|
+
if (this.dirtySubmit) {
|
|
1822
|
+
if (this._form.dirtySubmitButton) {
|
|
1823
|
+
if (!this._form.ngForm.dirty) {
|
|
1824
|
+
this.disable();
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1833
1827
|
}
|
|
1828
|
+
this.transitionStyle = 'none';
|
|
1834
1829
|
setTimeout(() => {
|
|
1835
1830
|
this.transitionStyle = null;
|
|
1836
1831
|
}, 500);
|
|
@@ -1839,12 +1834,14 @@ let FsSubmitButtonDirective = class FsSubmitButtonDirective {
|
|
|
1839
1834
|
disable() {
|
|
1840
1835
|
if (this._matButton) {
|
|
1841
1836
|
this._matButton.disabled = true;
|
|
1837
|
+
this._cdRef.markForCheck();
|
|
1842
1838
|
}
|
|
1843
1839
|
}
|
|
1844
1840
|
enable() {
|
|
1845
1841
|
if (this._matButton) {
|
|
1846
1842
|
this._matButton.disabled = false;
|
|
1847
1843
|
this._matButton.disableRipple = true;
|
|
1844
|
+
this._cdRef.markForCheck();
|
|
1848
1845
|
}
|
|
1849
1846
|
}
|
|
1850
1847
|
process() {
|
|
@@ -1920,7 +1917,8 @@ let FsSubmitButtonDirective = class FsSubmitButtonDirective {
|
|
|
1920
1917
|
FsSubmitButtonDirective.ctorParameters = () => [
|
|
1921
1918
|
{ type: MatButton, decorators: [{ type: Optional }, { type: Host }] },
|
|
1922
1919
|
{ type: FsFormDirective, decorators: [{ type: Optional }] },
|
|
1923
|
-
{ type: ElementRef }
|
|
1920
|
+
{ type: ElementRef },
|
|
1921
|
+
{ type: ChangeDetectorRef }
|
|
1924
1922
|
];
|
|
1925
1923
|
__decorate([
|
|
1926
1924
|
Input(),
|
|
@@ -1936,13 +1934,14 @@ __decorate([
|
|
|
1936
1934
|
], FsSubmitButtonDirective.prototype, "transitionStyle", void 0);
|
|
1937
1935
|
FsSubmitButtonDirective = __decorate([
|
|
1938
1936
|
Directive({
|
|
1939
|
-
selector: '
|
|
1937
|
+
selector: 'button[type="submit"]',
|
|
1940
1938
|
}),
|
|
1941
1939
|
__param(0, Optional()), __param(0, Host()),
|
|
1942
1940
|
__param(1, Optional()),
|
|
1943
1941
|
__metadata("design:paramtypes", [MatButton,
|
|
1944
1942
|
FsFormDirective,
|
|
1945
|
-
ElementRef
|
|
1943
|
+
ElementRef,
|
|
1944
|
+
ChangeDetectorRef])
|
|
1946
1945
|
], FsSubmitButtonDirective);
|
|
1947
1946
|
|
|
1948
1947
|
let FsFormValidateDirective = class FsFormValidateDirective extends FsControlDirective {
|
|
@@ -1974,8 +1973,9 @@ let FsFormDialogActionsComponent = class FsFormDialogActionsComponent {
|
|
|
1974
1973
|
constructor(_form, _cdRef) {
|
|
1975
1974
|
this._form = _form;
|
|
1976
1975
|
this._cdRef = _cdRef;
|
|
1976
|
+
this.save = true;
|
|
1977
1977
|
this.create = false;
|
|
1978
|
-
this.close =
|
|
1978
|
+
this.close = false;
|
|
1979
1979
|
this.dirty = false;
|
|
1980
1980
|
this._destroy$ = new Subject();
|
|
1981
1981
|
}
|
|
@@ -2002,6 +2002,10 @@ FsFormDialogActionsComponent.ctorParameters = () => [
|
|
|
2002
2002
|
{ type: FsFormDirective, decorators: [{ type: Optional }] },
|
|
2003
2003
|
{ type: ChangeDetectorRef }
|
|
2004
2004
|
];
|
|
2005
|
+
__decorate([
|
|
2006
|
+
Input(),
|
|
2007
|
+
__metadata("design:type", Object)
|
|
2008
|
+
], FsFormDialogActionsComponent.prototype, "save", void 0);
|
|
2005
2009
|
__decorate([
|
|
2006
2010
|
Input(),
|
|
2007
2011
|
__metadata("design:type", Object)
|
|
@@ -2010,11 +2014,16 @@ __decorate([
|
|
|
2010
2014
|
Input(),
|
|
2011
2015
|
__metadata("design:type", Object)
|
|
2012
2016
|
], FsFormDialogActionsComponent.prototype, "close", void 0);
|
|
2017
|
+
__decorate([
|
|
2018
|
+
Input(),
|
|
2019
|
+
__metadata("design:type", String)
|
|
2020
|
+
], FsFormDialogActionsComponent.prototype, "name", void 0);
|
|
2013
2021
|
FsFormDialogActionsComponent = __decorate([
|
|
2014
2022
|
Component({
|
|
2015
2023
|
selector: 'fs-form-dialog-actions',
|
|
2016
|
-
template: "<button \r\n
|
|
2017
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2024
|
+
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>",
|
|
2025
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2026
|
+
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}"]
|
|
2018
2027
|
}),
|
|
2019
2028
|
__param(0, Optional()),
|
|
2020
2029
|
__metadata("design:paramtypes", [FsFormDirective,
|