@gravity-ui/dynamic-forms 1.11.2 → 1.12.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.
|
@@ -49,8 +49,8 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
|
|
|
49
49
|
const _value = lodash_1.default.isFunction(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
|
|
50
50
|
const error = validate === null || validate === void 0 ? void 0 : validate(_value);
|
|
51
51
|
let value = (0, utils_1.transformArrIn)(_value);
|
|
52
|
-
if ((0, helpers_1.isNumberSpec)(spec) &&
|
|
53
|
-
value = Number(value);
|
|
52
|
+
if ((0, helpers_1.isNumberSpec)(spec) && !error) {
|
|
53
|
+
value = (value ? Number(value) : undefined);
|
|
54
54
|
}
|
|
55
55
|
let newChildErrors = Object.assign({}, state.childErrors);
|
|
56
56
|
if (childErrors) {
|
|
@@ -60,7 +60,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
|
|
|
60
60
|
newChildErrors = Object.assign(Object.assign({}, lodash_1.default.omit(newChildErrors, existingСhildNames)), childErrors);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
return Object.assign(Object.assign({}, state), { dirty: !lodash_1.default.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value, visited: true, childErrors: newChildErrors });
|
|
63
|
+
return Object.assign(Object.assign({}, state), { dirty: !lodash_1.default.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value: value, visited: true, childErrors: newChildErrors });
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
const onDrop = () => {
|
|
@@ -72,7 +72,8 @@ const getNumberValidator = (params = {}) => {
|
|
|
72
72
|
}
|
|
73
73
|
if (!ignoreMinimumCheck &&
|
|
74
74
|
lodash_1.default.isNumber(spec.minimum) &&
|
|
75
|
-
|
|
75
|
+
stringValue.length &&
|
|
76
|
+
spec.minimum > Number(stringValue)) {
|
|
76
77
|
return validators_1.ErrorMessages.minNumber(spec.minimum);
|
|
77
78
|
}
|
|
78
79
|
if (lodash_1.default.isString(spec.format) && stringValue.length) {
|
|
@@ -45,8 +45,8 @@ export const useField = ({ name, spec, initialValue, value: externalValue, valid
|
|
|
45
45
|
const _value = _.isFunction(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
|
|
46
46
|
const error = validate === null || validate === void 0 ? void 0 : validate(_value);
|
|
47
47
|
let value = transformArrIn(_value);
|
|
48
|
-
if (isNumberSpec(spec) &&
|
|
49
|
-
value = Number(value);
|
|
48
|
+
if (isNumberSpec(spec) && !error) {
|
|
49
|
+
value = (value ? Number(value) : undefined);
|
|
50
50
|
}
|
|
51
51
|
let newChildErrors = Object.assign({}, state.childErrors);
|
|
52
52
|
if (childErrors) {
|
|
@@ -56,7 +56,7 @@ export const useField = ({ name, spec, initialValue, value: externalValue, valid
|
|
|
56
56
|
newChildErrors = Object.assign(Object.assign({}, _.omit(newChildErrors, existingСhildNames)), childErrors);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
return Object.assign(Object.assign({}, state), { dirty: !_.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value, visited: true, childErrors: newChildErrors });
|
|
59
|
+
return Object.assign(Object.assign({}, state), { dirty: !_.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value: value, visited: true, childErrors: newChildErrors });
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
const onDrop = () => {
|
|
@@ -66,7 +66,8 @@ export const getNumberValidator = (params = {}) => {
|
|
|
66
66
|
}
|
|
67
67
|
if (!ignoreMinimumCheck &&
|
|
68
68
|
_.isNumber(spec.minimum) &&
|
|
69
|
-
|
|
69
|
+
stringValue.length &&
|
|
70
|
+
spec.minimum > Number(stringValue)) {
|
|
70
71
|
return ErrorMessages.minNumber(spec.minimum);
|
|
71
72
|
}
|
|
72
73
|
if (_.isString(spec.format) && stringValue.length) {
|