@reactables/forms 2.0.0-beta.9 → 2.0.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/dist/Helpers/addAsyncValidationEffects.d.ts +7 -5
- package/dist/Helpers/buildFormState.d.ts +2 -2
- package/dist/Helpers/buildHub2Source.d.ts +1 -1
- package/dist/Models/Controls.d.ts +9 -8
- package/dist/Models/Validators.d.ts +1 -1
- package/dist/Reducers/Hub2/asyncValidation.d.ts +1 -1
- package/dist/Reducers/Hub2/asyncValidationResponse.d.ts +1 -1
- package/dist/Reducers/Hub2/formChange.d.ts +3 -3
- package/dist/Reducers/Hub2/mergeControls.d.ts +1 -1
- package/dist/Reducers/Hub2/mergeRemoveControl.d.ts +1 -1
- package/dist/RxForm/RxForm.d.ts +14 -14
- package/dist/Testing/Models/initialState.d.ts +1 -1
- package/dist/index.cjs +64 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +64 -61
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/Reducers/Hub1/index.d.ts +0 -6
- package/dist/Reducers/Hub2/index.d.ts +0 -3
- package/dist/Reducers/index.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var DEFAULT_HUB2_FIELDS = {
|
|
|
9
9
|
pending: false,
|
|
10
10
|
valid: null,
|
|
11
11
|
childrenValid: null,
|
|
12
|
-
errors:
|
|
12
|
+
errors: {},
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
var Controls = /*#__PURE__*/Object.freeze({
|
|
@@ -30,7 +30,7 @@ var required = function (value) {
|
|
|
30
30
|
return { required: false };
|
|
31
31
|
};
|
|
32
32
|
var arrayNotEmpty = function (value) { return ({
|
|
33
|
-
arrayNotEmpty: !Boolean(value.length)
|
|
33
|
+
arrayNotEmpty: !Boolean(value.length),
|
|
34
34
|
}); };
|
|
35
35
|
var email = function (value) {
|
|
36
36
|
return value && !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(value) ? { email: true } : { email: false };
|
|
@@ -147,16 +147,15 @@ var getErrors = function (control, value, _a) {
|
|
|
147
147
|
var _b;
|
|
148
148
|
var validators = _a.validators;
|
|
149
149
|
return ((_b = control.config.validators) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, validator) {
|
|
150
|
-
if (!validators[validator]) {
|
|
150
|
+
if (!(validators === null || validators === void 0 ? void 0 : validators[validator])) {
|
|
151
151
|
throw "You have not provided a validator for \"".concat(validator, "\"");
|
|
152
152
|
}
|
|
153
153
|
return __assign(__assign({}, acc), validators[validator](value));
|
|
154
154
|
}, {})) || {};
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
-
var buildState = function (config,
|
|
157
|
+
var buildState = function (config, controlRef, providers, form) {
|
|
158
158
|
var _a;
|
|
159
|
-
if (form === void 0) { form = { root: null }; }
|
|
160
159
|
if (controlRef === void 0) { controlRef = []; }
|
|
161
160
|
var value = getValueFromControlConfig(config);
|
|
162
161
|
var control = {
|
|
@@ -167,7 +166,7 @@ var buildState = function (config, form, controlRef, providers) {
|
|
|
167
166
|
controlRef: controlRef,
|
|
168
167
|
validatorErrors: {},
|
|
169
168
|
config: config,
|
|
170
|
-
key: generateKey(5)
|
|
169
|
+
key: generateKey(5),
|
|
171
170
|
};
|
|
172
171
|
var newForm = __assign(__assign({}, form), (_a = {}, _a[getFormKey(controlRef)] = __assign(__assign({}, control), { validatorErrors: getErrors(control, value, providers) }), _a));
|
|
173
172
|
var controls = config.controls;
|
|
@@ -175,22 +174,21 @@ var buildState = function (config, form, controlRef, providers) {
|
|
|
175
174
|
if (controls && !(controls instanceof Array)) {
|
|
176
175
|
newForm = Object.entries(config.controls).reduce(function (acc, _a) {
|
|
177
176
|
var key = _a[0], controlConfig = _a[1];
|
|
178
|
-
return buildState(controlConfig,
|
|
177
|
+
return buildState(controlConfig, controlRef.concat(key), providers, acc);
|
|
179
178
|
}, newForm);
|
|
180
179
|
}
|
|
181
180
|
else if (controls && controls instanceof Array) {
|
|
182
181
|
// Adding controls for Form Array
|
|
183
182
|
newForm = config.controls.reduce(function (acc, controlConfig, index) {
|
|
184
|
-
return buildState(controlConfig,
|
|
183
|
+
return buildState(controlConfig, controlRef.concat(index), providers, acc);
|
|
185
184
|
}, newForm);
|
|
186
185
|
}
|
|
187
186
|
return newForm;
|
|
188
187
|
};
|
|
189
|
-
var buildFormState = function (config,
|
|
190
|
-
if (form === void 0) { form = { root: null }; }
|
|
188
|
+
var buildFormState = function (config, controlRef, providers, form) {
|
|
191
189
|
if (controlRef === void 0) { controlRef = []; }
|
|
192
190
|
return {
|
|
193
|
-
form: buildState(config,
|
|
191
|
+
form: buildState(config, controlRef, providers, form),
|
|
194
192
|
};
|
|
195
193
|
};
|
|
196
194
|
|
|
@@ -201,7 +199,8 @@ var getScopedEffectsForControl = function (formControl, providers) {
|
|
|
201
199
|
if (asyncValidators && asyncValidators.length) {
|
|
202
200
|
scopedEffects = asyncValidators.reduce(function (acc, asyncValidator, validatorIndex) {
|
|
203
201
|
var effect = function (actions$) {
|
|
204
|
-
|
|
202
|
+
var _a;
|
|
203
|
+
if (!((_a = providers.asyncValidators) === null || _a === void 0 ? void 0 : _a[asyncValidator])) {
|
|
205
204
|
throw "You have not provided an asyncValidator for \"".concat(asyncValidator, "\"");
|
|
206
205
|
}
|
|
207
206
|
return actions$.pipe(map(function (_a) {
|
|
@@ -213,16 +212,16 @@ var getScopedEffectsForControl = function (formControl, providers) {
|
|
|
213
212
|
payload: {
|
|
214
213
|
key: key,
|
|
215
214
|
errors: errors,
|
|
216
|
-
validatorIndex: validatorIndex
|
|
217
|
-
}
|
|
215
|
+
validatorIndex: validatorIndex,
|
|
216
|
+
},
|
|
218
217
|
}); }), catchError(function () {
|
|
219
218
|
return of({
|
|
220
219
|
type: 'asyncValidationResponse',
|
|
221
220
|
payload: {
|
|
222
221
|
key: key,
|
|
223
222
|
errors: { asyncValidationApiError: true },
|
|
224
|
-
validatorIndex: validatorIndex
|
|
225
|
-
}
|
|
223
|
+
validatorIndex: validatorIndex,
|
|
224
|
+
},
|
|
226
225
|
});
|
|
227
226
|
})));
|
|
228
227
|
}));
|
|
@@ -281,7 +280,7 @@ var updateAncestorValues = function (form, _a, providers) {
|
|
|
281
280
|
}
|
|
282
281
|
var newParentControl = __assign(__assign({}, parentControl), { validatorErrors: getErrors(parentControl, newValue, providers), value: newValue, dirty: !isEqual(newValue, parentControl.pristineValue) });
|
|
283
282
|
return updateAncestorValues(__assign(__assign({}, form), (_c = {}, _c[parentFormKey] = newParentControl, _c)), {
|
|
284
|
-
payload: { controlRef: parentRef, value: newValue }
|
|
283
|
+
payload: { controlRef: parentRef, value: newValue },
|
|
285
284
|
}, providers);
|
|
286
285
|
}
|
|
287
286
|
return form;
|
|
@@ -303,7 +302,7 @@ var getDescendantControls = function (controlRef, form, excludeSelf) {
|
|
|
303
302
|
}
|
|
304
303
|
var control = getControl(controlRef, form);
|
|
305
304
|
var value = control.value, config = control.config;
|
|
306
|
-
var descendants;
|
|
305
|
+
var descendants = [];
|
|
307
306
|
if (Array.isArray(config.controls)) {
|
|
308
307
|
// If control is a Form Array
|
|
309
308
|
descendants = value.reduce(function (acc, item, index) {
|
|
@@ -329,11 +328,11 @@ var getAncestorControls = function (controlRef, form, excludeSelf) {
|
|
|
329
328
|
var formControls = acc.formControls.concat(getControl(currentRef, form));
|
|
330
329
|
return {
|
|
331
330
|
currentRef: currentRef,
|
|
332
|
-
formControls: formControls
|
|
331
|
+
formControls: formControls,
|
|
333
332
|
};
|
|
334
333
|
}, {
|
|
335
334
|
currentRef: [],
|
|
336
|
-
formControls: []
|
|
335
|
+
formControls: [],
|
|
337
336
|
}).formControls;
|
|
338
337
|
var root = form['root'];
|
|
339
338
|
var result = [root].concat(formControls);
|
|
@@ -405,7 +404,7 @@ var updateDescendantValues = function (form, _a, providers) {
|
|
|
405
404
|
if (configControls) {
|
|
406
405
|
checkKeys(oldChildValue, newChildValue);
|
|
407
406
|
acc = updateDescendantValues(acc, {
|
|
408
|
-
payload: { controlRef: control.controlRef, value: newChildValue }
|
|
407
|
+
payload: { controlRef: control.controlRef, value: newChildValue },
|
|
409
408
|
}, providers);
|
|
410
409
|
}
|
|
411
410
|
}
|
|
@@ -417,10 +416,11 @@ var updateDescendantValues = function (form, _a, providers) {
|
|
|
417
416
|
// Use AddControlPayload/RemoveControl action reducers to add/remove control
|
|
418
417
|
var updateValues = function (_a, action, providers, mergeChanges) {
|
|
419
418
|
var _b, _c;
|
|
420
|
-
var
|
|
419
|
+
var _d;
|
|
420
|
+
var form = _a.form, _e = _a._changedControls, _changedControls = _e === void 0 ? {} : _e, _f = _a._removedControls, _removedControls = _f === void 0 ? {} : _f;
|
|
421
421
|
if (mergeChanges === void 0) { mergeChanges = false; }
|
|
422
422
|
var normalizers = providers.normalizers;
|
|
423
|
-
var
|
|
423
|
+
var _g = action.payload, controlRef = _g.controlRef, value = _g.value;
|
|
424
424
|
controlRefCheck(controlRef);
|
|
425
425
|
// Update its own value
|
|
426
426
|
var ctrlKey = getFormKey(controlRef);
|
|
@@ -428,8 +428,8 @@ var updateValues = function (_a, action, providers, mergeChanges) {
|
|
|
428
428
|
var oldValue = form[ctrlKey].value;
|
|
429
429
|
var config = form[ctrlKey].config;
|
|
430
430
|
if (config.normalizers) {
|
|
431
|
-
newValue = config.normalizers.reduce(function (acc, normalizer) {
|
|
432
|
-
if (!normalizers[normalizer]) {
|
|
431
|
+
newValue = (_d = config.normalizers) === null || _d === void 0 ? void 0 : _d.reduce(function (acc, normalizer) {
|
|
432
|
+
if (!(normalizers === null || normalizers === void 0 ? void 0 : normalizers[normalizer])) {
|
|
433
433
|
throw "You have not provided a normalizer for \"".concat(normalizer, "\"");
|
|
434
434
|
}
|
|
435
435
|
return normalizers[normalizer](acc);
|
|
@@ -439,7 +439,7 @@ var updateValues = function (_a, action, providers, mergeChanges) {
|
|
|
439
439
|
var newControl = __assign(__assign({}, form[ctrlKey]), { validatorErrors: validatorErrors, dirty: !isEqual(value, form[ctrlKey].pristineValue), value: newValue });
|
|
440
440
|
var result = {
|
|
441
441
|
form: __assign(__assign({}, form), (_b = {}, _b[ctrlKey] = newControl, _b)),
|
|
442
|
-
_changedControls: (_c = {}, _c[newControl.key] = newControl, _c)
|
|
442
|
+
_changedControls: (_c = {}, _c[newControl.key] = newControl, _c),
|
|
443
443
|
};
|
|
444
444
|
var configControls = config.controls;
|
|
445
445
|
// Update its descendants
|
|
@@ -448,8 +448,8 @@ var updateValues = function (_a, action, providers, mergeChanges) {
|
|
|
448
448
|
var updatedDescendants = updateDescendantValues(result.form, {
|
|
449
449
|
payload: {
|
|
450
450
|
controlRef: controlRef,
|
|
451
|
-
value: newValue
|
|
452
|
-
}
|
|
451
|
+
value: newValue,
|
|
452
|
+
},
|
|
453
453
|
}, providers);
|
|
454
454
|
var changedDescendantControls = getDescendantControls(controlRef, updatedDescendants).reduce(function (acc, control) {
|
|
455
455
|
var _a;
|
|
@@ -460,7 +460,7 @@ var updateValues = function (_a, action, providers, mergeChanges) {
|
|
|
460
460
|
// Update its Ancestors
|
|
461
461
|
if (controlRef.length) {
|
|
462
462
|
result = __assign(__assign({}, result), { form: updateAncestorValues(result.form, {
|
|
463
|
-
payload: { controlRef: controlRef, value: newValue }
|
|
463
|
+
payload: { controlRef: controlRef, value: newValue },
|
|
464
464
|
}, providers) });
|
|
465
465
|
}
|
|
466
466
|
var changedAncestorControls = getAncestorControls(controlRef, result.form).reduce(function (acc, control) {
|
|
@@ -491,7 +491,7 @@ var updateAncestorValuesRemoveControl = function (form, _a, providers) {
|
|
|
491
491
|
}
|
|
492
492
|
var newParentControl = __assign(__assign({}, parentControl), { value: newValue, validatorErrors: getErrors(parentControl, newValue, providers), dirty: !isEqual(newValue, parentControl.pristineValue) });
|
|
493
493
|
return updateAncestorValues(__assign(__assign({}, form), (_b = {}, _b[parentFormKey] = newParentControl, _b)), {
|
|
494
|
-
payload: { controlRef: parentRef, value: newValue }
|
|
494
|
+
payload: { controlRef: parentRef, value: newValue },
|
|
495
495
|
}, providers);
|
|
496
496
|
}
|
|
497
497
|
return form;
|
|
@@ -545,7 +545,7 @@ var removeControl = function (state, action, providers, mergeChanges) {
|
|
|
545
545
|
return __assign(__assign({}, acc), (_c = {}, _c[key] = control, _c));
|
|
546
546
|
}, {});
|
|
547
547
|
var result = updateAncestorValuesRemoveControl(controlRemoved, {
|
|
548
|
-
payload: controlRef
|
|
548
|
+
payload: controlRef,
|
|
549
549
|
}, providers);
|
|
550
550
|
var _changedControls = __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), getAncestorControls(controlRef.slice(0, -1), result).reduce(function (acc, control) {
|
|
551
551
|
var _a;
|
|
@@ -586,7 +586,7 @@ var removeControl = function (state, action, providers, mergeChanges) {
|
|
|
586
586
|
return {
|
|
587
587
|
form: result,
|
|
588
588
|
_changedControls: _changedControls,
|
|
589
|
-
_removedControls: _removedControls
|
|
589
|
+
_removedControls: _removedControls,
|
|
590
590
|
};
|
|
591
591
|
};
|
|
592
592
|
|
|
@@ -609,7 +609,7 @@ var updateAncestorValuesAddControl = function (form, _a, providers) {
|
|
|
609
609
|
}
|
|
610
610
|
var newParentControl = __assign(__assign({}, parentControl), { value: newValue, validatorErrors: getErrors(parentControl, newValue, providers), dirty: !isEqual(newValue, parentControl.pristineValue) });
|
|
611
611
|
return updateAncestorValues(__assign(__assign({}, form), (_c = {}, _c[parentFormKey] = newParentControl, _c)), {
|
|
612
|
-
payload: { controlRef: parentRef, value: newValue }
|
|
612
|
+
payload: { controlRef: parentRef, value: newValue },
|
|
613
613
|
}, providers);
|
|
614
614
|
}
|
|
615
615
|
return form;
|
|
@@ -629,10 +629,10 @@ var addControl = function (state, action, providers, mergeChanges) {
|
|
|
629
629
|
if (!getControl(controlRef.slice(0, -1), state.form)) {
|
|
630
630
|
throw 'You are attempting to add a control to a non-existent form group';
|
|
631
631
|
}
|
|
632
|
-
var newForm = buildState(config,
|
|
632
|
+
var newForm = buildState(config, controlRef, providers, state.form);
|
|
633
633
|
var newValue = getControl(controlRef, newForm).value;
|
|
634
634
|
var ancestorsUpdated = updateAncestorValuesAddControl(newForm, {
|
|
635
|
-
payload: { controlRef: controlRef, value: newValue }
|
|
635
|
+
payload: { controlRef: controlRef, value: newValue },
|
|
636
636
|
}, providers);
|
|
637
637
|
var _changedControls = getControlBranch(controlRef, ancestorsUpdated).reduce(function (acc, control) {
|
|
638
638
|
var _a;
|
|
@@ -641,7 +641,7 @@ var addControl = function (state, action, providers, mergeChanges) {
|
|
|
641
641
|
return {
|
|
642
642
|
form: ancestorsUpdated,
|
|
643
643
|
_changedControls: __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), _changedControls),
|
|
644
|
-
_removedControls: mergeChanges ? state._removedControls || {} : undefined
|
|
644
|
+
_removedControls: mergeChanges ? state._removedControls || {} : undefined,
|
|
645
645
|
};
|
|
646
646
|
};
|
|
647
647
|
|
|
@@ -660,10 +660,10 @@ var pushControl = function (state, action, providers, mergeChanges) {
|
|
|
660
660
|
else {
|
|
661
661
|
throw 'You are attempting to push to a control that is not a Form Array';
|
|
662
662
|
}
|
|
663
|
-
var newForm = buildState(config,
|
|
663
|
+
var newForm = buildState(config, newControlRef, providers, state.form);
|
|
664
664
|
var newValue = getControl(newControlRef, newForm).value;
|
|
665
665
|
var ancestorsUpdated = updateAncestorValuesAddControl(newForm, {
|
|
666
|
-
payload: { controlRef: newControlRef, value: newValue }
|
|
666
|
+
payload: { controlRef: newControlRef, value: newValue },
|
|
667
667
|
}, providers);
|
|
668
668
|
var _changedControls = getControlBranch(newControlRef, ancestorsUpdated).reduce(function (acc, control) {
|
|
669
669
|
var _a;
|
|
@@ -672,7 +672,7 @@ var pushControl = function (state, action, providers, mergeChanges) {
|
|
|
672
672
|
return {
|
|
673
673
|
form: ancestorsUpdated,
|
|
674
674
|
_changedControls: __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), _changedControls),
|
|
675
|
-
_removedControls: mergeChanges ? state._removedControls || {} : undefined
|
|
675
|
+
_removedControls: mergeChanges ? state._removedControls || {} : undefined,
|
|
676
676
|
};
|
|
677
677
|
};
|
|
678
678
|
|
|
@@ -703,7 +703,7 @@ var updateAncestorPristineValues = function (form, _a) {
|
|
|
703
703
|
}
|
|
704
704
|
var newParentControl = __assign(__assign({}, form[parentKey]), { pristineValue: newValue, dirty: isEqual(form[parentKey].value, newValue) });
|
|
705
705
|
return updateAncestorPristineValues(__assign(__assign({}, form), (_b = {}, _b[parentKey] = newParentControl, _b)), {
|
|
706
|
-
payload: parentRef
|
|
706
|
+
payload: parentRef,
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
709
|
return form;
|
|
@@ -721,7 +721,7 @@ var markControlAsPristine = function (state, action, mergeChanges) {
|
|
|
721
721
|
var result = __assign(__assign({}, form), descendants);
|
|
722
722
|
if (controlRef.length) {
|
|
723
723
|
result = updateAncestorPristineValues(result, {
|
|
724
|
-
payload: controlRef
|
|
724
|
+
payload: controlRef,
|
|
725
725
|
});
|
|
726
726
|
}
|
|
727
727
|
var _changedControls = getControlBranch(controlRef, result).reduce(function (acc, control) {
|
|
@@ -731,7 +731,7 @@ var markControlAsPristine = function (state, action, mergeChanges) {
|
|
|
731
731
|
return {
|
|
732
732
|
form: result,
|
|
733
733
|
_changedControls: __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), _changedControls),
|
|
734
|
-
_removedControls: mergeChanges ? state._removedControls || {} : undefined
|
|
734
|
+
_removedControls: mergeChanges ? state._removedControls || {} : undefined,
|
|
735
735
|
};
|
|
736
736
|
};
|
|
737
737
|
|
|
@@ -753,7 +753,7 @@ var markControlAsTouched = function (state, action, mergeChanges) {
|
|
|
753
753
|
return {
|
|
754
754
|
form: __assign(__assign({}, form), controls),
|
|
755
755
|
_changedControls: __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), _changedControls),
|
|
756
|
-
_removedControls: mergeChanges ? state._removedControls || {} : undefined
|
|
756
|
+
_removedControls: mergeChanges ? state._removedControls || {} : undefined,
|
|
757
757
|
};
|
|
758
758
|
};
|
|
759
759
|
|
|
@@ -783,7 +783,7 @@ var markControlAsUntouched = function (state, action, mergeChanges) {
|
|
|
783
783
|
return {
|
|
784
784
|
form: result,
|
|
785
785
|
_changedControls: __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), _changedControls),
|
|
786
|
-
_removedControls: mergeChanges ? state._removedControls || {} : undefined
|
|
786
|
+
_removedControls: mergeChanges ? state._removedControls || {} : undefined,
|
|
787
787
|
};
|
|
788
788
|
};
|
|
789
789
|
|
|
@@ -804,10 +804,10 @@ var resetControl = function (state, action, providers, mergeChanges) {
|
|
|
804
804
|
delete descendantsRemoved[key];
|
|
805
805
|
});
|
|
806
806
|
// Remove all descendants
|
|
807
|
-
var restoredControls = buildState(controlToReset.config,
|
|
807
|
+
var restoredControls = buildState(controlToReset.config, controlToReset.controlRef, providers, descendantsRemoved);
|
|
808
808
|
var restoredControlValue = getControl(controlRef, restoredControls).value;
|
|
809
809
|
var result = updateAncestorValues(restoredControls, {
|
|
810
|
-
payload: { controlRef: controlRef, value: restoredControlValue }
|
|
810
|
+
payload: { controlRef: controlRef, value: restoredControlValue },
|
|
811
811
|
}, providers);
|
|
812
812
|
var _changedControls = __assign(__assign({}, (mergeChanges ? state._changedControls || {} : undefined)), getControlBranch(controlRef, result).reduce(function (acc, control) {
|
|
813
813
|
var _a;
|
|
@@ -826,7 +826,7 @@ var resetControl = function (state, action, providers, mergeChanges) {
|
|
|
826
826
|
return {
|
|
827
827
|
form: result,
|
|
828
828
|
_changedControls: _changedControls,
|
|
829
|
-
_removedControls: _removedControls
|
|
829
|
+
_removedControls: _removedControls,
|
|
830
830
|
};
|
|
831
831
|
};
|
|
832
832
|
|
|
@@ -834,12 +834,14 @@ var asyncValidation = function (form, _a) {
|
|
|
834
834
|
var controlRef = _a.payload;
|
|
835
835
|
var updatedSelfAndAncestors = getAncestorControls(controlRef, form).reduce(function (acc, control) {
|
|
836
836
|
var _a;
|
|
837
|
+
var _b;
|
|
837
838
|
var isChangedControl = getFormKey(control.controlRef) === getFormKey(controlRef);
|
|
838
839
|
return __assign(__assign({}, acc), (_a = {}, _a[getFormKey(control.controlRef)] = __assign(__assign({}, control), { pending: true, asyncValidateInProgress: isChangedControl
|
|
839
|
-
? __assign({}, control.config.asyncValidators.reduce(function (acc, _, index) {
|
|
840
|
+
? __assign({}, (_b = control.config.asyncValidators) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, _, index) {
|
|
840
841
|
var _a;
|
|
841
842
|
return (__assign(__assign({}, acc), (_a = {}, _a[index] = true, _a)));
|
|
842
|
-
}, {}))
|
|
843
|
+
}, {}))
|
|
844
|
+
: control.asyncValidateInProgress }), _a));
|
|
843
845
|
}, {});
|
|
844
846
|
return __assign(__assign({}, form), updatedSelfAndAncestors);
|
|
845
847
|
};
|
|
@@ -1060,7 +1062,7 @@ var control = function (config) {
|
|
|
1060
1062
|
var indexMap = {
|
|
1061
1063
|
0: 'initialValue',
|
|
1062
1064
|
1: 'validators',
|
|
1063
|
-
2: 'asyncValidators'
|
|
1065
|
+
2: 'asyncValidators',
|
|
1064
1066
|
};
|
|
1065
1067
|
return __assign(__assign({}, acc), (_a = {}, _a[indexMap[index]] = index < 1 ? item : [].concat(item || []), _a));
|
|
1066
1068
|
}, {});
|
|
@@ -1093,7 +1095,7 @@ var reducerTools = function (providers) { return ({
|
|
|
1093
1095
|
},
|
|
1094
1096
|
markControlAsUntouched: function (state, payload) {
|
|
1095
1097
|
return markControlAsUntouched(state, { payload: payload }, true);
|
|
1096
|
-
}
|
|
1098
|
+
},
|
|
1097
1099
|
}); };
|
|
1098
1100
|
var build = function (config, options) {
|
|
1099
1101
|
var _a, _b, _c;
|
|
@@ -1101,9 +1103,9 @@ var build = function (config, options) {
|
|
|
1101
1103
|
var providers = {
|
|
1102
1104
|
normalizers: __assign({}, (_a = options.providers) === null || _a === void 0 ? void 0 : _a.normalizers),
|
|
1103
1105
|
validators: __assign(__assign({}, Validators), (_b = options.providers) === null || _b === void 0 ? void 0 : _b.validators),
|
|
1104
|
-
asyncValidators: __assign({}, (_c = options.providers) === null || _c === void 0 ? void 0 : _c.asyncValidators)
|
|
1106
|
+
asyncValidators: __assign({}, (_c = options.providers) === null || _c === void 0 ? void 0 : _c.asyncValidators),
|
|
1105
1107
|
};
|
|
1106
|
-
var initialState = buildFormState(config, undefined,
|
|
1108
|
+
var initialState = buildFormState(config, undefined, providers);
|
|
1107
1109
|
return createReactable(initialState, options);
|
|
1108
1110
|
};
|
|
1109
1111
|
var load = function (state, options) {
|
|
@@ -1122,7 +1124,7 @@ var load = function (state, options) {
|
|
|
1122
1124
|
var key = _a[0], value = _a[1];
|
|
1123
1125
|
return (__assign(__assign({}, acc), (_b = {}, _b[key] = value, _b)));
|
|
1124
1126
|
}, {}), _b));
|
|
1125
|
-
}, {})
|
|
1127
|
+
}, {}),
|
|
1126
1128
|
};
|
|
1127
1129
|
return createReactable(baseFormState, options);
|
|
1128
1130
|
};
|
|
@@ -1132,7 +1134,7 @@ var createReactable = function (initialBaseState, options, initialFormState) {
|
|
|
1132
1134
|
var providers = {
|
|
1133
1135
|
normalizers: __assign({}, (_a = options.providers) === null || _a === void 0 ? void 0 : _a.normalizers),
|
|
1134
1136
|
validators: __assign(__assign({}, Validators), (_b = options.providers) === null || _b === void 0 ? void 0 : _b.validators),
|
|
1135
|
-
asyncValidators: __assign({}, (_c = options.providers) === null || _c === void 0 ? void 0 : _c.asyncValidators)
|
|
1137
|
+
asyncValidators: __assign({}, (_c = options.providers) === null || _c === void 0 ? void 0 : _c.asyncValidators),
|
|
1136
1138
|
};
|
|
1137
1139
|
var reducers = options.reducers, debug = options.debug, name = options.name, otherOptions = __rest(options, ["reducers", "debug", "name"]);
|
|
1138
1140
|
var customReducers = Object.entries(reducers || {}).reduce(function (acc, _a) {
|
|
@@ -1145,7 +1147,7 @@ var createReactable = function (initialBaseState, options, initialFormState) {
|
|
|
1145
1147
|
var form = _a.form;
|
|
1146
1148
|
return _reducer(reducerTools(providers), { form: form }, action);
|
|
1147
1149
|
},
|
|
1148
|
-
effects: effects
|
|
1150
|
+
effects: effects,
|
|
1149
1151
|
}, _b));
|
|
1150
1152
|
}, {});
|
|
1151
1153
|
var _d = RxBuilder(__assign({ initialState: initialBaseState, name: "Stage 1 ".concat(name ? name : 'rxForm'), debug: debug, reducers: __assign({ updateValues: function (state, action) {
|
|
@@ -1172,20 +1174,21 @@ var createReactable = function (initialBaseState, options, initialFormState) {
|
|
|
1172
1174
|
reducer: function (state) { return state; },
|
|
1173
1175
|
effects: function (control) { return ({
|
|
1174
1176
|
key: control.key,
|
|
1175
|
-
effects: getScopedEffectsForControl(control, providers)
|
|
1176
|
-
}); }
|
|
1177
|
+
effects: getScopedEffectsForControl(control, providers),
|
|
1178
|
+
}); },
|
|
1177
1179
|
},
|
|
1178
1180
|
asyncValidation: asyncValidation,
|
|
1179
|
-
asyncValidationResponse: asyncValidationResponse
|
|
1180
|
-
}
|
|
1181
|
+
asyncValidationResponse: asyncValidationResponse,
|
|
1182
|
+
},
|
|
1181
1183
|
}), state$ = _e[0], hub2Actions = _e[1];
|
|
1182
1184
|
var destroy = function () {
|
|
1183
1185
|
hub1Actions.destroy();
|
|
1184
1186
|
hub2Actions.destroy();
|
|
1185
1187
|
};
|
|
1188
|
+
var actions = __assign(__assign({}, hub1Actions), { destroy: destroy });
|
|
1186
1189
|
return [
|
|
1187
1190
|
state$.pipe(filter(function (form) { return form !== null; })),
|
|
1188
|
-
|
|
1191
|
+
actions,
|
|
1189
1192
|
hub1Actions$,
|
|
1190
1193
|
];
|
|
1191
1194
|
};
|