@rxap/forms 12.5.1 → 12.7.1

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.
@@ -1696,6 +1696,7 @@
1696
1696
  */
1697
1697
  _this.rxapSubmit = new i0.EventEmitter();
1698
1698
  _this.invalidSubmit = new i0.EventEmitter();
1699
+ _this.submitSuccessful$ = new i0.EventEmitter();
1699
1700
  _this.submitting$ = new rxjs$1.ToggleSubject();
1700
1701
  _this.submitError$ = new rxjs.BehaviorSubject(null);
1701
1702
  _this.loading$ = new rxjs$1.ToggleSubject();
@@ -1805,10 +1806,58 @@
1805
1806
  this.submit();
1806
1807
  }
1807
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
+ }
1808
1857
  if (i0.isDevMode()) {
1809
1858
  console.log('Form submit is not valid for: ' + this.form.controlId, this.form.errors);
1810
1859
  function printErrorControls(control) {
1811
- var e_1, _c, e_2, _d;
1860
+ var e_3, _c, e_4, _d;
1812
1861
  if (!control.valid) {
1813
1862
  console.group(control.controlId);
1814
1863
  if (control.controls) {
@@ -1829,12 +1878,12 @@
1829
1878
  printErrorControls(child);
1830
1879
  }
1831
1880
  }
1832
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1881
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1833
1882
  finally {
1834
1883
  try {
1835
1884
  if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
1836
1885
  }
1837
- finally { if (e_1) throw e_1.error; }
1886
+ finally { if (e_3) throw e_3.error; }
1838
1887
  }
1839
1888
  }
1840
1889
  }
@@ -1848,12 +1897,12 @@
1848
1897
  console.groupEnd();
1849
1898
  }
1850
1899
  }
1851
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1900
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1852
1901
  finally {
1853
1902
  try {
1854
1903
  if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
1855
1904
  }
1856
- finally { if (e_2) throw e_2.error; }
1905
+ finally { if (e_4) throw e_4.error; }
1857
1906
  }
1858
1907
  }
1859
1908
  console.log('value: ', control.value);
@@ -1863,7 +1912,7 @@
1863
1912
  }
1864
1913
  printErrorControls(this.form);
1865
1914
  }
1866
- this.invalidSubmit.emit();
1915
+ this.invalidSubmit.emit(reduceErrors(this.form));
1867
1916
  }
1868
1917
  return false;
1869
1918
  };
@@ -2006,6 +2055,7 @@
2006
2055
  }
2007
2056
  };
2008
2057
  FormDirective.prototype.submitSuccessful = function (value) {
2058
+ this.submitSuccessful$.next(value);
2009
2059
  if (this.submitSuccessfulMethod) {
2010
2060
  this.submitSuccessfulMethod.call(value);
2011
2061
  }
@@ -2028,7 +2078,7 @@
2028
2078
  return FormDirective;
2029
2079
  }(i1.FormGroupDirective));
2030
2080
  FormDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: RXAP_FORM_DEFINITION, optional: true }, { token: RXAP_FORM_SUBMIT_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_FAILED_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_SUCCESSFUL_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_SUBMIT_FAILED_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_DEFINITION_BUILDER, optional: true, skipSelf: true }, { token: i2.LoadingIndicatorService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2031
- FormDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormDirective, selector: "form[rxapForm]:not([formGroup]):not([ngForm]),rxap-form,form[rxapForm]", inputs: { initial: "initial", useFormDefinition: ["rxapForm", "useFormDefinition"], submitMethod: "submitMethod" }, outputs: { ngSubmit: "ngSubmit", rxapSubmit: "rxapSubmit", invalidSubmit: "invalidSubmit" }, host: { listeners: { "reset": "onReset()" }, properties: { "class.rxap-submitting": "this.submitting", "class.rxap-submit-error": "this.submitError", "class.rxap-loading": "this.loading", "class.rxap-loaded": "this.loaded", "class.rxap-loading-error": "this.loadingError" } }, providers: [
2081
+ FormDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormDirective, selector: "form[rxapForm]:not([formGroup]):not([ngForm]),rxap-form,form[rxapForm]", inputs: { initial: "initial", useFormDefinition: ["rxapForm", "useFormDefinition"], submitMethod: "submitMethod" }, outputs: { ngSubmit: "ngSubmit", rxapSubmit: "rxapSubmit", invalidSubmit: "invalidSubmit", submitSuccessful$: "submitSuccessful" }, host: { listeners: { "reset": "onReset()" }, properties: { "class.rxap-submitting": "this.submitting", "class.rxap-submit-error": "this.submitError", "class.rxap-loading": "this.loading", "class.rxap-loaded": "this.loaded", "class.rxap-loading-error": "this.loadingError" } }, providers: [
2032
2082
  {
2033
2083
  provide: i1.ControlContainer,
2034
2084
  // ignore coverage
@@ -2196,6 +2246,9 @@
2196
2246
  type: i0.Output
2197
2247
  }], invalidSubmit: [{
2198
2248
  type: i0.Output
2249
+ }], submitSuccessful$: [{
2250
+ type: i0.Output,
2251
+ args: ['submitSuccessful']
2199
2252
  }], submitting: [{
2200
2253
  type: i0.HostBinding,
2201
2254
  args: ['class.rxap-submitting']
@@ -2815,6 +2868,84 @@
2815
2868
  }]
2816
2869
  }] });
2817
2870
 
2871
+ var FormSubmitSuccessfulDirective = /** @class */ (function () {
2872
+ function FormSubmitSuccessfulDirective(formDirective, template, viewContainerRef) {
2873
+ this.formDirective = formDirective;
2874
+ this.template = template;
2875
+ this.viewContainerRef = viewContainerRef;
2876
+ }
2877
+ FormSubmitSuccessfulDirective.prototype.ngAfterViewInit = function () {
2878
+ var _this = this;
2879
+ this.subscription = this.formDirective.submitSuccessful$.pipe(operators.tap(function (result) {
2880
+ _this.viewContainerRef.clear();
2881
+ _this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: result });
2882
+ })).subscribe();
2883
+ };
2884
+ FormSubmitSuccessfulDirective.prototype.ngOnDestroy = function () {
2885
+ var _a;
2886
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2887
+ };
2888
+ return FormSubmitSuccessfulDirective;
2889
+ }());
2890
+ FormSubmitSuccessfulDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitSuccessfulDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2891
+ FormSubmitSuccessfulDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitSuccessfulDirective, selector: "[rxapFormSubmitSuccessful]", ngImport: i0__namespace });
2892
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitSuccessfulDirective, decorators: [{
2893
+ type: i0.Directive,
2894
+ args: [{
2895
+ selector: '[rxapFormSubmitSuccessful]'
2896
+ }]
2897
+ }], ctorParameters: function () {
2898
+ return [{ type: FormDirective, decorators: [{
2899
+ type: i0.Inject,
2900
+ args: [FormDirective]
2901
+ }] }, { type: i0__namespace.TemplateRef, decorators: [{
2902
+ type: i0.Inject,
2903
+ args: [i0.TemplateRef]
2904
+ }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2905
+ type: i0.Inject,
2906
+ args: [i0.ViewContainerRef]
2907
+ }] }];
2908
+ } });
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
+
2818
2949
  var RxapFormsModule = /** @class */ (function () {
2819
2950
  function RxapFormsModule() {
2820
2951
  }
@@ -2835,7 +2966,9 @@
2835
2966
  FormSubmitDirective,
2836
2967
  FormGroupNameDirective,
2837
2968
  FormControlNameDirective,
2838
- ParentControlContainerDirective], exports: [FormDirective,
2969
+ ParentControlContainerDirective,
2970
+ FormSubmitSuccessfulDirective,
2971
+ FormSubmitInvalidDirective], exports: [FormDirective,
2839
2972
  FormSubmitFailedDirective,
2840
2973
  FormLoadingDirective,
2841
2974
  FormSubmittingDirective,
@@ -2849,7 +2982,9 @@
2849
2982
  FormSubmitDirective,
2850
2983
  FormGroupNameDirective,
2851
2984
  FormControlNameDirective,
2852
- ParentControlContainerDirective] });
2985
+ ParentControlContainerDirective,
2986
+ FormSubmitSuccessfulDirective,
2987
+ FormSubmitInvalidDirective] });
2853
2988
  RxapFormsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule });
2854
2989
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule, decorators: [{
2855
2990
  type: i0.NgModule,
@@ -2869,7 +3004,9 @@
2869
3004
  FormSubmitDirective,
2870
3005
  FormGroupNameDirective,
2871
3006
  FormControlNameDirective,
2872
- ParentControlContainerDirective
3007
+ ParentControlContainerDirective,
3008
+ FormSubmitSuccessfulDirective,
3009
+ FormSubmitInvalidDirective,
2873
3010
  ],
2874
3011
  exports: [
2875
3012
  FormDirective,
@@ -2886,7 +3023,9 @@
2886
3023
  FormSubmitDirective,
2887
3024
  FormGroupNameDirective,
2888
3025
  FormControlNameDirective,
2889
- ParentControlContainerDirective
3026
+ ParentControlContainerDirective,
3027
+ FormSubmitSuccessfulDirective,
3028
+ FormSubmitInvalidDirective,
2890
3029
  ]
2891
3030
  }]
2892
3031
  }] });
@@ -3320,6 +3459,8 @@
3320
3459
  exports.FormLoadingErrorDirective = FormLoadingErrorDirective;
3321
3460
  exports.FormSubmitDirective = FormSubmitDirective;
3322
3461
  exports.FormSubmitFailedDirective = FormSubmitFailedDirective;
3462
+ exports.FormSubmitInvalidDirective = FormSubmitInvalidDirective;
3463
+ exports.FormSubmitSuccessfulDirective = FormSubmitSuccessfulDirective;
3323
3464
  exports.FormSubmittingDirective = FormSubmittingDirective;
3324
3465
  exports.IsArray = IsArray;
3325
3466
  exports.IsBoolean = IsBoolean;