@gravity-ui/dynamic-forms 4.16.0 → 4.16.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/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +8 -2
- package/build/cjs/lib/kit/components/Views/CardOneOfView.js +13 -3
- package/build/cjs/lib/kit/utils/common.js +5 -8
- package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +8 -2
- package/build/esm/lib/kit/components/Views/CardOneOfView.js +13 -3
- package/build/esm/lib/kit/utils/common.js +5 -8
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ const Layouts_1 = require("../../Layouts");
|
|
|
11
11
|
const RemoveButton_1 = require("../../RemoveButton");
|
|
12
12
|
const CardOneOf = (props) => {
|
|
13
13
|
var _a;
|
|
14
|
-
const { input, meta, spec, name } = props;
|
|
14
|
+
const { input, meta, spec, name, Layout } = props;
|
|
15
15
|
const [open, setOpen] = react_1.default.useState(true);
|
|
16
16
|
const onToggle = react_1.default.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
17
17
|
const onOpen = react_1.default.useCallback(() => setOpen(true), [setOpen]);
|
|
@@ -19,7 +19,13 @@ const CardOneOf = (props) => {
|
|
|
19
19
|
props,
|
|
20
20
|
onTogglerChange: onOpen,
|
|
21
21
|
});
|
|
22
|
-
const toggler = react_1.default.useMemo(() =>
|
|
22
|
+
const toggler = react_1.default.useMemo(() => {
|
|
23
|
+
const togglerProps = Object.assign(Object.assign({}, props), { name: '__stub-name', children: togglerInput });
|
|
24
|
+
if (Layout) {
|
|
25
|
+
return react_1.default.createElement(Layout, Object.assign({}, togglerProps));
|
|
26
|
+
}
|
|
27
|
+
return react_1.default.createElement(Layouts_1.Row, Object.assign({}, togglerProps));
|
|
28
|
+
}, [togglerInput, props, Layout]);
|
|
23
29
|
const actions = react_1.default.useMemo(() => {
|
|
24
30
|
if ((0, core_1.isArrayItem)(name)) {
|
|
25
31
|
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop, name: name });
|
|
@@ -7,7 +7,7 @@ const isObjectLike_1 = tslib_1.__importDefault(require("lodash/isObjectLike"));
|
|
|
7
7
|
const __1 = require("../");
|
|
8
8
|
const core_1 = require("../../../core");
|
|
9
9
|
const CardOneOfView = (props) => {
|
|
10
|
-
const { value = {}, spec, name } = props;
|
|
10
|
+
const { value = {}, spec, name, Layout } = props;
|
|
11
11
|
const [open, setOpen] = react_1.default.useState(true);
|
|
12
12
|
const onToggle = react_1.default.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
13
13
|
const specProperties = react_1.default.useMemo(() => ((0, isObjectLike_1.default)(spec.properties) ? spec.properties : {}), [spec.properties]);
|
|
@@ -18,8 +18,18 @@ const CardOneOfView = (props) => {
|
|
|
18
18
|
((_b = specProperties[valueKey]) === null || _b === void 0 ? void 0 : _b.viewSpec.layoutTitle) ||
|
|
19
19
|
valueKey);
|
|
20
20
|
}, [valueKey, spec.description, specProperties]);
|
|
21
|
-
const title = react_1.default.useMemo(() =>
|
|
22
|
-
|
|
21
|
+
const title = react_1.default.useMemo(() => {
|
|
22
|
+
const titleProps = {
|
|
23
|
+
spec: spec,
|
|
24
|
+
value: valueName,
|
|
25
|
+
name: name,
|
|
26
|
+
children: react_1.default.createElement(react_1.default.Fragment, null, valueName),
|
|
27
|
+
};
|
|
28
|
+
if (Layout) {
|
|
29
|
+
return react_1.default.createElement(Layout, Object.assign({}, titleProps));
|
|
30
|
+
}
|
|
31
|
+
return react_1.default.createElement(__1.ViewRow, Object.assign({}, titleProps));
|
|
32
|
+
}, [spec, name, valueName, Layout]);
|
|
23
33
|
if (!value || !Object.keys(value).length) {
|
|
24
34
|
return null;
|
|
25
35
|
}
|
|
@@ -42,7 +42,7 @@ const isNotEmptyValue = (value, spec) => {
|
|
|
42
42
|
};
|
|
43
43
|
exports.isNotEmptyValue = isNotEmptyValue;
|
|
44
44
|
const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
45
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
46
46
|
if ((0, isObjectLike_1.default)(spec)) {
|
|
47
47
|
const result = (0, cloneDeep_1.default)(spec);
|
|
48
48
|
if ((0, isString_1.default)(result.type)) {
|
|
@@ -54,7 +54,7 @@ const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
|
54
54
|
try {
|
|
55
55
|
_defaultValue = JSON.parse(result.defaultValue);
|
|
56
56
|
}
|
|
57
|
-
catch (
|
|
57
|
+
catch (_k) {
|
|
58
58
|
_defaultValue = undefined;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -75,17 +75,14 @@ const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
|
75
75
|
if ((0, isString_1.default)((_c = result.viewSpec) === null || _c === void 0 ? void 0 : _c.addButtonPosition)) {
|
|
76
76
|
result.viewSpec.addButtonPosition = result.viewSpec.addButtonPosition.toLowerCase();
|
|
77
77
|
}
|
|
78
|
-
if ((0, isString_1.default)((_d = result.viewSpec) === null || _d === void 0 ? void 0 : _d.
|
|
79
|
-
result.viewSpec.textContentParams = Object.assign(Object.assign({}, result.viewSpec.textContentParams), { themeLabel: result.viewSpec.themeLabel.toLowerCase() });
|
|
80
|
-
}
|
|
81
|
-
if ((0, isString_1.default)((_f = (_e = result.viewSpec) === null || _e === void 0 ? void 0 : _e.oneOfParams) === null || _f === void 0 ? void 0 : _f.toggler)) {
|
|
78
|
+
if ((0, isString_1.default)((_e = (_d = result.viewSpec) === null || _d === void 0 ? void 0 : _d.oneOfParams) === null || _e === void 0 ? void 0 : _e.toggler)) {
|
|
82
79
|
result.viewSpec.oneOfParams.toggler = result.viewSpec.oneOfParams.toggler.toLowerCase();
|
|
83
80
|
}
|
|
84
|
-
if ((0, isString_1.default)((
|
|
81
|
+
if ((0, isString_1.default)((_g = (_f = result.viewSpec) === null || _f === void 0 ? void 0 : _f.textContentParams) === null || _g === void 0 ? void 0 : _g.themeLabel)) {
|
|
85
82
|
result.viewSpec.textContentParams.themeLabel =
|
|
86
83
|
result.viewSpec.textContentParams.themeLabel.toLowerCase();
|
|
87
84
|
}
|
|
88
|
-
if ((0, isString_1.default)((
|
|
85
|
+
if ((0, isString_1.default)((_j = (_h = result.viewSpec) === null || _h === void 0 ? void 0 : _h.textContentParams) === null || _j === void 0 ? void 0 : _j.themeAlert)) {
|
|
89
86
|
result.viewSpec.textContentParams.themeAlert =
|
|
90
87
|
result.viewSpec.textContentParams.themeAlert.toLowerCase();
|
|
91
88
|
}
|
|
@@ -7,7 +7,7 @@ import { Row } from '../../Layouts';
|
|
|
7
7
|
import { RemoveButton } from '../../RemoveButton';
|
|
8
8
|
export const CardOneOf = (props) => {
|
|
9
9
|
var _a;
|
|
10
|
-
const { input, meta, spec, name } = props;
|
|
10
|
+
const { input, meta, spec, name, Layout } = props;
|
|
11
11
|
const [open, setOpen] = React.useState(true);
|
|
12
12
|
const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
13
13
|
const onOpen = React.useCallback(() => setOpen(true), [setOpen]);
|
|
@@ -15,7 +15,13 @@ export const CardOneOf = (props) => {
|
|
|
15
15
|
props,
|
|
16
16
|
onTogglerChange: onOpen,
|
|
17
17
|
});
|
|
18
|
-
const toggler = React.useMemo(() =>
|
|
18
|
+
const toggler = React.useMemo(() => {
|
|
19
|
+
const togglerProps = Object.assign(Object.assign({}, props), { name: '__stub-name', children: togglerInput });
|
|
20
|
+
if (Layout) {
|
|
21
|
+
return React.createElement(Layout, Object.assign({}, togglerProps));
|
|
22
|
+
}
|
|
23
|
+
return React.createElement(Row, Object.assign({}, togglerProps));
|
|
24
|
+
}, [togglerInput, props, Layout]);
|
|
19
25
|
const actions = React.useMemo(() => {
|
|
20
26
|
if (isArrayItem(name)) {
|
|
21
27
|
return React.createElement(RemoveButton, { onDrop: input.onDrop, name: name });
|
|
@@ -3,7 +3,7 @@ import isObjectLike from 'lodash/isObjectLike';
|
|
|
3
3
|
import { Card, ViewRow } from '../';
|
|
4
4
|
import { ViewController } from '../../../core';
|
|
5
5
|
export const CardOneOfView = (props) => {
|
|
6
|
-
const { value = {}, spec, name } = props;
|
|
6
|
+
const { value = {}, spec, name, Layout } = props;
|
|
7
7
|
const [open, setOpen] = React.useState(true);
|
|
8
8
|
const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
9
9
|
const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
|
|
@@ -14,8 +14,18 @@ export const CardOneOfView = (props) => {
|
|
|
14
14
|
((_b = specProperties[valueKey]) === null || _b === void 0 ? void 0 : _b.viewSpec.layoutTitle) ||
|
|
15
15
|
valueKey);
|
|
16
16
|
}, [valueKey, spec.description, specProperties]);
|
|
17
|
-
const title = React.useMemo(() =>
|
|
18
|
-
|
|
17
|
+
const title = React.useMemo(() => {
|
|
18
|
+
const titleProps = {
|
|
19
|
+
spec: spec,
|
|
20
|
+
value: valueName,
|
|
21
|
+
name: name,
|
|
22
|
+
children: React.createElement(React.Fragment, null, valueName),
|
|
23
|
+
};
|
|
24
|
+
if (Layout) {
|
|
25
|
+
return React.createElement(Layout, Object.assign({}, titleProps));
|
|
26
|
+
}
|
|
27
|
+
return React.createElement(ViewRow, Object.assign({}, titleProps));
|
|
28
|
+
}, [spec, name, valueName, Layout]);
|
|
19
29
|
if (!value || !Object.keys(value).length) {
|
|
20
30
|
return null;
|
|
21
31
|
}
|
|
@@ -37,7 +37,7 @@ export const isNotEmptyValue = (value, spec) => {
|
|
|
37
37
|
return true;
|
|
38
38
|
};
|
|
39
39
|
export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
40
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
41
41
|
if (isObjectLike(spec)) {
|
|
42
42
|
const result = cloneDeep(spec);
|
|
43
43
|
if (isString(result.type)) {
|
|
@@ -49,7 +49,7 @@ export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) =
|
|
|
49
49
|
try {
|
|
50
50
|
_defaultValue = JSON.parse(result.defaultValue);
|
|
51
51
|
}
|
|
52
|
-
catch (
|
|
52
|
+
catch (_k) {
|
|
53
53
|
_defaultValue = undefined;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -70,17 +70,14 @@ export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) =
|
|
|
70
70
|
if (isString((_c = result.viewSpec) === null || _c === void 0 ? void 0 : _c.addButtonPosition)) {
|
|
71
71
|
result.viewSpec.addButtonPosition = result.viewSpec.addButtonPosition.toLowerCase();
|
|
72
72
|
}
|
|
73
|
-
if (isString((_d = result.viewSpec) === null || _d === void 0 ? void 0 : _d.
|
|
74
|
-
result.viewSpec.textContentParams = Object.assign(Object.assign({}, result.viewSpec.textContentParams), { themeLabel: result.viewSpec.themeLabel.toLowerCase() });
|
|
75
|
-
}
|
|
76
|
-
if (isString((_f = (_e = result.viewSpec) === null || _e === void 0 ? void 0 : _e.oneOfParams) === null || _f === void 0 ? void 0 : _f.toggler)) {
|
|
73
|
+
if (isString((_e = (_d = result.viewSpec) === null || _d === void 0 ? void 0 : _d.oneOfParams) === null || _e === void 0 ? void 0 : _e.toggler)) {
|
|
77
74
|
result.viewSpec.oneOfParams.toggler = result.viewSpec.oneOfParams.toggler.toLowerCase();
|
|
78
75
|
}
|
|
79
|
-
if (isString((
|
|
76
|
+
if (isString((_g = (_f = result.viewSpec) === null || _f === void 0 ? void 0 : _f.textContentParams) === null || _g === void 0 ? void 0 : _g.themeLabel)) {
|
|
80
77
|
result.viewSpec.textContentParams.themeLabel =
|
|
81
78
|
result.viewSpec.textContentParams.themeLabel.toLowerCase();
|
|
82
79
|
}
|
|
83
|
-
if (isString((
|
|
80
|
+
if (isString((_j = (_h = result.viewSpec) === null || _h === void 0 ? void 0 : _h.textContentParams) === null || _j === void 0 ? void 0 : _j.themeAlert)) {
|
|
84
81
|
result.viewSpec.textContentParams.themeAlert =
|
|
85
82
|
result.viewSpec.textContentParams.themeAlert.toLowerCase();
|
|
86
83
|
}
|