@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.
@@ -1120,6 +1120,7 @@ class FormDirective extends FormGroupDirective {
1120
1120
  */
1121
1121
  this.rxapSubmit = new EventEmitter();
1122
1122
  this.invalidSubmit = new EventEmitter();
1123
+ this.submitSuccessful$ = new EventEmitter();
1123
1124
  this.submitting$ = new ToggleSubject();
1124
1125
  this.submitError$ = new BehaviorSubject(null);
1125
1126
  this.loading$ = new ToggleSubject();
@@ -1199,6 +1200,32 @@ class FormDirective extends FormGroupDirective {
1199
1200
  this.submit();
1200
1201
  }
1201
1202
  else {
1203
+ function reduceErrors(control, errors = {}) {
1204
+ if (control.invalid) {
1205
+ if (control.controls) {
1206
+ if (Array.isArray(control.controls)) {
1207
+ const errorList = [];
1208
+ for (const item of control.controls) {
1209
+ errorList.push(reduceErrors(item));
1210
+ }
1211
+ errors[control.controlId] = errorList;
1212
+ }
1213
+ else {
1214
+ const innerErrors = {};
1215
+ for (const child of Object.values(control.controls)) {
1216
+ reduceErrors(child, innerErrors);
1217
+ }
1218
+ errors[control.controlId] = innerErrors;
1219
+ }
1220
+ }
1221
+ else {
1222
+ if (control.errors) {
1223
+ errors[control.controlId] = control.errors;
1224
+ }
1225
+ }
1226
+ }
1227
+ return errors;
1228
+ }
1202
1229
  if (isDevMode()) {
1203
1230
  console.log('Form submit is not valid for: ' + this.form.controlId, this.form.errors);
1204
1231
  function printErrorControls(control) {
@@ -1236,7 +1263,7 @@ class FormDirective extends FormGroupDirective {
1236
1263
  }
1237
1264
  printErrorControls(this.form);
1238
1265
  }
1239
- this.invalidSubmit.emit();
1266
+ this.invalidSubmit.emit(reduceErrors(this.form));
1240
1267
  }
1241
1268
  return false;
1242
1269
  }
@@ -1377,6 +1404,7 @@ class FormDirective extends FormGroupDirective {
1377
1404
  }
1378
1405
  }
1379
1406
  submitSuccessful(value) {
1407
+ this.submitSuccessful$.next(value);
1380
1408
  if (this.submitSuccessfulMethod) {
1381
1409
  this.submitSuccessfulMethod.call(value);
1382
1410
  }
@@ -1398,7 +1426,7 @@ class FormDirective extends FormGroupDirective {
1398
1426
  }
1399
1427
  }
1400
1428
  FormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: FormDirective, deps: [{ token: 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: LoadingIndicatorService, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1401
- FormDirective.ɵdir = i0.ɵɵ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: [
1429
+ FormDirective.ɵdir = i0.ɵɵ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: [
1402
1430
  {
1403
1431
  provide: ControlContainer,
1404
1432
  // ignore coverage
@@ -1564,6 +1592,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImpor
1564
1592
  type: Output
1565
1593
  }], invalidSubmit: [{
1566
1594
  type: Output
1595
+ }], submitSuccessful$: [{
1596
+ type: Output,
1597
+ args: ['submitSuccessful']
1567
1598
  }], submitting: [{
1568
1599
  type: HostBinding,
1569
1600
  args: ['class.rxap-submitting']
@@ -2129,6 +2160,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImpor
2129
2160
  }]
2130
2161
  }] });
2131
2162
 
2163
+ class FormSubmitSuccessfulDirective {
2164
+ constructor(formDirective, template, viewContainerRef) {
2165
+ this.formDirective = formDirective;
2166
+ this.template = template;
2167
+ this.viewContainerRef = viewContainerRef;
2168
+ }
2169
+ ngAfterViewInit() {
2170
+ this.subscription = this.formDirective.submitSuccessful$.pipe(tap(result => {
2171
+ this.viewContainerRef.clear();
2172
+ this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
2173
+ })).subscribe();
2174
+ }
2175
+ ngOnDestroy() {
2176
+ var _a;
2177
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2178
+ }
2179
+ }
2180
+ FormSubmitSuccessfulDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: FormSubmitSuccessfulDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
2181
+ FormSubmitSuccessfulDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitSuccessfulDirective, selector: "[rxapFormSubmitSuccessful]", ngImport: i0 });
2182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: FormSubmitSuccessfulDirective, decorators: [{
2183
+ type: Directive,
2184
+ args: [{
2185
+ selector: '[rxapFormSubmitSuccessful]'
2186
+ }]
2187
+ }], ctorParameters: function () { return [{ type: FormDirective, decorators: [{
2188
+ type: Inject,
2189
+ args: [FormDirective]
2190
+ }] }, { type: i0.TemplateRef, decorators: [{
2191
+ type: Inject,
2192
+ args: [TemplateRef]
2193
+ }] }, { type: i0.ViewContainerRef, decorators: [{
2194
+ type: Inject,
2195
+ args: [ViewContainerRef]
2196
+ }] }]; } });
2197
+
2198
+ class FormSubmitInvalidDirective {
2199
+ constructor(formDirective, template, viewContainerRef) {
2200
+ this.formDirective = formDirective;
2201
+ this.template = template;
2202
+ this.viewContainerRef = viewContainerRef;
2203
+ }
2204
+ ngAfterViewInit() {
2205
+ this.subscription = this.formDirective.invalidSubmit.pipe(tap(result => {
2206
+ this.viewContainerRef.clear();
2207
+ this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
2208
+ })).subscribe();
2209
+ }
2210
+ ngOnDestroy() {
2211
+ var _a;
2212
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2213
+ }
2214
+ }
2215
+ FormSubmitInvalidDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: FormSubmitInvalidDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
2216
+ FormSubmitInvalidDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitInvalidDirective, selector: "[rxapFormSubmitInvalid]", ngImport: i0 });
2217
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: FormSubmitInvalidDirective, decorators: [{
2218
+ type: Directive,
2219
+ args: [{
2220
+ selector: '[rxapFormSubmitInvalid]'
2221
+ }]
2222
+ }], ctorParameters: function () { return [{ type: FormDirective, decorators: [{
2223
+ type: Inject,
2224
+ args: [FormDirective]
2225
+ }] }, { type: i0.TemplateRef, decorators: [{
2226
+ type: Inject,
2227
+ args: [TemplateRef]
2228
+ }] }, { type: i0.ViewContainerRef, decorators: [{
2229
+ type: Inject,
2230
+ args: [ViewContainerRef]
2231
+ }] }]; } });
2232
+
2132
2233
  class RxapFormsModule {
2133
2234
  }
2134
2235
  RxapFormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: RxapFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -2146,7 +2247,9 @@ RxapFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version
2146
2247
  FormSubmitDirective,
2147
2248
  FormGroupNameDirective,
2148
2249
  FormControlNameDirective,
2149
- ParentControlContainerDirective], exports: [FormDirective,
2250
+ ParentControlContainerDirective,
2251
+ FormSubmitSuccessfulDirective,
2252
+ FormSubmitInvalidDirective], exports: [FormDirective,
2150
2253
  FormSubmitFailedDirective,
2151
2254
  FormLoadingDirective,
2152
2255
  FormSubmittingDirective,
@@ -2160,7 +2263,9 @@ RxapFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version
2160
2263
  FormSubmitDirective,
2161
2264
  FormGroupNameDirective,
2162
2265
  FormControlNameDirective,
2163
- ParentControlContainerDirective] });
2266
+ ParentControlContainerDirective,
2267
+ FormSubmitSuccessfulDirective,
2268
+ FormSubmitInvalidDirective] });
2164
2269
  RxapFormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: RxapFormsModule });
2165
2270
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0, type: RxapFormsModule, decorators: [{
2166
2271
  type: NgModule,
@@ -2180,7 +2285,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImpor
2180
2285
  FormSubmitDirective,
2181
2286
  FormGroupNameDirective,
2182
2287
  FormControlNameDirective,
2183
- ParentControlContainerDirective
2288
+ ParentControlContainerDirective,
2289
+ FormSubmitSuccessfulDirective,
2290
+ FormSubmitInvalidDirective,
2184
2291
  ],
2185
2292
  exports: [
2186
2293
  FormDirective,
@@ -2197,7 +2304,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImpor
2197
2304
  FormSubmitDirective,
2198
2305
  FormGroupNameDirective,
2199
2306
  FormControlNameDirective,
2200
- ParentControlContainerDirective
2307
+ ParentControlContainerDirective,
2308
+ FormSubmitSuccessfulDirective,
2309
+ FormSubmitInvalidDirective,
2201
2310
  ]
2202
2311
  }]
2203
2312
  }] });
@@ -2576,5 +2685,5 @@ const RxapValidators = {
2576
2685
  * Generated bundle index. Do not edit.
2577
2686
  */
2578
2687
 
2579
- export { ControlAsyncValidator, ControlChange, ControlSetValue, ControlValidator, ControlValueAccessor, FormArrayControlManager, FormControlErrorDirective, FormControlMarkDirtyDirective, FormControlMarkPristineDirective, FormControlMarkTouchedDirective, FormControlMarkUntouchedDirective, FormControlNameDirective, FormDirective, FormGroupNameDirective, FormLoadedDirective, FormLoadingDirective, FormLoadingErrorDirective, FormSubmitDirective, FormSubmitFailedDirective, FormSubmittingDirective, IsArray, IsBoolean, IsDate, IsEnum, IsInt, IsNumber, IsObject, IsString, ParentControlContainerDirective, RXAP_FORM_CONTEXT, RXAP_FORM_DEFINITION, RXAP_FORM_DEFINITION_BUILDER, RXAP_FORM_INITIAL_STATE, RXAP_FORM_LOAD_FAILED_METHOD, RXAP_FORM_LOAD_METHOD, RXAP_FORM_LOAD_SUCCESSFUL_METHOD, RXAP_FORM_SUBMIT_FAILED_METHOD, RXAP_FORM_SUBMIT_METHOD, RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD, RxapForm, RxapFormArray, RxapFormBuilder, RxapFormControl, RxapFormGroup, RxapFormsModule, RxapValidators, ToFormMethod, ToFormSubmitMethod, UseFormArrayControl, UseFormArrayGroup, UseFormControl, UseFormGroup, _IsNumber, controlDisabled$, controlDisabledWhile, controlEnabled$, controlEnabledWhile, controlErrorChanges$, controlReadonly$, controlStatusChanges$, controlValueChanges$, disableControl, enableControl, hasErrorAndDirty, hasErrorAndTouched, isNumber, markAllDirty, markAllPristine, markAllUntouched, mergeControlValidators, selectControlValue$, validateControlOn };
2688
+ export { ControlAsyncValidator, ControlChange, ControlSetValue, ControlValidator, ControlValueAccessor, FormArrayControlManager, FormControlErrorDirective, FormControlMarkDirtyDirective, FormControlMarkPristineDirective, FormControlMarkTouchedDirective, FormControlMarkUntouchedDirective, FormControlNameDirective, FormDirective, FormGroupNameDirective, FormLoadedDirective, FormLoadingDirective, FormLoadingErrorDirective, FormSubmitDirective, FormSubmitFailedDirective, FormSubmitInvalidDirective, FormSubmitSuccessfulDirective, FormSubmittingDirective, IsArray, IsBoolean, IsDate, IsEnum, IsInt, IsNumber, IsObject, IsString, ParentControlContainerDirective, RXAP_FORM_CONTEXT, RXAP_FORM_DEFINITION, RXAP_FORM_DEFINITION_BUILDER, RXAP_FORM_INITIAL_STATE, RXAP_FORM_LOAD_FAILED_METHOD, RXAP_FORM_LOAD_METHOD, RXAP_FORM_LOAD_SUCCESSFUL_METHOD, RXAP_FORM_SUBMIT_FAILED_METHOD, RXAP_FORM_SUBMIT_METHOD, RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD, RxapForm, RxapFormArray, RxapFormBuilder, RxapFormControl, RxapFormGroup, RxapFormsModule, RxapValidators, ToFormMethod, ToFormSubmitMethod, UseFormArrayControl, UseFormArrayGroup, UseFormControl, UseFormGroup, _IsNumber, controlDisabled$, controlDisabledWhile, controlEnabled$, controlEnabledWhile, controlErrorChanges$, controlReadonly$, controlStatusChanges$, controlValueChanges$, disableControl, enableControl, hasErrorAndDirty, hasErrorAndTouched, isNumber, markAllDirty, markAllPristine, markAllUntouched, mergeControlValidators, selectControlValue$, validateControlOn };
2580
2689
  //# sourceMappingURL=rxap-forms.js.map