@rxap/forms 12.6.1 → 12.7.3
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/bundles/rxap-forms.umd.js +101 -9
- package/bundles/rxap-forms.umd.js.map +1 -1
- package/esm2015/index.js +1 -0
- package/esm2015/index.js.map +1 -1
- package/esm2015/lib/directives/form-submit-invalid.directive.js +40 -0
- package/esm2015/lib/directives/form-submit-invalid.directive.js.map +1 -0
- package/esm2015/lib/directives/form.directive.js +28 -2
- package/esm2015/lib/directives/form.directive.js.map +1 -1
- package/esm2015/lib/directives/forms.module.js +7 -2
- package/esm2015/lib/directives/forms.module.js.map +1 -1
- package/fesm2015/rxap-forms.js +70 -5
- package/fesm2015/rxap-forms.js.map +1 -1
- package/index.d.ts +1 -0
- package/lib/directives/form-submit-invalid.directive.d.ts +16 -0
- package/lib/directives/form.directive.d.ts +2 -2
- package/lib/directives/forms.module.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1691,7 +1691,7 @@
|
|
|
1691
1691
|
* Emits when the submit method is executed without errors. The result of the
|
|
1692
1692
|
* submit method is passed as event object.
|
|
1693
1693
|
*
|
|
1694
|
-
* If no submit method is defined then emit
|
|
1694
|
+
* If no submit method is defined then emit after the submit button
|
|
1695
1695
|
* is clicked.
|
|
1696
1696
|
*/
|
|
1697
1697
|
_this.rxapSubmit = new i0.EventEmitter();
|
|
@@ -1806,10 +1806,58 @@
|
|
|
1806
1806
|
this.submit();
|
|
1807
1807
|
}
|
|
1808
1808
|
else {
|
|
1809
|
+
function reduceErrors(control, errors) {
|
|
1810
|
+
var e_1, _c, e_2, _d;
|
|
1811
|
+
if (errors === void 0) { errors = {}; }
|
|
1812
|
+
if (control.invalid) {
|
|
1813
|
+
if (control.controls) {
|
|
1814
|
+
if (Array.isArray(control.controls)) {
|
|
1815
|
+
var errorList = [];
|
|
1816
|
+
try {
|
|
1817
|
+
for (var _e = __values(control.controls), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1818
|
+
var item = _f.value;
|
|
1819
|
+
errorList.push(reduceErrors(item));
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1823
|
+
finally {
|
|
1824
|
+
try {
|
|
1825
|
+
if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
|
|
1826
|
+
}
|
|
1827
|
+
finally { if (e_1) throw e_1.error; }
|
|
1828
|
+
}
|
|
1829
|
+
errors[control.controlId] = errorList;
|
|
1830
|
+
}
|
|
1831
|
+
else {
|
|
1832
|
+
var innerErrors = {};
|
|
1833
|
+
try {
|
|
1834
|
+
for (var _g = __values(Object.values(control.controls)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
1835
|
+
var child = _h.value;
|
|
1836
|
+
reduceErrors(child, innerErrors);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1840
|
+
finally {
|
|
1841
|
+
try {
|
|
1842
|
+
if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
|
|
1843
|
+
}
|
|
1844
|
+
finally { if (e_2) throw e_2.error; }
|
|
1845
|
+
}
|
|
1846
|
+
errors[control.controlId] = innerErrors;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
else {
|
|
1850
|
+
if (control.errors) {
|
|
1851
|
+
errors[control.controlId] = control.errors;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return errors;
|
|
1856
|
+
}
|
|
1809
1857
|
if (i0.isDevMode()) {
|
|
1810
1858
|
console.log('Form submit is not valid for: ' + this.form.controlId, this.form.errors);
|
|
1811
1859
|
function printErrorControls(control) {
|
|
1812
|
-
var
|
|
1860
|
+
var e_3, _c, e_4, _d;
|
|
1813
1861
|
if (!control.valid) {
|
|
1814
1862
|
console.group(control.controlId);
|
|
1815
1863
|
if (control.controls) {
|
|
@@ -1830,12 +1878,12 @@
|
|
|
1830
1878
|
printErrorControls(child);
|
|
1831
1879
|
}
|
|
1832
1880
|
}
|
|
1833
|
-
catch (
|
|
1881
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1834
1882
|
finally {
|
|
1835
1883
|
try {
|
|
1836
1884
|
if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
|
|
1837
1885
|
}
|
|
1838
|
-
finally { if (
|
|
1886
|
+
finally { if (e_3) throw e_3.error; }
|
|
1839
1887
|
}
|
|
1840
1888
|
}
|
|
1841
1889
|
}
|
|
@@ -1849,12 +1897,12 @@
|
|
|
1849
1897
|
console.groupEnd();
|
|
1850
1898
|
}
|
|
1851
1899
|
}
|
|
1852
|
-
catch (
|
|
1900
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1853
1901
|
finally {
|
|
1854
1902
|
try {
|
|
1855
1903
|
if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
|
|
1856
1904
|
}
|
|
1857
|
-
finally { if (
|
|
1905
|
+
finally { if (e_4) throw e_4.error; }
|
|
1858
1906
|
}
|
|
1859
1907
|
}
|
|
1860
1908
|
console.log('value: ', control.value);
|
|
@@ -1864,7 +1912,7 @@
|
|
|
1864
1912
|
}
|
|
1865
1913
|
printErrorControls(this.form);
|
|
1866
1914
|
}
|
|
1867
|
-
this.invalidSubmit.emit();
|
|
1915
|
+
this.invalidSubmit.emit(reduceErrors(this.form));
|
|
1868
1916
|
}
|
|
1869
1917
|
return false;
|
|
1870
1918
|
};
|
|
@@ -2859,6 +2907,45 @@
|
|
|
2859
2907
|
}] }];
|
|
2860
2908
|
} });
|
|
2861
2909
|
|
|
2910
|
+
var FormSubmitInvalidDirective = /** @class */ (function () {
|
|
2911
|
+
function FormSubmitInvalidDirective(formDirective, template, viewContainerRef) {
|
|
2912
|
+
this.formDirective = formDirective;
|
|
2913
|
+
this.template = template;
|
|
2914
|
+
this.viewContainerRef = viewContainerRef;
|
|
2915
|
+
}
|
|
2916
|
+
FormSubmitInvalidDirective.prototype.ngAfterViewInit = function () {
|
|
2917
|
+
var _this = this;
|
|
2918
|
+
this.subscription = this.formDirective.invalidSubmit.pipe(operators.tap(function (result) {
|
|
2919
|
+
_this.viewContainerRef.clear();
|
|
2920
|
+
_this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: result });
|
|
2921
|
+
})).subscribe();
|
|
2922
|
+
};
|
|
2923
|
+
FormSubmitInvalidDirective.prototype.ngOnDestroy = function () {
|
|
2924
|
+
var _a;
|
|
2925
|
+
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2926
|
+
};
|
|
2927
|
+
return FormSubmitInvalidDirective;
|
|
2928
|
+
}());
|
|
2929
|
+
FormSubmitInvalidDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitInvalidDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
2930
|
+
FormSubmitInvalidDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitInvalidDirective, selector: "[rxapFormSubmitInvalid]", ngImport: i0__namespace });
|
|
2931
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitInvalidDirective, decorators: [{
|
|
2932
|
+
type: i0.Directive,
|
|
2933
|
+
args: [{
|
|
2934
|
+
selector: '[rxapFormSubmitInvalid]'
|
|
2935
|
+
}]
|
|
2936
|
+
}], ctorParameters: function () {
|
|
2937
|
+
return [{ type: FormDirective, decorators: [{
|
|
2938
|
+
type: i0.Inject,
|
|
2939
|
+
args: [FormDirective]
|
|
2940
|
+
}] }, { type: i0__namespace.TemplateRef, decorators: [{
|
|
2941
|
+
type: i0.Inject,
|
|
2942
|
+
args: [i0.TemplateRef]
|
|
2943
|
+
}] }, { type: i0__namespace.ViewContainerRef, decorators: [{
|
|
2944
|
+
type: i0.Inject,
|
|
2945
|
+
args: [i0.ViewContainerRef]
|
|
2946
|
+
}] }];
|
|
2947
|
+
} });
|
|
2948
|
+
|
|
2862
2949
|
var RxapFormsModule = /** @class */ (function () {
|
|
2863
2950
|
function RxapFormsModule() {
|
|
2864
2951
|
}
|
|
@@ -2880,7 +2967,8 @@
|
|
|
2880
2967
|
FormGroupNameDirective,
|
|
2881
2968
|
FormControlNameDirective,
|
|
2882
2969
|
ParentControlContainerDirective,
|
|
2883
|
-
FormSubmitSuccessfulDirective
|
|
2970
|
+
FormSubmitSuccessfulDirective,
|
|
2971
|
+
FormSubmitInvalidDirective], exports: [FormDirective,
|
|
2884
2972
|
FormSubmitFailedDirective,
|
|
2885
2973
|
FormLoadingDirective,
|
|
2886
2974
|
FormSubmittingDirective,
|
|
@@ -2895,7 +2983,8 @@
|
|
|
2895
2983
|
FormGroupNameDirective,
|
|
2896
2984
|
FormControlNameDirective,
|
|
2897
2985
|
ParentControlContainerDirective,
|
|
2898
|
-
FormSubmitSuccessfulDirective
|
|
2986
|
+
FormSubmitSuccessfulDirective,
|
|
2987
|
+
FormSubmitInvalidDirective] });
|
|
2899
2988
|
RxapFormsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule });
|
|
2900
2989
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule, decorators: [{
|
|
2901
2990
|
type: i0.NgModule,
|
|
@@ -2917,6 +3006,7 @@
|
|
|
2917
3006
|
FormControlNameDirective,
|
|
2918
3007
|
ParentControlContainerDirective,
|
|
2919
3008
|
FormSubmitSuccessfulDirective,
|
|
3009
|
+
FormSubmitInvalidDirective,
|
|
2920
3010
|
],
|
|
2921
3011
|
exports: [
|
|
2922
3012
|
FormDirective,
|
|
@@ -2935,6 +3025,7 @@
|
|
|
2935
3025
|
FormControlNameDirective,
|
|
2936
3026
|
ParentControlContainerDirective,
|
|
2937
3027
|
FormSubmitSuccessfulDirective,
|
|
3028
|
+
FormSubmitInvalidDirective,
|
|
2938
3029
|
]
|
|
2939
3030
|
}]
|
|
2940
3031
|
}] });
|
|
@@ -3368,6 +3459,7 @@
|
|
|
3368
3459
|
exports.FormLoadingErrorDirective = FormLoadingErrorDirective;
|
|
3369
3460
|
exports.FormSubmitDirective = FormSubmitDirective;
|
|
3370
3461
|
exports.FormSubmitFailedDirective = FormSubmitFailedDirective;
|
|
3462
|
+
exports.FormSubmitInvalidDirective = FormSubmitInvalidDirective;
|
|
3371
3463
|
exports.FormSubmitSuccessfulDirective = FormSubmitSuccessfulDirective;
|
|
3372
3464
|
exports.FormSubmittingDirective = FormSubmittingDirective;
|
|
3373
3465
|
exports.IsArray = IsArray;
|