@gravity-ui/dynamic-forms 1.8.0 → 1.8.1
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/CHANGELOG.md +7 -0
- package/build/cjs/lib/core/components/Form/hooks/useField.js +1 -1
- package/build/cjs/lib/kit/components/Views/ArrayBaseView.js +2 -1
- package/build/esm/lib/core/components/Form/hooks/useField.js +1 -1
- package/build/esm/lib/kit/components/Views/ArrayBaseView.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.8.1](https://github.com/gravity-ui/dynamic-forms/compare/v1.8.0...v1.8.1) (2023-05-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* fixed deleting numbers from arrays ([#50](https://github.com/gravity-ui/dynamic-forms/issues/50)) ([76fba69](https://github.com/gravity-ui/dynamic-forms/commit/76fba69c47e016fb806d5d2d06fa367f4672c524))
|
|
9
|
+
|
|
3
10
|
## [1.8.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.7.1...v1.8.0) (2023-05-25)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -55,7 +55,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
|
|
|
55
55
|
const _value = lodash_1.default.isFunction(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
|
|
56
56
|
const error = validate === null || validate === void 0 ? void 0 : validate(_value);
|
|
57
57
|
let value = (0, utils_1.transformArrIn)(_value);
|
|
58
|
-
if ((0, helpers_1.isNumberSpec)(spec) && value && !error) {
|
|
58
|
+
if ((0, helpers_1.isNumberSpec)(spec) && value && value !== constants_1.REMOVED_ITEM && !error) {
|
|
59
59
|
value = Number(value);
|
|
60
60
|
}
|
|
61
61
|
let newChildErrors = Object.assign({}, state.childErrors);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ArrayBaseView = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
7
|
const core_1 = require("../../../core");
|
|
7
8
|
const ArrayBaseView = ({ spec, name, value = [] }) => {
|
|
8
9
|
const itemSpecCorrect = react_1.default.useMemo(() => (0, core_1.isCorrectSpec)(spec.items), [spec.items]);
|
|
@@ -16,7 +17,7 @@ const ArrayBaseView = ({ spec, name, value = [] }) => {
|
|
|
16
17
|
: `${idx + 1}` });
|
|
17
18
|
return itemSpec;
|
|
18
19
|
}, [spec.items, itemSpecCorrect]);
|
|
19
|
-
const items = react_1.default.useMemo(() =>
|
|
20
|
+
const items = react_1.default.useMemo(() => lodash_1.default.map(value, (__, idx) => {
|
|
20
21
|
const itemSpec = getItemSpec(idx);
|
|
21
22
|
if (!itemSpec) {
|
|
22
23
|
return null;
|
|
@@ -51,7 +51,7 @@ export const useField = ({ name, spec, initialValue, value: externalValue, valid
|
|
|
51
51
|
const _value = _.isFunction(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
|
|
52
52
|
const error = validate === null || validate === void 0 ? void 0 : validate(_value);
|
|
53
53
|
let value = transformArrIn(_value);
|
|
54
|
-
if (isNumberSpec(spec) && value && !error) {
|
|
54
|
+
if (isNumberSpec(spec) && value && value !== REMOVED_ITEM && !error) {
|
|
55
55
|
value = Number(value);
|
|
56
56
|
}
|
|
57
57
|
let newChildErrors = Object.assign({}, state.childErrors);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
2
3
|
import { ViewController, isCorrectSpec } from '../../../core';
|
|
3
4
|
export const ArrayBaseView = ({ spec, name, value = [] }) => {
|
|
4
5
|
const itemSpecCorrect = React.useMemo(() => isCorrectSpec(spec.items), [spec.items]);
|
|
@@ -12,7 +13,7 @@ export const ArrayBaseView = ({ spec, name, value = [] }) => {
|
|
|
12
13
|
: `${idx + 1}` });
|
|
13
14
|
return itemSpec;
|
|
14
15
|
}, [spec.items, itemSpecCorrect]);
|
|
15
|
-
const items = React.useMemo(() =>
|
|
16
|
+
const items = React.useMemo(() => _.map(value, (__, idx) => {
|
|
16
17
|
const itemSpec = getItemSpec(idx);
|
|
17
18
|
if (!itemSpec) {
|
|
18
19
|
return null;
|