@reactables/forms 2.0.0-beta.1 → 2.0.0-beta.10
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 +8 -6
- 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/FormErrors.d.ts +1 -1
- 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 +16 -21
- package/dist/RxForm/index.d.ts +1 -1
- package/dist/Testing/Models/initialState.d.ts +1 -1
- package/dist/index.cjs +30 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -25
- 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
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect } from '@reactables/core';
|
|
2
2
|
import { BaseControl } from '../Models/Controls';
|
|
3
|
-
import { ControlAsyncValidationResponse } from '../Models/Payloads';
|
|
4
3
|
import { RxFormProviders } from '../RxForm/RxForm';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
8
|
-
|
|
4
|
+
type ControlScopedEffect<T> = Effect;
|
|
5
|
+
export declare const getScopedEffectsForControl: <T>(formControl: BaseControl<T>, providers: RxFormProviders) => Effect[];
|
|
6
|
+
export declare const getAsyncValidationEffects: (formControls: BaseControl<unknown>[]) => {
|
|
7
|
+
type: string;
|
|
8
|
+
scopedEffects?: import("@reactables/core").ScopedEffects | undefined;
|
|
9
|
+
payload: BaseControl<unknown>;
|
|
10
|
+
}[];
|
|
9
11
|
export {};
|
|
@@ -2,5 +2,5 @@ import { AbstractControlConfig } from '../Models/Configs';
|
|
|
2
2
|
import { BaseForm, BaseFormState } from '../Models/Controls';
|
|
3
3
|
import { ControlRef } from '../Models/ControlRef';
|
|
4
4
|
import { RxFormProviders } from '../RxForm/RxForm';
|
|
5
|
-
export declare const buildState: <T>(config: AbstractControlConfig,
|
|
6
|
-
export declare const buildFormState: <T>(config: AbstractControlConfig,
|
|
5
|
+
export declare const buildState: <T>(config: AbstractControlConfig, controlRef: ControlRef | undefined, providers: RxFormProviders, form?: BaseForm<T> | undefined) => BaseForm<T>;
|
|
6
|
+
export declare const buildFormState: <T>(config: AbstractControlConfig, controlRef: ControlRef | undefined, providers: RxFormProviders, form?: BaseForm<T> | undefined) => BaseFormState<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { Action } from '@reactables/core';
|
|
3
3
|
import { BaseFormState } from '../Models/Controls';
|
|
4
|
-
export declare const buildHub2Source:
|
|
4
|
+
export declare const buildHub2Source: (hub1State$: Observable<BaseFormState<any>>, initialBaseState: BaseFormState<any>) => Observable<Action<any>>;
|
|
@@ -19,9 +19,9 @@ interface AsyncFields {
|
|
|
19
19
|
pending?: boolean;
|
|
20
20
|
}
|
|
21
21
|
interface ValidatedFields {
|
|
22
|
-
valid: boolean;
|
|
22
|
+
valid: boolean | null;
|
|
23
23
|
errors: FormErrors;
|
|
24
|
-
childrenValid: boolean;
|
|
24
|
+
childrenValid: boolean | null;
|
|
25
25
|
}
|
|
26
26
|
export interface Hub2Fields extends AsyncFields, ValidatedFields {
|
|
27
27
|
}
|
|
@@ -36,13 +36,14 @@ export interface BaseFormState<T> {
|
|
|
36
36
|
[key: string]: BaseControl<unknown>;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
export
|
|
40
|
-
root
|
|
39
|
+
export type BaseForm<T> = {
|
|
40
|
+
root: BaseControl<T>;
|
|
41
41
|
[key: string]: BaseControl<unknown>;
|
|
42
|
-
}
|
|
43
|
-
export
|
|
44
|
-
root
|
|
42
|
+
};
|
|
43
|
+
export type Form<T> = {
|
|
44
|
+
root: FormControl<T>;
|
|
45
|
+
} & {
|
|
45
46
|
[key: string]: FormControl<unknown>;
|
|
46
|
-
}
|
|
47
|
+
};
|
|
47
48
|
export declare const DEFAULT_HUB2_FIELDS: Hub2Fields;
|
|
48
49
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { BaseControl } from './Controls';
|
|
3
3
|
import { FormErrors } from './FormErrors';
|
|
4
|
-
export type ValidatorFn = (value:
|
|
4
|
+
export type ValidatorFn = (value: any) => FormErrors;
|
|
5
5
|
export type ValidatorAsyncFn = <T>(control$: Observable<BaseControl<T>>) => Observable<Observable<FormErrors>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { Form } from '../../Models/Controls';
|
|
3
3
|
import { ControlRef } from '../../Models';
|
|
4
|
-
export declare const asyncValidation:
|
|
4
|
+
export declare const asyncValidation: (form: Form<any> | null, { payload: controlRef }: Action<ControlRef>) => Form<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { Form } from '../../Models/Controls';
|
|
3
3
|
import { ControlAsyncValidationResponse } from '../../Models/Payloads';
|
|
4
|
-
export declare const asyncValidationResponse:
|
|
4
|
+
export declare const asyncValidationResponse: (form: Form<any> | null, { payload: { key, validatorIndex, errors } }: Action<ControlAsyncValidationResponse>) => Form<any>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Form } from '../../Models/Controls';
|
|
3
|
-
export declare const formChange:
|
|
1
|
+
import { Action } from '@reactables/core';
|
|
2
|
+
import { BaseFormState, Form } from '../../Models/Controls';
|
|
3
|
+
export declare const formChange: (state: Form<any> | null | undefined, { payload }: Action<BaseFormState<any>>) => Form<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Form, FormControl, BaseFormState } from '../../Models/Controls';
|
|
2
2
|
export declare const mergeControls: <T>(state: Form<T>, { form, _changedControls, _removedControls }: BaseFormState<unknown>) => {
|
|
3
3
|
[x: string]: FormControl<unknown>;
|
|
4
|
-
root
|
|
4
|
+
root: FormControl<unknown>;
|
|
5
5
|
};
|
|
@@ -2,5 +2,5 @@ import { Form, BaseForm, FormControl } from '../../Models/Controls';
|
|
|
2
2
|
import { ControlRef } from '../../Models/ControlRef';
|
|
3
3
|
export declare const mergeRemoveControl: <T>(state: Form<T>, form: BaseForm<T>, controlRef: ControlRef) => {
|
|
4
4
|
[x: string]: FormControl<unknown>;
|
|
5
|
-
root
|
|
5
|
+
root: FormControl<unknown>;
|
|
6
6
|
};
|
package/dist/RxForm/RxForm.d.ts
CHANGED
|
@@ -29,22 +29,17 @@ export interface FormReducers {
|
|
|
29
29
|
markControlAsUntouched: <T>(state: BaseFormState<T>, payload: ControlRef) => BaseFormState<T>;
|
|
30
30
|
resetControl: <T>(state: BaseFormState<T>, payload: ControlRef) => BaseFormState<T>;
|
|
31
31
|
}
|
|
32
|
-
export type CustomReducerFunc<
|
|
33
|
-
export type CustomReducer = CustomReducerFunc | {
|
|
34
|
-
reducer: CustomReducerFunc
|
|
35
|
-
effects?: Effect
|
|
32
|
+
export type CustomReducerFunc<FormValue = unknown> = (reducers: FormReducers, state: BaseFormState<FormValue>, action: any) => BaseFormState<unknown>;
|
|
33
|
+
export type CustomReducer<FormValue = unknown> = CustomReducerFunc<FormValue> | {
|
|
34
|
+
reducer: CustomReducerFunc<FormValue>;
|
|
35
|
+
effects?: Effect[] | ((payload?: unknown) => ScopedEffects);
|
|
36
36
|
};
|
|
37
|
-
export type
|
|
38
|
-
|
|
39
|
-
[key: string]: CustomReducer;
|
|
40
|
-
})]: CustomReducer;
|
|
41
|
-
};
|
|
42
|
-
export type ActionCreatorTypeFromCustomReducer<T> = T extends (reducers: FormReducers, state: BaseFormState<unknown>) => BaseFormState<unknown> ? () => void : T extends CustomReducerFunc<infer P> ? (payload: P) => void : T extends {
|
|
43
|
-
reducer: (reducers: FormReducers, state: BaseFormState<unknown>) => BaseFormState<unknown>;
|
|
37
|
+
export type ActionCreatorTypeFromCustomReducer<T> = T extends (formReducers: FormReducers, state: any) => unknown ? () => void : T extends (formReducers: FormReducers, state: any, action: Action<infer P>) => unknown ? (payload: P) => void : T extends {
|
|
38
|
+
reducer: (formReducers: FormReducers, state: any) => unknown;
|
|
44
39
|
} ? () => void : T extends {
|
|
45
|
-
reducer:
|
|
40
|
+
reducer: (formReducers: FormReducers, state: any, action: Action<infer P>) => unknown;
|
|
46
41
|
} ? (payload: P) => void : never;
|
|
47
|
-
export interface RxFormOptions<T extends
|
|
42
|
+
export interface RxFormOptions<T extends Record<string, CustomReducer<any>> = Record<string, CustomReducer<any>>> {
|
|
48
43
|
reducers?: T;
|
|
49
44
|
providers?: RxFormProviders;
|
|
50
45
|
name?: string;
|
|
@@ -54,7 +49,7 @@ export interface RxFormOptions<T extends CustomReducers<unknown> = CustomReducer
|
|
|
54
49
|
type NormalizerFunction<T> = (value: T) => T;
|
|
55
50
|
export interface RxFormProviders {
|
|
56
51
|
normalizers?: {
|
|
57
|
-
[key: string]: NormalizerFunction<
|
|
52
|
+
[key: string]: NormalizerFunction<any>;
|
|
58
53
|
};
|
|
59
54
|
validators?: {
|
|
60
55
|
[key: string]: ValidatorFn;
|
|
@@ -63,8 +58,8 @@ export interface RxFormProviders {
|
|
|
63
58
|
[key: string]: ValidatorAsyncFn;
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
|
-
export declare const build: <
|
|
67
|
-
updateValues: <
|
|
61
|
+
export declare const build: <FormValue, CustomReducers extends Record<string, CustomReducer<FormValue>> = Record<string, CustomReducer<FormValue>>>(config: AbstractControlConfig, options?: RxFormOptions<CustomReducers>) => Reactable<Form<FormValue>, { [K in keyof CustomReducers]: ActionCreatorTypeFromCustomReducer<CustomReducers[K]>; } & {
|
|
62
|
+
updateValues: <T>(payload: UpdateValuesPayload<T>) => void;
|
|
68
63
|
addControl: (payload: AddControlPayload) => void;
|
|
69
64
|
pushControl: (payload: PushControlPayload) => void;
|
|
70
65
|
removeControl: (payload: ControlRef) => void;
|
|
@@ -72,11 +67,11 @@ export declare const build: <T extends CustomReducers<unknown>>(config: Abstract
|
|
|
72
67
|
markControlAsTouched: (payload: MarkTouchedPayload) => void;
|
|
73
68
|
markControlAsUntouched: (payload: ControlRef) => void;
|
|
74
69
|
resetControl: (payload: ControlRef) => void;
|
|
75
|
-
} & ActionMap & DestroyAction, CustomReducerActionTypes<
|
|
70
|
+
} & ActionMap & DestroyAction, CustomReducerActionTypes<CustomReducers> & FormActionTypes & {
|
|
76
71
|
destroy: 'destroy';
|
|
77
72
|
}>;
|
|
78
|
-
export declare const load: <
|
|
79
|
-
updateValues: <
|
|
73
|
+
export declare const load: <FormValue, CustomReducers extends Record<string, CustomReducer<FormValue>> = Record<string, CustomReducer<FormValue>>>(state: Form<FormValue>, options?: RxFormOptions<CustomReducers>) => Reactable<Form<FormValue>, { [K in keyof CustomReducers]: ActionCreatorTypeFromCustomReducer<CustomReducers[K]>; } & {
|
|
74
|
+
updateValues: <T>(payload: UpdateValuesPayload<T>) => void;
|
|
80
75
|
addControl: (payload: AddControlPayload) => void;
|
|
81
76
|
pushControl: (payload: PushControlPayload) => void;
|
|
82
77
|
removeControl: (payload: ControlRef) => void;
|
|
@@ -84,10 +79,10 @@ export declare const load: <Value, T extends CustomReducers<unknown>>(state: For
|
|
|
84
79
|
markControlAsTouched: (payload: MarkTouchedPayload) => void;
|
|
85
80
|
markControlAsUntouched: (payload: ControlRef) => void;
|
|
86
81
|
resetControl: (payload: ControlRef) => void;
|
|
87
|
-
} & ActionMap & DestroyAction, CustomReducerActionTypes<
|
|
82
|
+
} & ActionMap & DestroyAction, CustomReducerActionTypes<CustomReducers> & FormActionTypes & {
|
|
88
83
|
destroy: 'destroy';
|
|
89
84
|
}>;
|
|
90
|
-
type CustomReducerActionTypes<T extends
|
|
85
|
+
type CustomReducerActionTypes<T extends Record<string, CustomReducer>> = {
|
|
91
86
|
[K in keyof T as `${K & string}`]: `${K & string}`;
|
|
92
87
|
};
|
|
93
88
|
type FormActionTypes = {
|
package/dist/RxForm/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { build, load, group, array, control, RxFormActions, CustomReducer,
|
|
1
|
+
export { build, load, group, array, control, RxFormActions, CustomReducer, FormReducers, RxFormOptions, RxFormProviders, } from './RxForm';
|
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ var DEFAULT_HUB2_FIELDS = {
|
|
|
11
11
|
pending: false,
|
|
12
12
|
valid: null,
|
|
13
13
|
childrenValid: null,
|
|
14
|
-
errors:
|
|
14
|
+
errors: {}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
var Controls = /*#__PURE__*/Object.freeze({
|
|
@@ -149,16 +149,15 @@ var getErrors = function (control, value, _a) {
|
|
|
149
149
|
var _b;
|
|
150
150
|
var validators = _a.validators;
|
|
151
151
|
return ((_b = control.config.validators) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, validator) {
|
|
152
|
-
if (!validators[validator]) {
|
|
152
|
+
if (!(validators === null || validators === void 0 ? void 0 : validators[validator])) {
|
|
153
153
|
throw "You have not provided a validator for \"".concat(validator, "\"");
|
|
154
154
|
}
|
|
155
155
|
return __assign(__assign({}, acc), validators[validator](value));
|
|
156
156
|
}, {})) || {};
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
var buildState = function (config,
|
|
159
|
+
var buildState = function (config, controlRef, providers, form) {
|
|
160
160
|
var _a;
|
|
161
|
-
if (form === void 0) { form = { root: null }; }
|
|
162
161
|
if (controlRef === void 0) { controlRef = []; }
|
|
163
162
|
var value = getValueFromControlConfig(config);
|
|
164
163
|
var control = {
|
|
@@ -177,22 +176,21 @@ var buildState = function (config, form, controlRef, providers) {
|
|
|
177
176
|
if (controls && !(controls instanceof Array)) {
|
|
178
177
|
newForm = Object.entries(config.controls).reduce(function (acc, _a) {
|
|
179
178
|
var key = _a[0], controlConfig = _a[1];
|
|
180
|
-
return buildState(controlConfig,
|
|
179
|
+
return buildState(controlConfig, controlRef.concat(key), providers, acc);
|
|
181
180
|
}, newForm);
|
|
182
181
|
}
|
|
183
182
|
else if (controls && controls instanceof Array) {
|
|
184
183
|
// Adding controls for Form Array
|
|
185
184
|
newForm = config.controls.reduce(function (acc, controlConfig, index) {
|
|
186
|
-
return buildState(controlConfig,
|
|
185
|
+
return buildState(controlConfig, controlRef.concat(index), providers, acc);
|
|
187
186
|
}, newForm);
|
|
188
187
|
}
|
|
189
188
|
return newForm;
|
|
190
189
|
};
|
|
191
|
-
var buildFormState = function (config,
|
|
192
|
-
if (form === void 0) { form = { root: null }; }
|
|
190
|
+
var buildFormState = function (config, controlRef, providers, form) {
|
|
193
191
|
if (controlRef === void 0) { controlRef = []; }
|
|
194
192
|
return {
|
|
195
|
-
form: buildState(config,
|
|
193
|
+
form: buildState(config, controlRef, providers, form)
|
|
196
194
|
};
|
|
197
195
|
};
|
|
198
196
|
|
|
@@ -203,7 +201,8 @@ var getScopedEffectsForControl = function (formControl, providers) {
|
|
|
203
201
|
if (asyncValidators && asyncValidators.length) {
|
|
204
202
|
scopedEffects = asyncValidators.reduce(function (acc, asyncValidator, validatorIndex) {
|
|
205
203
|
var effect = function (actions$) {
|
|
206
|
-
|
|
204
|
+
var _a;
|
|
205
|
+
if (!((_a = providers.asyncValidators) === null || _a === void 0 ? void 0 : _a[asyncValidator])) {
|
|
207
206
|
throw "You have not provided an asyncValidator for \"".concat(asyncValidator, "\"");
|
|
208
207
|
}
|
|
209
208
|
return actions$.pipe(operators.map(function (_a) {
|
|
@@ -305,7 +304,7 @@ var getDescendantControls = function (controlRef, form, excludeSelf) {
|
|
|
305
304
|
}
|
|
306
305
|
var control = getControl(controlRef, form);
|
|
307
306
|
var value = control.value, config = control.config;
|
|
308
|
-
var descendants;
|
|
307
|
+
var descendants = [];
|
|
309
308
|
if (Array.isArray(config.controls)) {
|
|
310
309
|
// If control is a Form Array
|
|
311
310
|
descendants = value.reduce(function (acc, item, index) {
|
|
@@ -384,9 +383,11 @@ var controlRefCheck = function (ref) {
|
|
|
384
383
|
catch (_a) { }
|
|
385
384
|
};
|
|
386
385
|
|
|
387
|
-
var checkKeys = function (
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
var checkKeys = function (oldObj, newObj) {
|
|
387
|
+
var oldKeys = Object.keys(oldObj).slice().sort().join();
|
|
388
|
+
var newKeys = Object.keys(newObj).slice().sort().join();
|
|
389
|
+
if (oldKeys !== newKeys) {
|
|
390
|
+
console.warn("You are trying to update multiple controls but the keys don't match. It is recommended your keys match. Old keys: ".concat(oldKeys, ". New Keys: ").concat(newKeys, " "));
|
|
390
391
|
}
|
|
391
392
|
};
|
|
392
393
|
var updateDescendantValues = function (form, _a, providers) {
|
|
@@ -417,10 +418,11 @@ var updateDescendantValues = function (form, _a, providers) {
|
|
|
417
418
|
// Use AddControlPayload/RemoveControl action reducers to add/remove control
|
|
418
419
|
var updateValues = function (_a, action, providers, mergeChanges) {
|
|
419
420
|
var _b, _c;
|
|
420
|
-
var
|
|
421
|
+
var _d;
|
|
422
|
+
var form = _a.form, _e = _a._changedControls, _changedControls = _e === void 0 ? {} : _e, _f = _a._removedControls, _removedControls = _f === void 0 ? {} : _f;
|
|
421
423
|
if (mergeChanges === void 0) { mergeChanges = false; }
|
|
422
424
|
var normalizers = providers.normalizers;
|
|
423
|
-
var
|
|
425
|
+
var _g = action.payload, controlRef = _g.controlRef, value = _g.value;
|
|
424
426
|
controlRefCheck(controlRef);
|
|
425
427
|
// Update its own value
|
|
426
428
|
var ctrlKey = getFormKey(controlRef);
|
|
@@ -428,8 +430,8 @@ var updateValues = function (_a, action, providers, mergeChanges) {
|
|
|
428
430
|
var oldValue = form[ctrlKey].value;
|
|
429
431
|
var config = form[ctrlKey].config;
|
|
430
432
|
if (config.normalizers) {
|
|
431
|
-
newValue = config.normalizers.reduce(function (acc, normalizer) {
|
|
432
|
-
if (!normalizers[normalizer]) {
|
|
433
|
+
newValue = (_d = config.normalizers) === null || _d === void 0 ? void 0 : _d.reduce(function (acc, normalizer) {
|
|
434
|
+
if (!(normalizers === null || normalizers === void 0 ? void 0 : normalizers[normalizer])) {
|
|
433
435
|
throw "You have not provided a normalizer for \"".concat(normalizer, "\"");
|
|
434
436
|
}
|
|
435
437
|
return normalizers[normalizer](acc);
|
|
@@ -629,7 +631,7 @@ var addControl = function (state, action, providers, mergeChanges) {
|
|
|
629
631
|
if (!getControl(controlRef.slice(0, -1), state.form)) {
|
|
630
632
|
throw 'You are attempting to add a control to a non-existent form group';
|
|
631
633
|
}
|
|
632
|
-
var newForm = buildState(config,
|
|
634
|
+
var newForm = buildState(config, controlRef, providers, state.form);
|
|
633
635
|
var newValue = getControl(controlRef, newForm).value;
|
|
634
636
|
var ancestorsUpdated = updateAncestorValuesAddControl(newForm, {
|
|
635
637
|
payload: { controlRef: controlRef, value: newValue }
|
|
@@ -660,7 +662,7 @@ var pushControl = function (state, action, providers, mergeChanges) {
|
|
|
660
662
|
else {
|
|
661
663
|
throw 'You are attempting to push to a control that is not a Form Array';
|
|
662
664
|
}
|
|
663
|
-
var newForm = buildState(config,
|
|
665
|
+
var newForm = buildState(config, newControlRef, providers, state.form);
|
|
664
666
|
var newValue = getControl(newControlRef, newForm).value;
|
|
665
667
|
var ancestorsUpdated = updateAncestorValuesAddControl(newForm, {
|
|
666
668
|
payload: { controlRef: newControlRef, value: newValue }
|
|
@@ -804,7 +806,7 @@ var resetControl = function (state, action, providers, mergeChanges) {
|
|
|
804
806
|
delete descendantsRemoved[key];
|
|
805
807
|
});
|
|
806
808
|
// Remove all descendants
|
|
807
|
-
var restoredControls = buildState(controlToReset.config,
|
|
809
|
+
var restoredControls = buildState(controlToReset.config, controlToReset.controlRef, providers, descendantsRemoved);
|
|
808
810
|
var restoredControlValue = getControl(controlRef, restoredControls).value;
|
|
809
811
|
var result = updateAncestorValues(restoredControls, {
|
|
810
812
|
payload: { controlRef: controlRef, value: restoredControlValue }
|
|
@@ -834,12 +836,14 @@ var asyncValidation = function (form, _a) {
|
|
|
834
836
|
var controlRef = _a.payload;
|
|
835
837
|
var updatedSelfAndAncestors = getAncestorControls(controlRef, form).reduce(function (acc, control) {
|
|
836
838
|
var _a;
|
|
839
|
+
var _b;
|
|
837
840
|
var isChangedControl = getFormKey(control.controlRef) === getFormKey(controlRef);
|
|
838
841
|
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) {
|
|
842
|
+
? __assign({}, (_b = control.config.asyncValidators) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, _, index) {
|
|
840
843
|
var _a;
|
|
841
844
|
return (__assign(__assign({}, acc), (_a = {}, _a[index] = true, _a)));
|
|
842
|
-
}, {}))
|
|
845
|
+
}, {}))
|
|
846
|
+
: control.asyncValidateInProgress }), _a));
|
|
843
847
|
}, {});
|
|
844
848
|
return __assign(__assign({}, form), updatedSelfAndAncestors);
|
|
845
849
|
};
|
|
@@ -1103,7 +1107,7 @@ var build = function (config, options) {
|
|
|
1103
1107
|
validators: __assign(__assign({}, Validators), (_b = options.providers) === null || _b === void 0 ? void 0 : _b.validators),
|
|
1104
1108
|
asyncValidators: __assign({}, (_c = options.providers) === null || _c === void 0 ? void 0 : _c.asyncValidators)
|
|
1105
1109
|
};
|
|
1106
|
-
var initialState = buildFormState(config, undefined,
|
|
1110
|
+
var initialState = buildFormState(config, undefined, providers);
|
|
1107
1111
|
return createReactable(initialState, options);
|
|
1108
1112
|
};
|
|
1109
1113
|
var load = function (state, options) {
|
|
@@ -1183,9 +1187,10 @@ var createReactable = function (initialBaseState, options, initialFormState) {
|
|
|
1183
1187
|
hub1Actions.destroy();
|
|
1184
1188
|
hub2Actions.destroy();
|
|
1185
1189
|
};
|
|
1190
|
+
var actions = __assign(__assign({}, hub1Actions), { destroy: destroy });
|
|
1186
1191
|
return [
|
|
1187
1192
|
state$.pipe(operators.filter(function (form) { return form !== null; })),
|
|
1188
|
-
|
|
1193
|
+
actions,
|
|
1189
1194
|
hub1Actions$,
|
|
1190
1195
|
];
|
|
1191
1196
|
};
|