@rxap/forms 12.5.1-next.1 → 12.6.0
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 +120 -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-successful.directive.js +40 -0
- package/esm2015/lib/directives/form-submit-successful.directive.js.map +1 -0
- package/esm2015/lib/directives/form.directive.js +6 -1
- package/esm2015/lib/directives/form.directive.js.map +1 -1
- package/esm2015/lib/directives/forms.module.js +9 -4
- package/esm2015/lib/directives/forms.module.js.map +1 -1
- package/esm2015/lib/form-builder.js +65 -3
- package/esm2015/lib/form-builder.js.map +1 -1
- package/esm2015/lib/validators/is-number.js +1 -1
- package/esm2015/lib/validators/is-number.js.map +1 -1
- package/fesm2015/rxap-forms.js +116 -10
- package/fesm2015/rxap-forms.js.map +1 -1
- package/index.d.ts +1 -0
- package/lib/directives/form-submit-successful.directive.d.ts +16 -0
- package/lib/directives/form.directive.d.ts +2 -1
- package/lib/directives/forms.module.d.ts +2 -1
- package/lib/form-builder.d.ts +26 -0
- package/lib/validators/is-number.d.ts +1 -0
- package/package.json +6 -5
|
@@ -1189,7 +1189,7 @@
|
|
|
1189
1189
|
try {
|
|
1190
1190
|
for (var _d = __values(this.formArrayControls.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1191
1191
|
var _f = __read(_e.value, 2), controlId = _f[0], options = _f[1];
|
|
1192
|
-
var formState = this.
|
|
1192
|
+
var formState = this.coerceToArrayFormState(controlId, [], builderFormState, options.state);
|
|
1193
1193
|
utilities.assertIsArray(formState);
|
|
1194
1194
|
var formControls = formState.map(function (fs, index) { return new RxapFormControl(fs, { controlId: index.toFixed(0) }); });
|
|
1195
1195
|
var manager = new FormArrayControlManager(form, controlId);
|
|
@@ -1215,7 +1215,7 @@
|
|
|
1215
1215
|
RxapFormBuilder.prototype.buildArrayGroups = function (builderFormState, form, controls) {
|
|
1216
1216
|
var e_4, _c;
|
|
1217
1217
|
var _loop_1 = function (controlId, options) {
|
|
1218
|
-
var formState = this_1.
|
|
1218
|
+
var formState = this_1.coerceToArrayFormState(controlId, [], builderFormState, options.state);
|
|
1219
1219
|
utilities.assertIsArray(formState);
|
|
1220
1220
|
var formGroupBuilder = new RxapFormBuilder(options.definition, this_1.injector, this_1.providers);
|
|
1221
1221
|
// TODO : add the formGroupOptions property. To definition of the form group options
|
|
@@ -1249,7 +1249,7 @@
|
|
|
1249
1249
|
try {
|
|
1250
1250
|
for (var _d = __values(this.formGroups.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1251
1251
|
var _f = __read(_e.value, 2), controlId = _f[0], options = _f[1];
|
|
1252
|
-
var formState = this.
|
|
1252
|
+
var formState = this.coerceToGroupFormState(controlId, {}, builderFormState, options.state);
|
|
1253
1253
|
utilities.assertIsObject(formState);
|
|
1254
1254
|
var formGroupDefinition = new RxapFormBuilder(options.definition, this.injector, this.providers).build(formState, Object.assign(Object.assign({}, options), { validators: [], asyncValidators: [] }));
|
|
1255
1255
|
controls[controlId] = formGroupDefinition.rxapFormGroup;
|
|
@@ -1405,6 +1405,68 @@
|
|
|
1405
1405
|
}
|
|
1406
1406
|
return formState;
|
|
1407
1407
|
};
|
|
1408
|
+
/**
|
|
1409
|
+
* Coerce to the form state for the specified controlId. If none form state is
|
|
1410
|
+
* found the default form state will be returned.
|
|
1411
|
+
*
|
|
1412
|
+
* The difference to the method coerceToControlFormState is that null will be
|
|
1413
|
+
* handled as undefined and the defaultFormState is used
|
|
1414
|
+
*
|
|
1415
|
+
* @param controlId A control id
|
|
1416
|
+
* @param defaultFormState The default form state
|
|
1417
|
+
* @param builderFormState The form state provides as build state parameter
|
|
1418
|
+
* @param optionsFormState The form state set by the decorator in the form definition
|
|
1419
|
+
*/
|
|
1420
|
+
RxapFormBuilder.prototype.coerceToGroupFormState = function (controlId, defaultFormState, builderFormState, optionsFormState) {
|
|
1421
|
+
var formState = defaultFormState;
|
|
1422
|
+
if (builderFormState && builderFormState[controlId]) {
|
|
1423
|
+
formState = builderFormState[controlId];
|
|
1424
|
+
}
|
|
1425
|
+
else if (optionsFormState) {
|
|
1426
|
+
formState = optionsFormState;
|
|
1427
|
+
}
|
|
1428
|
+
if (typeof formState === 'function') {
|
|
1429
|
+
formState = formState();
|
|
1430
|
+
if (!formState) {
|
|
1431
|
+
throw new Error("The form state function for the form group '" + controlId + "' returns a empty value (null/undefined)");
|
|
1432
|
+
}
|
|
1433
|
+
if (typeof formState !== 'object') {
|
|
1434
|
+
throw new Error("The form state function for the form group '" + controlId + "' returns a non object like value instead '" + typeof formState + "'");
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
return formState;
|
|
1438
|
+
};
|
|
1439
|
+
/**
|
|
1440
|
+
* Coerce to the form state for the specified controlId. If none form state is
|
|
1441
|
+
* found the default form state will be returned.
|
|
1442
|
+
*
|
|
1443
|
+
* The difference to the method coerceToControlFormState is that null will be
|
|
1444
|
+
* handled as undefined and the defaultFormState is used
|
|
1445
|
+
*
|
|
1446
|
+
* @param controlId A control id
|
|
1447
|
+
* @param defaultFormState The default form state
|
|
1448
|
+
* @param builderFormState The form state provides as build state parameter
|
|
1449
|
+
* @param optionsFormState The form state set by the decorator in the form definition
|
|
1450
|
+
*/
|
|
1451
|
+
RxapFormBuilder.prototype.coerceToArrayFormState = function (controlId, defaultFormState, builderFormState, optionsFormState) {
|
|
1452
|
+
var formState = defaultFormState;
|
|
1453
|
+
if (builderFormState && builderFormState[controlId] && Array.isArray(builderFormState[controlId])) {
|
|
1454
|
+
formState = builderFormState[controlId];
|
|
1455
|
+
}
|
|
1456
|
+
else if (optionsFormState && Array.isArray(optionsFormState)) {
|
|
1457
|
+
formState = optionsFormState;
|
|
1458
|
+
}
|
|
1459
|
+
if (typeof formState === 'function') {
|
|
1460
|
+
formState = formState();
|
|
1461
|
+
if (!formState) {
|
|
1462
|
+
throw new Error("The form state function for the form array '" + controlId + "' returns a empty value (null/undefined)");
|
|
1463
|
+
}
|
|
1464
|
+
if (!Array.isArray(formState)) {
|
|
1465
|
+
throw new Error("The form state function for the form array '" + controlId + "' returns a non array like value instead '" + typeof formState + "'");
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
return formState;
|
|
1469
|
+
};
|
|
1408
1470
|
RxapFormBuilder.prototype.extractControlChanges = function () {
|
|
1409
1471
|
var _a;
|
|
1410
1472
|
return ((_a = reflectMetadata.getMetadata(MetadataKeys.CONTROL_CHANGES, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
@@ -1634,6 +1696,7 @@
|
|
|
1634
1696
|
*/
|
|
1635
1697
|
_this.rxapSubmit = new i0.EventEmitter();
|
|
1636
1698
|
_this.invalidSubmit = new i0.EventEmitter();
|
|
1699
|
+
_this.submitSuccessful$ = new i0.EventEmitter();
|
|
1637
1700
|
_this.submitting$ = new rxjs$1.ToggleSubject();
|
|
1638
1701
|
_this.submitError$ = new rxjs.BehaviorSubject(null);
|
|
1639
1702
|
_this.loading$ = new rxjs$1.ToggleSubject();
|
|
@@ -1944,6 +2007,7 @@
|
|
|
1944
2007
|
}
|
|
1945
2008
|
};
|
|
1946
2009
|
FormDirective.prototype.submitSuccessful = function (value) {
|
|
2010
|
+
this.submitSuccessful$.next(value);
|
|
1947
2011
|
if (this.submitSuccessfulMethod) {
|
|
1948
2012
|
this.submitSuccessfulMethod.call(value);
|
|
1949
2013
|
}
|
|
@@ -1966,7 +2030,7 @@
|
|
|
1966
2030
|
return FormDirective;
|
|
1967
2031
|
}(i1.FormGroupDirective));
|
|
1968
2032
|
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 });
|
|
1969
|
-
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: [
|
|
2033
|
+
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: [
|
|
1970
2034
|
{
|
|
1971
2035
|
provide: i1.ControlContainer,
|
|
1972
2036
|
// ignore coverage
|
|
@@ -2134,6 +2198,9 @@
|
|
|
2134
2198
|
type: i0.Output
|
|
2135
2199
|
}], invalidSubmit: [{
|
|
2136
2200
|
type: i0.Output
|
|
2201
|
+
}], submitSuccessful$: [{
|
|
2202
|
+
type: i0.Output,
|
|
2203
|
+
args: ['submitSuccessful']
|
|
2137
2204
|
}], submitting: [{
|
|
2138
2205
|
type: i0.HostBinding,
|
|
2139
2206
|
args: ['class.rxap-submitting']
|
|
@@ -2753,6 +2820,45 @@
|
|
|
2753
2820
|
}]
|
|
2754
2821
|
}] });
|
|
2755
2822
|
|
|
2823
|
+
var FormSubmitSuccessfulDirective = /** @class */ (function () {
|
|
2824
|
+
function FormSubmitSuccessfulDirective(formDirective, template, viewContainerRef) {
|
|
2825
|
+
this.formDirective = formDirective;
|
|
2826
|
+
this.template = template;
|
|
2827
|
+
this.viewContainerRef = viewContainerRef;
|
|
2828
|
+
}
|
|
2829
|
+
FormSubmitSuccessfulDirective.prototype.ngAfterViewInit = function () {
|
|
2830
|
+
var _this = this;
|
|
2831
|
+
this.subscription = this.formDirective.submitSuccessful$.pipe(operators.tap(function (result) {
|
|
2832
|
+
_this.viewContainerRef.clear();
|
|
2833
|
+
_this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: result });
|
|
2834
|
+
})).subscribe();
|
|
2835
|
+
};
|
|
2836
|
+
FormSubmitSuccessfulDirective.prototype.ngOnDestroy = function () {
|
|
2837
|
+
var _a;
|
|
2838
|
+
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2839
|
+
};
|
|
2840
|
+
return FormSubmitSuccessfulDirective;
|
|
2841
|
+
}());
|
|
2842
|
+
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 });
|
|
2843
|
+
FormSubmitSuccessfulDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitSuccessfulDirective, selector: "[rxapFormSubmitSuccessful]", ngImport: i0__namespace });
|
|
2844
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitSuccessfulDirective, decorators: [{
|
|
2845
|
+
type: i0.Directive,
|
|
2846
|
+
args: [{
|
|
2847
|
+
selector: '[rxapFormSubmitSuccessful]'
|
|
2848
|
+
}]
|
|
2849
|
+
}], ctorParameters: function () {
|
|
2850
|
+
return [{ type: FormDirective, decorators: [{
|
|
2851
|
+
type: i0.Inject,
|
|
2852
|
+
args: [FormDirective]
|
|
2853
|
+
}] }, { type: i0__namespace.TemplateRef, decorators: [{
|
|
2854
|
+
type: i0.Inject,
|
|
2855
|
+
args: [i0.TemplateRef]
|
|
2856
|
+
}] }, { type: i0__namespace.ViewContainerRef, decorators: [{
|
|
2857
|
+
type: i0.Inject,
|
|
2858
|
+
args: [i0.ViewContainerRef]
|
|
2859
|
+
}] }];
|
|
2860
|
+
} });
|
|
2861
|
+
|
|
2756
2862
|
var RxapFormsModule = /** @class */ (function () {
|
|
2757
2863
|
function RxapFormsModule() {
|
|
2758
2864
|
}
|
|
@@ -2773,7 +2879,8 @@
|
|
|
2773
2879
|
FormSubmitDirective,
|
|
2774
2880
|
FormGroupNameDirective,
|
|
2775
2881
|
FormControlNameDirective,
|
|
2776
|
-
ParentControlContainerDirective
|
|
2882
|
+
ParentControlContainerDirective,
|
|
2883
|
+
FormSubmitSuccessfulDirective], exports: [FormDirective,
|
|
2777
2884
|
FormSubmitFailedDirective,
|
|
2778
2885
|
FormLoadingDirective,
|
|
2779
2886
|
FormSubmittingDirective,
|
|
@@ -2787,7 +2894,8 @@
|
|
|
2787
2894
|
FormSubmitDirective,
|
|
2788
2895
|
FormGroupNameDirective,
|
|
2789
2896
|
FormControlNameDirective,
|
|
2790
|
-
ParentControlContainerDirective
|
|
2897
|
+
ParentControlContainerDirective,
|
|
2898
|
+
FormSubmitSuccessfulDirective] });
|
|
2791
2899
|
RxapFormsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule });
|
|
2792
2900
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule, decorators: [{
|
|
2793
2901
|
type: i0.NgModule,
|
|
@@ -2807,7 +2915,8 @@
|
|
|
2807
2915
|
FormSubmitDirective,
|
|
2808
2916
|
FormGroupNameDirective,
|
|
2809
2917
|
FormControlNameDirective,
|
|
2810
|
-
ParentControlContainerDirective
|
|
2918
|
+
ParentControlContainerDirective,
|
|
2919
|
+
FormSubmitSuccessfulDirective,
|
|
2811
2920
|
],
|
|
2812
2921
|
exports: [
|
|
2813
2922
|
FormDirective,
|
|
@@ -2824,7 +2933,8 @@
|
|
|
2824
2933
|
FormSubmitDirective,
|
|
2825
2934
|
FormGroupNameDirective,
|
|
2826
2935
|
FormControlNameDirective,
|
|
2827
|
-
ParentControlContainerDirective
|
|
2936
|
+
ParentControlContainerDirective,
|
|
2937
|
+
FormSubmitSuccessfulDirective,
|
|
2828
2938
|
]
|
|
2829
2939
|
}]
|
|
2830
2940
|
}] });
|
|
@@ -2887,7 +2997,7 @@
|
|
|
2887
2997
|
if (control.value === null) {
|
|
2888
2998
|
return null;
|
|
2889
2999
|
}
|
|
2890
|
-
if (!isNumber(control.value, options)) {
|
|
3000
|
+
if (!isNumber(!(options === null || options === void 0 ? void 0 : options.strict) && typeof control.value === 'string' ? Number(control.value) : control.value, options)) {
|
|
2891
3001
|
return {
|
|
2892
3002
|
isNumber: {
|
|
2893
3003
|
expected: 'A number value',
|
|
@@ -3258,6 +3368,7 @@
|
|
|
3258
3368
|
exports.FormLoadingErrorDirective = FormLoadingErrorDirective;
|
|
3259
3369
|
exports.FormSubmitDirective = FormSubmitDirective;
|
|
3260
3370
|
exports.FormSubmitFailedDirective = FormSubmitFailedDirective;
|
|
3371
|
+
exports.FormSubmitSuccessfulDirective = FormSubmitSuccessfulDirective;
|
|
3261
3372
|
exports.FormSubmittingDirective = FormSubmittingDirective;
|
|
3262
3373
|
exports.IsArray = IsArray;
|
|
3263
3374
|
exports.IsBoolean = IsBoolean;
|