@reactables/forms 0.7.0-alpha.1 → 0.7.0-alpha.3
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.
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { Form, FormControl, BaseFormState } from '../../Models/Controls';
|
|
2
|
-
import { FormErrors } from '../../Models/FormErrors';
|
|
3
2
|
export declare const mergeControls: <T>(state: Form<T>, { form, changedControls, removedControls }: BaseFormState<unknown>) => {
|
|
4
|
-
[x: string]: FormControl<unknown
|
|
5
|
-
errors: {
|
|
6
|
-
[x: string]: boolean;
|
|
7
|
-
};
|
|
8
|
-
valid: boolean;
|
|
9
|
-
childrenValid: boolean;
|
|
10
|
-
pristineValue: unknown;
|
|
11
|
-
controlRef: import("../..").ControlRef;
|
|
12
|
-
value: unknown;
|
|
13
|
-
dirty: boolean;
|
|
14
|
-
touched: boolean;
|
|
15
|
-
validatorErrors: FormErrors;
|
|
16
|
-
config: import("../..").AbstractControlConfig;
|
|
17
|
-
key: string;
|
|
18
|
-
asyncValidatorErrors: FormErrors;
|
|
19
|
-
asyncValidateInProgress: {
|
|
20
|
-
[key: string]: boolean;
|
|
21
|
-
[key: number]: boolean;
|
|
22
|
-
};
|
|
23
|
-
pending?: boolean;
|
|
24
|
-
};
|
|
3
|
+
[x: string]: FormControl<unknown>;
|
|
25
4
|
root?: FormControl<unknown>;
|
|
26
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?: FormControl<
|
|
5
|
+
root?: FormControl<unknown>;
|
|
6
6
|
};
|
package/dist/RxForm/RxForm.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface FormReducers {
|
|
|
28
28
|
markControlAsUntouched: <T>(state: BaseFormState<T>, payload: ControlRef) => BaseFormState<T>;
|
|
29
29
|
resetControl: <T>(state: BaseFormState<T>, payload: ControlRef) => BaseFormState<T>;
|
|
30
30
|
}
|
|
31
|
-
type CustomReducer = (reducers: FormReducers, state: BaseFormState<unknown>, action: Action<unknown>) => BaseFormState<unknown>;
|
|
31
|
+
export type CustomReducer = (reducers: FormReducers, state: BaseFormState<unknown>, action: Action<unknown>) => BaseFormState<unknown>;
|
|
32
32
|
export interface CustomReducers {
|
|
33
33
|
[key: string]: CustomReducer | {
|
|
34
34
|
reducer: CustomReducer;
|
package/dist/index.js
CHANGED
|
@@ -793,6 +793,15 @@ var asyncValidation = function (form, _a) {
|
|
|
793
793
|
return __assign(__assign({}, form), updatedSelfAndAncestors);
|
|
794
794
|
};
|
|
795
795
|
|
|
796
|
+
var reverseObjectKeys = function (form) {
|
|
797
|
+
return Object.keys(form)
|
|
798
|
+
.reverse()
|
|
799
|
+
.reduce(function (acc, key) {
|
|
800
|
+
acc[key] = form[key];
|
|
801
|
+
return acc;
|
|
802
|
+
}, {});
|
|
803
|
+
};
|
|
804
|
+
|
|
796
805
|
var hasErrors$3 = function (errors) {
|
|
797
806
|
return Object.values(errors).some(function (hasError) { return hasError; });
|
|
798
807
|
};
|
|
@@ -827,7 +836,8 @@ var mergeBranchErrors = function (form, controlRef) {
|
|
|
827
836
|
}
|
|
828
837
|
return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { errors: errors, valid: selfValid && childrenValid, childrenValid: childrenValid }), _b));
|
|
829
838
|
}, {});
|
|
830
|
-
|
|
839
|
+
var errorsMergedOrderRestored = reverseObjectKeys(errorsMerged);
|
|
840
|
+
return __assign(__assign({}, form), errorsMergedOrderRestored);
|
|
831
841
|
};
|
|
832
842
|
|
|
833
843
|
var isControlValidating = function (control) {
|
|
@@ -883,12 +893,7 @@ var mergeErrors = function (form) {
|
|
|
883
893
|
}
|
|
884
894
|
return __assign(__assign({}, acc), (_b = {}, _b[key] = __assign(__assign({}, control), { errors: errors, valid: selfValid && childrenValid, childrenValid: childrenValid }), _b));
|
|
885
895
|
}, {});
|
|
886
|
-
var restoredOrder =
|
|
887
|
-
.reverse()
|
|
888
|
-
.reduce(function (acc, key) {
|
|
889
|
-
acc[key] = errorsMerged[key];
|
|
890
|
-
return acc;
|
|
891
|
-
}, {});
|
|
896
|
+
var restoredOrder = reverseObjectKeys(errorsMerged);
|
|
892
897
|
return restoredOrder;
|
|
893
898
|
};
|
|
894
899
|
|
|
@@ -926,13 +931,14 @@ var mergeRemoveControl = function (state, form, controlRef) {
|
|
|
926
931
|
}
|
|
927
932
|
return __assign(__assign({}, acc), (_a = {}, _a[key] = __assign(__assign(__assign({}, existingControl), baseControl), { errors: errors, valid: selfValid && childrenValid, childrenValid: childrenValid }), _a));
|
|
928
933
|
}, {});
|
|
934
|
+
var updatedControlBranchOrderRestored = reverseObjectKeys(updatedControlBranch);
|
|
929
935
|
var descendants = existingBranch.filter(function (control) { return control.controlRef.length > parentRef.length; });
|
|
930
936
|
var removedControls = __assign({}, state);
|
|
931
937
|
descendants.forEach(function (control) {
|
|
932
938
|
delete removedControls[getFormKey(control.controlRef)];
|
|
933
939
|
});
|
|
934
940
|
delete removedControls[getFormKey(controlRef)];
|
|
935
|
-
return __assign(__assign({}, removedControls),
|
|
941
|
+
return __assign(__assign({}, removedControls), updatedControlBranchOrderRestored);
|
|
936
942
|
};
|
|
937
943
|
|
|
938
944
|
var hasErrors = function (errors) {
|
|
@@ -976,7 +982,8 @@ var mergeControls = function (state, _a) {
|
|
|
976
982
|
}
|
|
977
983
|
return __assign(__assign({}, acc), (_a = {}, _a[formKey] = __assign(__assign({}, newControl), { errors: errors, valid: selfValid && childrenValid, childrenValid: childrenValid }), _a));
|
|
978
984
|
}, {});
|
|
979
|
-
var
|
|
985
|
+
var orderRestored = reverseObjectKeys(updatedBranch);
|
|
986
|
+
var result = __assign(__assign({}, controlsRemoved), orderRestored);
|
|
980
987
|
return result;
|
|
981
988
|
};
|
|
982
989
|
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"author": "David Lai",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@reactables/core": "^0.7.0-alpha.
|
|
17
|
+
"@reactables/core": "^0.7.0-alpha.3",
|
|
18
18
|
"lodash.isequal": "^4.5.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"lodash.clonedeep": "^4.5.0"
|
|
25
25
|
},
|
|
26
|
-
"version": "0.7.0-alpha.
|
|
26
|
+
"version": "0.7.0-alpha.3"
|
|
27
27
|
}
|