@gravity-ui/dynamic-forms 1.5.0 → 1.6.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.
- package/CHANGELOG.md +13 -0
- package/build/cjs/lib/core/components/Form/hooks/useField.js +3 -0
- package/build/cjs/lib/core/components/Form/hooks/useStore.js +6 -0
- package/build/cjs/lib/core/helpers.js +4 -1
- package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
- package/build/cjs/lib/kit/components/Card/Card.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/Checkbox/Checkbox.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.js +3 -3
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputBase.js +5 -5
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/NumberWithScale/NumberWithScale.js +3 -3
- package/build/cjs/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +18 -5
- package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.css +8 -8
- package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +3 -3
- package/build/cjs/lib/kit/components/Inputs/Secret/Secret.js +16 -6
- package/build/cjs/lib/kit/components/Inputs/Select/Select.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -3
- package/build/cjs/lib/kit/components/Inputs/Text/Text.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/TextArea/TextArea.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +18 -5
- package/build/cjs/lib/kit/components/Layouts/Accordeon/Accordeon.js +3 -3
- package/build/cjs/lib/kit/components/Layouts/Accordeon/RemoveButton.js +2 -2
- package/build/cjs/lib/kit/components/Layouts/AccordeonCardLayout/AccordeonCardLayout.js +3 -3
- package/build/cjs/lib/kit/components/Layouts/CardAccordeon.js +3 -3
- package/build/cjs/lib/kit/components/Layouts/CardSection.js +3 -3
- package/build/cjs/lib/kit/components/Layouts/Row/Row.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Row2/Row2.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/SectionCard/SectionCard.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Transparent/Transparent.js +2 -2
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +1 -1
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewCardSection.js +2 -2
- package/build/cjs/lib/kit/components/Views/CardOneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +18 -4
- package/build/cjs/lib/kit/components/Views/OneOfCardView.js +1 -1
- package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +21 -7
- package/build/cjs/lib/kit/hooks/useOneOf.js +4 -4
- package/build/esm/lib/core/components/Form/hooks/useField.js +4 -1
- package/build/esm/lib/core/components/Form/hooks/useStore.js +6 -0
- package/build/esm/lib/core/helpers.d.ts +1 -0
- package/build/esm/lib/core/helpers.js +2 -0
- package/build/esm/lib/core/types/specs.d.ts +0 -1
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.d.ts +1 -0
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
- package/build/esm/lib/kit/components/Card/Card.d.ts +1 -0
- package/build/esm/lib/kit/components/Card/Card.js +2 -2
- package/build/esm/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
- package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
- package/build/esm/lib/kit/components/Inputs/Checkbox/Checkbox.js +2 -2
- package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.js +3 -3
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputBase.js +5 -5
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.js +2 -2
- package/build/esm/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +2 -2
- package/build/esm/lib/kit/components/Inputs/NumberWithScale/NumberWithScale.js +3 -3
- package/build/esm/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -2
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +18 -5
- package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.css +8 -8
- package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
- package/build/esm/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +3 -3
- package/build/esm/lib/kit/components/Inputs/Secret/Secret.js +17 -7
- package/build/esm/lib/kit/components/Inputs/Select/Select.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -3
- package/build/esm/lib/kit/components/Inputs/Text/Text.d.ts +1 -1
- package/build/esm/lib/kit/components/Inputs/Text/Text.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +18 -5
- package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.js +3 -3
- package/build/esm/lib/kit/components/Layouts/Accordeon/RemoveButton.d.ts +1 -0
- package/build/esm/lib/kit/components/Layouts/Accordeon/RemoveButton.js +2 -2
- package/build/esm/lib/kit/components/Layouts/AccordeonCardLayout/AccordeonCardLayout.js +3 -3
- package/build/esm/lib/kit/components/Layouts/CardAccordeon.js +3 -3
- package/build/esm/lib/kit/components/Layouts/CardSection.js +3 -3
- package/build/esm/lib/kit/components/Layouts/Row/Row.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Row2/Row2.js +1 -1
- package/build/esm/lib/kit/components/Layouts/SectionCard/SectionCard.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Transparent/Transparent.js +2 -2
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +1 -1
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.d.ts +1 -0
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewCardAccordeon.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewCardSection.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewCardSection.js +2 -2
- package/build/esm/lib/kit/components/Views/CardOneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +19 -4
- package/build/esm/lib/kit/components/Views/OneOfCardView.js +1 -1
- package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +23 -8
- package/build/esm/lib/kit/hooks/useOneOf.js +4 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.5.0...v1.6.0) (2023-04-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* adapt useStore and useField with 18 react ([#31](https://github.com/gravity-ui/dynamic-forms/issues/31)) ([d64ae4a](https://github.com/gravity-ui/dynamic-forms/commit/d64ae4a1b3f9f2e8b02288c1088679b5c848f738))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fixed display for accordeon layoutDescription ([#34](https://github.com/gravity-ui/dynamic-forms/issues/34)) ([fa58210](https://github.com/gravity-ui/dynamic-forms/commit/fa58210239df31911f3865262a4d33bd653e1b01))
|
|
14
|
+
* fixed display for one of ([#33](https://github.com/gravity-ui/dynamic-forms/issues/33)) ([823c8fc](https://github.com/gravity-ui/dynamic-forms/commit/823c8fceddcb9a7e0cf021c1b122470cf58db4df))
|
|
15
|
+
|
|
3
16
|
## [1.5.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.4.1...v1.5.0) (2023-04-18)
|
|
4
17
|
|
|
5
18
|
|
|
@@ -133,6 +133,9 @@ const useField = ({ name, spec, initialValue, validate: propsValidate, tools, pa
|
|
|
133
133
|
react_1.default.useEffect(() => {
|
|
134
134
|
firstRenderRef.current = false;
|
|
135
135
|
return () => {
|
|
136
|
+
if ((0, helpers_1.isReact18OrMore)()) {
|
|
137
|
+
firstRenderRef.current = true;
|
|
138
|
+
}
|
|
136
139
|
(parentOnUnmount ? parentOnUnmount : tools.onUnmount)(name);
|
|
137
140
|
};
|
|
138
141
|
}, []);
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const react_final_form_1 = require("react-final-form");
|
|
8
|
+
const helpers_1 = require("../../../helpers");
|
|
8
9
|
const utils_1 = require("../utils");
|
|
9
10
|
const useStore = (name) => {
|
|
10
11
|
const form = (0, react_final_form_1.useForm)();
|
|
@@ -42,6 +43,11 @@ const useStore = (name) => {
|
|
|
42
43
|
}, [name]);
|
|
43
44
|
react_1.default.useEffect(() => {
|
|
44
45
|
firstRenderRef.current = false;
|
|
46
|
+
return () => {
|
|
47
|
+
if ((0, helpers_1.isReact18OrMore)()) {
|
|
48
|
+
firstRenderRef.current = true;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
45
51
|
}, []);
|
|
46
52
|
return { tools, store };
|
|
47
53
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isStringSpec = exports.isObjectSpec = exports.isNumberSpec = exports.isBooleanSpec = exports.isArraySpec = exports.isCorrectSpec = void 0;
|
|
3
|
+
exports.isReact18OrMore = exports.isStringSpec = exports.isObjectSpec = exports.isNumberSpec = exports.isBooleanSpec = exports.isArraySpec = exports.isCorrectSpec = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
7
|
const constants_1 = require("./constants");
|
|
7
8
|
const isCorrectSpec = (candidate) => lodash_1.default.isObjectLike(candidate) &&
|
|
@@ -23,3 +24,5 @@ const isObjectSpec = (candidate) => (candidate === null || candidate === void 0
|
|
|
23
24
|
exports.isObjectSpec = isObjectSpec;
|
|
24
25
|
const isStringSpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === constants_1.SpecTypes.String;
|
|
25
26
|
exports.isStringSpec = isStringSpec;
|
|
27
|
+
const isReact18OrMore = () => Number(react_1.default.version.split('.')[0]) >= 18;
|
|
28
|
+
exports.isReact18OrMore = isReact18OrMore;
|
|
@@ -8,7 +8,7 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
8
8
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const b = (0, utils_1.block)('accordeon-card');
|
|
11
|
-
const AccordeonCard = ({ className, header, description, open: propsOpen, onToggle, headerActionsTemplate, ignoreHeaderToggle, titleSize = 'm', alwaysOpen, children, }) => {
|
|
11
|
+
const AccordeonCard = ({ className, name, header, description, open: propsOpen, onToggle, headerActionsTemplate, ignoreHeaderToggle, titleSize = 'm', alwaysOpen, children, }) => {
|
|
12
12
|
const accordeonRef = react_1.default.useRef(null);
|
|
13
13
|
const bodyRef = react_1.default.useRef(null);
|
|
14
14
|
const [open, setOpen] = react_1.default.useState(alwaysOpen || propsOpen || false);
|
|
@@ -43,7 +43,7 @@ const AccordeonCard = ({ className, header, description, open: propsOpen, onTogg
|
|
|
43
43
|
description ? (react_1.default.createElement("span", { className: b('header-content-description'), dangerouslySetInnerHTML: { __html: description } })) : null),
|
|
44
44
|
!emptyBody && !alwaysOpen ? (react_1.default.createElement("div", { className: b('header-toggle-btn'), onClick: preventEvent },
|
|
45
45
|
headerActionsTemplate ? (react_1.default.createElement("div", { className: b('interal-actions') }, headerActionsTemplate)) : null,
|
|
46
|
-
react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleToggle },
|
|
46
|
+
react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleToggle, qa: `${name}-accordeon-toggler` },
|
|
47
47
|
react_1.default.createElement(uikit_1.Icon, { className: b('toggle-icon', { open }), data: icons_1.ChevronDown, size: 16 })))) : null),
|
|
48
48
|
react_1.default.createElement("div", { ref: bodyRef, className: b('body', { open: open && !emptyBody }) }, children)));
|
|
49
49
|
};
|
|
@@ -8,7 +8,7 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
8
8
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const b = (0, utils_1.block)('card');
|
|
11
|
-
const Card = ({ title: propsTitle, description, actions, open: propsOpen, onToggle, alwaysOpen, disableHeaderToggle, checkEmptyBody, children, }) => {
|
|
11
|
+
const Card = ({ name, title: propsTitle, description, actions, open: propsOpen, onToggle, alwaysOpen, disableHeaderToggle, checkEmptyBody, children, }) => {
|
|
12
12
|
const containerRef = react_1.default.useRef(null);
|
|
13
13
|
const bodyRef = react_1.default.useRef(null);
|
|
14
14
|
const [open, setOpen] = react_1.default.useState(alwaysOpen || propsOpen || false);
|
|
@@ -58,7 +58,7 @@ const Card = ({ title: propsTitle, description, actions, open: propsOpen, onTogg
|
|
|
58
58
|
react_1.default.createElement("div", { className: b('header-right'), onClick: preventEvent },
|
|
59
59
|
actions ? react_1.default.createElement("div", { className: b('actions') }, actions) : null,
|
|
60
60
|
alwaysOpen ? null : (react_1.default.createElement("div", { className: b('toggler') },
|
|
61
|
-
react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleToggle },
|
|
61
|
+
react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleToggle, qa: `${name}-accordeon-toggler` },
|
|
62
62
|
react_1.default.createElement(uikit_1.Icon, { className: b('toggler-icon', { open }), data: icons_1.ChevronDown, size: 16 })))))),
|
|
63
63
|
react_1.default.createElement("div", { ref: bodyRef, className: b('body', { open }) }, children)));
|
|
64
64
|
};
|
|
@@ -53,9 +53,9 @@ const ArrayBase = ({ spec, name, arrayInput, input }) => {
|
|
|
53
53
|
}
|
|
54
54
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
55
|
items,
|
|
56
|
-
!arrayInput.value && spec.defaultValue ? (react_1.default.createElement(uikit_1.Button, { onClick: () => input.onChange((0, core_1.transformArrIn)(spec.defaultValue)), disabled: spec.viewSpec.disabled },
|
|
56
|
+
!arrayInput.value && spec.defaultValue ? (react_1.default.createElement(uikit_1.Button, { onClick: () => input.onChange((0, core_1.transformArrIn)(spec.defaultValue)), disabled: spec.viewSpec.disabled, qa: `${name}-init-arr` },
|
|
57
57
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Plus, size: 14 }),
|
|
58
|
-
spec.viewSpec.layoutTitle || null)) : (react_1.default.createElement(uikit_1.Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled },
|
|
58
|
+
spec.viewSpec.layoutTitle || null)) : (react_1.default.createElement(uikit_1.Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled, qa: `${name}-add-item` },
|
|
59
59
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Plus, size: 14 }),
|
|
60
60
|
spec.viewSpec.itemLabel || null))));
|
|
61
61
|
};
|
|
@@ -22,7 +22,7 @@ const CardOneOf = (props) => {
|
|
|
22
22
|
const toggler = react_1.default.useMemo(() => (react_1.default.createElement(Layouts_1.Row, Object.assign({}, props, { name: "__stub-name" }), togglerInput)), [togglerInput, props]);
|
|
23
23
|
const actions = react_1.default.useMemo(() => {
|
|
24
24
|
if ((0, core_1.isArrayItem)(name)) {
|
|
25
|
-
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop });
|
|
25
|
+
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop, name: name });
|
|
26
26
|
}
|
|
27
27
|
return;
|
|
28
28
|
}, [name, input.onDrop]);
|
|
@@ -32,6 +32,6 @@ const CardOneOf = (props) => {
|
|
|
32
32
|
}, [input.onChange, input.name]);
|
|
33
33
|
const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
34
34
|
(0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
|
|
35
|
-
return (react_1.default.createElement(__1.Card, { title: toggler, description: spec.viewSpec.layoutDescription, actions: actions, open: open, onToggle: onToggle, disableHeaderToggle: true }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
|
|
35
|
+
return (react_1.default.createElement(__1.Card, { name: name, title: toggler, description: spec.viewSpec.layoutDescription, actions: actions, open: open, onToggle: onToggle, disableHeaderToggle: true }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
|
|
36
36
|
};
|
|
37
37
|
exports.CardOneOf = CardOneOf;
|
|
@@ -6,10 +6,10 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
8
|
const b = (0, utils_1.block)('checkbox');
|
|
9
|
-
const Checkbox = ({ input, spec }) => {
|
|
9
|
+
const Checkbox = ({ name, input, spec }) => {
|
|
10
10
|
const { value, onBlur, onChange, onFocus } = input;
|
|
11
11
|
const handleChange = react_1.default.useCallback((e) => onChange(e.target.checked), [onChange]);
|
|
12
12
|
return (react_1.default.createElement("div", { className: b() },
|
|
13
|
-
react_1.default.createElement(uikit_1.Checkbox, { checked: value, onChange: handleChange, onBlur: onBlur, onFocus: onFocus, disabled: spec.viewSpec.disabled })));
|
|
13
|
+
react_1.default.createElement(uikit_1.Checkbox, { checked: value, onChange: handleChange, onBlur: onBlur, onFocus: onFocus, disabled: spec.viewSpec.disabled, qa: name })));
|
|
14
14
|
};
|
|
15
15
|
exports.Checkbox = Checkbox;
|
|
@@ -9,7 +9,7 @@ const i18n_1 = tslib_1.__importDefault(require("../../../../kit/i18n"));
|
|
|
9
9
|
const utils_1 = require("../../../utils");
|
|
10
10
|
const utils_2 = require("./utils");
|
|
11
11
|
const b = (0, utils_1.block)('file-input');
|
|
12
|
-
const FileInput = ({ input, spec }) => {
|
|
12
|
+
const FileInput = ({ name, input, spec }) => {
|
|
13
13
|
var _a, _b;
|
|
14
14
|
const { value, onChange } = input;
|
|
15
15
|
const inputRef = react_1.default.useRef(null);
|
|
@@ -41,10 +41,10 @@ const FileInput = ({ input, spec }) => {
|
|
|
41
41
|
return null;
|
|
42
42
|
}, [fileName, value]);
|
|
43
43
|
return (react_1.default.createElement("div", { className: b() },
|
|
44
|
-
react_1.default.createElement(uikit_1.Button, { disabled: spec.viewSpec.disabled, onClick: handleClick }, (0, i18n_1.default)('button-upload_file')),
|
|
44
|
+
react_1.default.createElement(uikit_1.Button, { disabled: spec.viewSpec.disabled, onClick: handleClick, qa: `${name}-file-upload` }, (0, i18n_1.default)('button-upload_file')),
|
|
45
45
|
react_1.default.createElement("input", { type: "file", ref: inputRef, autoComplete: "off", disabled: spec.viewSpec.disabled, onChange: handleInputChange, className: b('input'), tabIndex: -1, accept: (_b = spec.viewSpec.fileInput) === null || _b === void 0 ? void 0 : _b.accept }),
|
|
46
46
|
react_1.default.createElement("span", { className: b('file-name') }, fileNameContent),
|
|
47
|
-
value ? (react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleReset, disabled: spec.viewSpec.disabled },
|
|
47
|
+
value ? (react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleReset, disabled: spec.viewSpec.disabled, qa: `${name}-file-remove` },
|
|
48
48
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 16 }))) : null));
|
|
49
49
|
};
|
|
50
50
|
exports.FileInput = FileInput;
|
|
@@ -11,7 +11,7 @@ const MonacoHeader_1 = require("./MonacoHeader");
|
|
|
11
11
|
const MonacoInputDialog_1 = require("./MonacoInputDialog");
|
|
12
12
|
const useMonacoOptions_1 = require("./useMonacoOptions");
|
|
13
13
|
const b = (0, utils_1.block)('monaco-input');
|
|
14
|
-
const MonacoInputBase = ({ input, spec, card, MonacoComponent, withoutDialog, }) => {
|
|
14
|
+
const MonacoInputBase = ({ name, input, spec, card, MonacoComponent, withoutDialog, }) => {
|
|
15
15
|
const { value, onChange } = input;
|
|
16
16
|
const MonacoEditor = (0, hooks_1.useMonaco)() || MonacoComponent;
|
|
17
17
|
const { monacoParams, disabled, layoutTitle } = spec.viewSpec;
|
|
@@ -21,21 +21,21 @@ const MonacoInputBase = ({ input, spec, card, MonacoComponent, withoutDialog, })
|
|
|
21
21
|
const handleMonacoEditorDialogClose = react_1.default.useCallback(() => setMonacoEditorDialog(false), []);
|
|
22
22
|
const dialogButton = react_1.default.useMemo(() => {
|
|
23
23
|
if (!withoutDialog) {
|
|
24
|
-
return (react_1.default.createElement(uikit_1.Button, { onClick: () => setMonacoEditorDialog(true) },
|
|
24
|
+
return (react_1.default.createElement(uikit_1.Button, { onClick: () => setMonacoEditorDialog(true), qa: `${name}-open-dialog` },
|
|
25
25
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ChevronsExpandUpRight, size: 16 })));
|
|
26
26
|
}
|
|
27
27
|
return;
|
|
28
|
-
}, [withoutDialog, setMonacoEditorDialog]);
|
|
28
|
+
}, [withoutDialog, setMonacoEditorDialog, name]);
|
|
29
29
|
react_1.default.useEffect(() => onChange(monacoValue), [monacoValue]);
|
|
30
30
|
const options = (0, useMonacoOptions_1.useMonacoOptions)(fontSize, disabled !== null && disabled !== void 0 ? disabled : false);
|
|
31
31
|
if (!MonacoEditor) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
return (react_1.default.createElement("div", { className: b({ card }) },
|
|
35
|
-
react_1.default.createElement("div", { className: b('container') },
|
|
35
|
+
react_1.default.createElement("div", { className: b('container'), "data-qa": name },
|
|
36
36
|
react_1.default.createElement(MonacoHeader_1.MonacoHeader, { language: language, card: card, editButton: dialogButton }),
|
|
37
37
|
react_1.default.createElement(MonacoEditor, { language: language, value: monacoValue, height: "300", onChange: setMonacoValue, options: options })),
|
|
38
|
-
react_1.default.createElement(MonacoInputDialog_1.MonacoInputDialog, { title: layoutTitle, fontSize: fontSize, value: monacoValue, visible: monacoEditorDialog, language: language, card: card, changeMonacoValue: setMonacoValue, onChange: onChange, onClose: handleMonacoEditorDialogClose, MonacoComponent: MonacoComponent })));
|
|
38
|
+
react_1.default.createElement(MonacoInputDialog_1.MonacoInputDialog, { name: name, title: layoutTitle, fontSize: fontSize, value: monacoValue, visible: monacoEditorDialog, language: language, card: card, changeMonacoValue: setMonacoValue, onChange: onChange, onClose: handleMonacoEditorDialogClose, MonacoComponent: MonacoComponent })));
|
|
39
39
|
};
|
|
40
40
|
exports.MonacoInputBase = MonacoInputBase;
|
|
41
41
|
const MonacoInput = (props) => (react_1.default.createElement(exports.MonacoInputBase, Object.assign({}, props)));
|
|
@@ -10,7 +10,7 @@ const utils_1 = require("../../../utils");
|
|
|
10
10
|
const MonacoHeader_1 = require("./MonacoHeader");
|
|
11
11
|
const useMonacoOptions_1 = require("./useMonacoOptions");
|
|
12
12
|
const b = (0, utils_1.block)('monaco-input-dialog');
|
|
13
|
-
const MonacoInputDialog = ({ value, title, visible, language, card, onChange, onClose, changeMonacoValue, fontSize, MonacoComponent, }) => {
|
|
13
|
+
const MonacoInputDialog = ({ name, value, title, visible, language, card, onChange, onClose, changeMonacoValue, fontSize, MonacoComponent, }) => {
|
|
14
14
|
const MonacoEditor = (0, hooks_1.useMonaco)() || MonacoComponent;
|
|
15
15
|
const handleClose = react_1.default.useCallback(() => {
|
|
16
16
|
onChange(value);
|
|
@@ -23,7 +23,7 @@ const MonacoInputDialog = ({ value, title, visible, language, card, onChange, on
|
|
|
23
23
|
return (react_1.default.createElement(uikit_1.Dialog, { open: visible, onClose: handleClose, className: b() },
|
|
24
24
|
react_1.default.createElement(uikit_1.Dialog.Header, { caption: title, className: b('dialog-header') }),
|
|
25
25
|
react_1.default.createElement(uikit_1.Dialog.Body, null,
|
|
26
|
-
react_1.default.createElement("div", { className: b('container') },
|
|
26
|
+
react_1.default.createElement("div", { className: b('container'), "data-qa": `${name}-dialog` },
|
|
27
27
|
react_1.default.createElement(MonacoHeader_1.MonacoHeader, { language: language, card: card }),
|
|
28
28
|
react_1.default.createElement(MonacoEditor, { language: language, height: "600", width: "900", value: value, onChange: changeMonacoValue, options: options }))),
|
|
29
29
|
react_1.default.createElement(uikit_1.Dialog.Footer, { textButtonApply: (0, i18n_1.default)('button_cancel'), onClickButtonApply: handleClose })));
|
|
@@ -7,7 +7,7 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
7
7
|
const core_1 = require("../../../../core");
|
|
8
8
|
const utils_1 = require("../../../utils");
|
|
9
9
|
const b = (0, utils_1.block)('multi-select');
|
|
10
|
-
const MultiSelect = ({ input, spec }) => {
|
|
10
|
+
const MultiSelect = ({ name, input, spec }) => {
|
|
11
11
|
var _a;
|
|
12
12
|
const { value, onBlur, onChange, onFocus } = input;
|
|
13
13
|
const filterable = react_1.default.useMemo(() => { var _a; return (((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length) || 0) > 9; }, [(_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length]);
|
|
@@ -33,6 +33,6 @@ const MultiSelect = ({ input, spec }) => {
|
|
|
33
33
|
}, [onFocus, onBlur]);
|
|
34
34
|
const _value = react_1.default.useMemo(() => (0, core_1.transformArrOut)(value), [value]);
|
|
35
35
|
const handleChange = react_1.default.useCallback((value) => onChange((0, core_1.transformArrIn)(value)), [onChange]);
|
|
36
|
-
return (react_1.default.createElement(uikit_1.Select, { width: "max", className: b(), value: _value, options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterable: filterable, multiple: true }));
|
|
36
|
+
return (react_1.default.createElement(uikit_1.Select, { width: "max", className: b(), value: _value, options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterable: filterable, multiple: true, qa: name }));
|
|
37
37
|
};
|
|
38
38
|
exports.MultiSelect = MultiSelect;
|
|
@@ -7,7 +7,7 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
8
|
const useInitial_1 = require("./useInitial");
|
|
9
9
|
const b = (0, utils_1.block)('number-with-scale');
|
|
10
|
-
const NumberWithScaleBase = ({ input, spec }) => {
|
|
10
|
+
const NumberWithScaleBase = ({ name, input, spec }) => {
|
|
11
11
|
const { value = '', onBlur, onFocus, onChange } = input;
|
|
12
12
|
const { sizeParams, disabled, placeholder } = spec.viewSpec;
|
|
13
13
|
const { defaultType, scale } = sizeParams;
|
|
@@ -64,8 +64,8 @@ const NumberWithScaleBase = ({ input, spec }) => {
|
|
|
64
64
|
}
|
|
65
65
|
}, [setPreparedValue, setScaleValue, incorrectStringNumber, value, scale, defaultType]);
|
|
66
66
|
return (react_1.default.createElement("div", { className: b('wrapper') },
|
|
67
|
-
react_1.default.createElement(uikit_1.TextInput, { value: preparedValue, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, placeholder: placeholder, disabled: disabled }),
|
|
68
|
-
react_1.default.createElement(uikit_1.Select, { width: "max", className: b('select', 'df-error-wrapper-ignore'), value: [scaleValue], options: scaleOptions, onUpdate: handleScaleChange, disabled: disabled || incorrectStringNumber })));
|
|
67
|
+
react_1.default.createElement(uikit_1.TextInput, { value: preparedValue, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, placeholder: placeholder, disabled: disabled, qa: name }),
|
|
68
|
+
react_1.default.createElement(uikit_1.Select, { width: "max", className: b('select', 'df-error-wrapper-ignore'), value: [scaleValue], options: scaleOptions, onUpdate: handleScaleChange, disabled: disabled || incorrectStringNumber, qa: `${name}-scale` })));
|
|
69
69
|
};
|
|
70
70
|
const NumberWithScale = (props) => (0, utils_1.isCorrectSizeParams)(props.spec) ? react_1.default.createElement(NumberWithScaleBase, Object.assign({}, props)) : null;
|
|
71
71
|
exports.NumberWithScale = NumberWithScale;
|
|
@@ -11,7 +11,7 @@ const ObjectBase = (_a) => {
|
|
|
11
11
|
var { spec, name, Layout } = _a, restProps = tslib_1.__rest(_a, ["spec", "name", "Layout"]);
|
|
12
12
|
const addBtn = react_1.default.useMemo(() => {
|
|
13
13
|
var _a;
|
|
14
|
-
return (react_1.default.createElement(uikit_1.Button, { onClick: () => restProps.input.onChange((0, core_1.transformArrIn)(spec.defaultValue) || {}), disabled: (_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.disabled },
|
|
14
|
+
return (react_1.default.createElement(uikit_1.Button, { onClick: () => restProps.input.onChange((0, core_1.transformArrIn)(spec.defaultValue) || {}), disabled: (_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.disabled, qa: `${name}-init-obj` },
|
|
15
15
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Plus, size: 14 }),
|
|
16
16
|
spec.viewSpec.layoutTitle || null));
|
|
17
17
|
}, [spec.defaultValue, spec.viewSpec.layoutTitle, restProps.input.onChange]);
|
|
@@ -21,7 +21,7 @@ const ObjectBase = (_a) => {
|
|
|
21
21
|
if (!lodash_1.default.isObjectLike(spec.properties) || !Object.keys(spec.properties || {}).length) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
if (!restProps.input.value
|
|
24
|
+
if (!restProps.input.value) {
|
|
25
25
|
return addBtn;
|
|
26
26
|
}
|
|
27
27
|
const specProperties = Object.assign({}, spec.properties);
|
|
@@ -6,14 +6,27 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const core_1 = require("../../../../core");
|
|
8
8
|
const OBJECT_VALUE_PROPERTY_NAME = 'value';
|
|
9
|
-
const ObjectValueInput = (
|
|
9
|
+
const ObjectValueInput = (props) => {
|
|
10
10
|
var _a;
|
|
11
|
-
const
|
|
11
|
+
const { spec, input, name, Layout } = props;
|
|
12
|
+
const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
|
|
12
13
|
const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const childSpec = react_1.default.useMemo(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME]) {
|
|
17
|
+
const childSpec = lodash_1.default.cloneDeep(spec.properties[OBJECT_VALUE_PROPERTY_NAME]);
|
|
18
|
+
childSpec.viewSpec.layout = '';
|
|
19
|
+
return childSpec;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}, [spec.properties]);
|
|
23
|
+
if (!childSpec) {
|
|
15
24
|
return null;
|
|
16
25
|
}
|
|
17
|
-
|
|
26
|
+
const content = (react_1.default.createElement(core_1.Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME], spec: childSpec, name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, key: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
|
|
27
|
+
if (Layout) {
|
|
28
|
+
return react_1.default.createElement(Layout, Object.assign({}, props), content);
|
|
29
|
+
}
|
|
30
|
+
return react_1.default.createElement(react_1.default.Fragment, null, content);
|
|
18
31
|
};
|
|
19
32
|
exports.ObjectValueInput = ObjectValueInput;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
.df-oneof {
|
|
2
2
|
display: flex;
|
|
3
|
-
flex-direction: column
|
|
3
|
+
flex-direction: column;
|
|
4
4
|
}
|
|
5
5
|
.df-oneof:last-child > .df-group-indent {
|
|
6
6
|
margin-bottom: 0;
|
|
7
7
|
}
|
|
8
|
-
.df-oneof:last-child > .df-group-indent:empty + .df-oneof__toggler {
|
|
9
|
-
margin-bottom: 0;
|
|
10
|
-
}
|
|
11
|
-
.df-oneof__toggler {
|
|
12
|
-
margin-bottom: 15px;
|
|
13
|
-
}
|
|
14
8
|
.df-oneof .df-group-indent {
|
|
15
9
|
all: unset;
|
|
16
10
|
}
|
|
17
11
|
.df-oneof .df-group-indent > .df-use-search {
|
|
18
12
|
padding-top: 11px;
|
|
19
13
|
padding-left: 20px;
|
|
20
|
-
margin-top:
|
|
14
|
+
margin-top: 4px;
|
|
21
15
|
margin-bottom: 20px;
|
|
22
16
|
margin-left: 5px;
|
|
23
17
|
border-left: 1px solid var(--yc-color-line-generic-accent);
|
|
24
18
|
}
|
|
25
19
|
.df-oneof .df-group-indent > .df-use-search:empty {
|
|
26
20
|
display: none;
|
|
21
|
+
}
|
|
22
|
+
.df-oneof .df-group-indent > .df-use-search:last-child {
|
|
23
|
+
margin-bottom: 0;
|
|
24
|
+
}
|
|
25
|
+
.df-oneof .df-group-indent > .df-use-search > .df-simple-vertical-accordeon_view {
|
|
26
|
+
margin-top: -10px;
|
|
27
27
|
}
|
|
@@ -18,8 +18,8 @@ const OneOf = (props) => {
|
|
|
18
18
|
}, [props.input.onChange, props.input.name]);
|
|
19
19
|
const parentOnUnmount = react_1.default.useCallback((childName) => props.input.onChange((currentValue) => currentValue, { [childName]: false }), [props.input.onChange]);
|
|
20
20
|
return (react_1.default.createElement("div", { className: b() },
|
|
21
|
+
react_1.default.createElement("div", null, toggler),
|
|
21
22
|
specProperties[oneOfValue] ? (react_1.default.createElement(__1.GroupIndent, null,
|
|
22
|
-
react_1.default.createElement(core_1.Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${props.name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${props.name}.${oneOfValue}` }))) : null
|
|
23
|
-
react_1.default.createElement("div", { className: b('toggler') }, toggler)));
|
|
23
|
+
react_1.default.createElement(core_1.Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${props.name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${props.name}.${oneOfValue}` }))) : null));
|
|
24
24
|
};
|
|
25
25
|
exports.OneOf = OneOf;
|
|
@@ -29,16 +29,16 @@ const OneOfCard = (props) => {
|
|
|
29
29
|
}, [togglerInput, props, arrayItem]);
|
|
30
30
|
const headerActionsTemplate = react_1.default.useMemo(() => {
|
|
31
31
|
if (arrayItem) {
|
|
32
|
-
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop });
|
|
32
|
+
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop, name: name });
|
|
33
33
|
}
|
|
34
34
|
return null;
|
|
35
|
-
}, [arrayItem, input.onDrop]);
|
|
35
|
+
}, [arrayItem, input.onDrop, name]);
|
|
36
36
|
const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => {
|
|
37
37
|
const value = lodash_1.default.set({}, childName.split(`${input.name}.`).join(''), childValue);
|
|
38
38
|
input.onChange(value, childErrors);
|
|
39
39
|
}, [input.onChange, input.name]);
|
|
40
40
|
const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
41
41
|
(0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
|
|
42
|
-
return (react_1.default.createElement(__1.AccordeonCard, { className: b(), header: toggler, description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, ignoreHeaderToggle: true, headerActionsTemplate: headerActionsTemplate }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
|
|
42
|
+
return (react_1.default.createElement(__1.AccordeonCard, { className: b(), name: name, header: toggler, description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, ignoreHeaderToggle: true, headerActionsTemplate: headerActionsTemplate }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
|
|
43
43
|
};
|
|
44
44
|
exports.OneOfCard = OneOfCard;
|
|
@@ -6,17 +6,27 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const core_1 = require("../../../../core");
|
|
8
8
|
const SECRET_PROPERTY_NAME = 'raw';
|
|
9
|
-
const Secret = (
|
|
9
|
+
const Secret = (props) => {
|
|
10
10
|
var _a;
|
|
11
|
+
const { spec, name, input, Layout } = props;
|
|
12
|
+
const childSpec = react_1.default.useMemo(() => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[SECRET_PROPERTY_NAME]) {
|
|
15
|
+
const childSpec = lodash_1.default.cloneDeep((_b = spec.properties) === null || _b === void 0 ? void 0 : _b[SECRET_PROPERTY_NAME]);
|
|
16
|
+
childSpec.viewSpec.layout = '';
|
|
17
|
+
return childSpec;
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}, [spec.properties]);
|
|
11
21
|
const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${input.name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
|
|
12
22
|
const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
13
|
-
if (!
|
|
23
|
+
if (!childSpec) {
|
|
14
24
|
return null;
|
|
15
25
|
}
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
26
|
+
const content = (react_1.default.createElement(core_1.Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[SECRET_PROPERTY_NAME], spec: childSpec, name: `${name}.${SECRET_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${SECRET_PROPERTY_NAME}` }));
|
|
27
|
+
if (Layout) {
|
|
28
|
+
return react_1.default.createElement(Layout, Object.assign({}, props), content);
|
|
19
29
|
}
|
|
20
|
-
return
|
|
30
|
+
return react_1.default.createElement(react_1.default.Fragment, null, content);
|
|
21
31
|
};
|
|
22
32
|
exports.Secret = Secret;
|
|
@@ -6,7 +6,7 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
8
|
const b = (0, utils_1.block)('select');
|
|
9
|
-
const Select = ({ input, spec }) => {
|
|
9
|
+
const Select = ({ name, input, spec }) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const { value, onBlur, onChange, onFocus } = input;
|
|
12
12
|
const filterable = react_1.default.useMemo(() => { var _a; return (((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length) || 0) > 9; }, [(_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length]);
|
|
@@ -31,6 +31,6 @@ const Select = ({ input, spec }) => {
|
|
|
31
31
|
onBlur();
|
|
32
32
|
}
|
|
33
33
|
}, [onFocus, onBlur]);
|
|
34
|
-
return (react_1.default.createElement(uikit_1.Select, { className: b(), width: "max", value: [value], options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterable: filterable }));
|
|
34
|
+
return (react_1.default.createElement(uikit_1.Select, { className: b(), width: "max", value: [value], options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterable: filterable, qa: name }));
|
|
35
35
|
};
|
|
36
36
|
exports.Select = Select;
|
|
@@ -44,7 +44,7 @@ const TableArrayInput = ({ spec, name, arrayInput, input }) => {
|
|
|
44
44
|
id: 'remove',
|
|
45
45
|
name: '',
|
|
46
46
|
sticky: 'right',
|
|
47
|
-
template: ({ key }) => (react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: () => onItemRemove(key), key: `remove-${key}` },
|
|
47
|
+
template: ({ key }) => (react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: () => onItemRemove(key), key: `remove-${key}`, qa: `${name}-item-remove-${key}` },
|
|
48
48
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 16 }))),
|
|
49
49
|
};
|
|
50
50
|
const columns = table.map(({ property, label }) => ({
|
|
@@ -77,9 +77,9 @@ const TableArrayInput = ({ spec, name, arrayInput, input }) => {
|
|
|
77
77
|
}
|
|
78
78
|
return (react_1.default.createElement("div", { className: b() },
|
|
79
79
|
keys.length ? (react_1.default.createElement(uikit_1.Table, { className: b('table'), data: keys, columns: columns, getRowId: (_, idx) => `${name}-${idx}`, verticalAlign: "top", getRowClassNames: getRowClassNames })) : null,
|
|
80
|
-
!arrayInput.value && spec.defaultValue ? (react_1.default.createElement(uikit_1.Button, { onClick: () => input.onChange((0, core_1.transformArrIn)(spec.defaultValue)), disabled: spec.viewSpec.disabled },
|
|
80
|
+
!arrayInput.value && spec.defaultValue ? (react_1.default.createElement(uikit_1.Button, { onClick: () => input.onChange((0, core_1.transformArrIn)(spec.defaultValue)), disabled: spec.viewSpec.disabled, qa: `${name}-init-arr` },
|
|
81
81
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Plus, size: 14 }),
|
|
82
|
-
spec.viewSpec.layoutTitle || null)) : (react_1.default.createElement(uikit_1.Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled },
|
|
82
|
+
spec.viewSpec.layoutTitle || null)) : (react_1.default.createElement(uikit_1.Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled, qa: `${name}-add-item` },
|
|
83
83
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Plus, size: 14 }),
|
|
84
84
|
spec.viewSpec.itemLabel || null))));
|
|
85
85
|
};
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
7
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
8
|
-
const Text = ({ input, spec }) => {
|
|
8
|
+
const Text = ({ name, input, spec }) => {
|
|
9
9
|
const { value, onBlur, onChange, onFocus } = input;
|
|
10
10
|
const handleChange = react_1.default.useCallback((value) => {
|
|
11
11
|
onChange(value);
|
|
@@ -16,6 +16,6 @@ const Text = ({ input, spec }) => {
|
|
|
16
16
|
}
|
|
17
17
|
return 'text';
|
|
18
18
|
}, [spec.viewSpec.type]);
|
|
19
|
-
return (react_1.default.createElement(uikit_1.TextInput, { type: type, value: lodash_1.default.isNil(value) ? '' : `${value}`, hasClear: true, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, autoComplete: type === 'password' ? 'new-password' : undefined }));
|
|
19
|
+
return (react_1.default.createElement(uikit_1.TextInput, { type: type, value: lodash_1.default.isNil(value) ? '' : `${value}`, hasClear: true, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, autoComplete: type === 'password' ? 'new-password' : undefined, qa: name }));
|
|
20
20
|
};
|
|
21
21
|
exports.Text = Text;
|
|
@@ -4,8 +4,8 @@ exports.TextArea = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
-
const TextArea = ({ input, spec }) => {
|
|
7
|
+
const TextArea = ({ name, input, spec }) => {
|
|
8
8
|
const { value, onBlur, onChange, onFocus } = input;
|
|
9
|
-
return (react_1.default.createElement(uikit_1.TextInput, { value: value, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, multiline: true, placeholder: spec.viewSpec.placeholder }));
|
|
9
|
+
return (react_1.default.createElement(uikit_1.TextInput, { value: value, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, multiline: true, placeholder: spec.viewSpec.placeholder, qa: name }));
|
|
10
10
|
};
|
|
11
11
|
exports.TextArea = TextArea;
|
|
@@ -6,15 +6,28 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const core_1 = require("../../../../core");
|
|
8
8
|
const TEXT_LINK_PROPERTY_NAME = 'text';
|
|
9
|
-
const TextLink = (
|
|
9
|
+
const TextLink = (props) => {
|
|
10
10
|
var _a;
|
|
11
|
+
const { spec, input, name, Layout } = props;
|
|
11
12
|
const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
|
|
12
13
|
const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const childSpec = react_1.default.useMemo(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME]) &&
|
|
17
|
+
(0, core_1.isStringSpec)(spec.properties[TEXT_LINK_PROPERTY_NAME])) {
|
|
18
|
+
const childSpec = lodash_1.default.cloneDeep(spec.properties[TEXT_LINK_PROPERTY_NAME]);
|
|
19
|
+
childSpec.viewSpec.layout = '';
|
|
20
|
+
return childSpec;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}, [spec.properties]);
|
|
24
|
+
if (!childSpec) {
|
|
16
25
|
return null;
|
|
17
26
|
}
|
|
18
|
-
|
|
27
|
+
const content = (react_1.default.createElement(core_1.Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME], spec: childSpec, name: `${name}.${TEXT_LINK_PROPERTY_NAME}`, key: `${name}.${TEXT_LINK_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
|
|
28
|
+
if (Layout) {
|
|
29
|
+
return react_1.default.createElement(Layout, Object.assign({}, props), content);
|
|
30
|
+
}
|
|
31
|
+
return react_1.default.createElement(react_1.default.Fragment, null, content);
|
|
19
32
|
};
|
|
20
33
|
exports.TextLink = TextLink;
|
|
@@ -18,10 +18,10 @@ const Accordeon = ({ name, spec, input, meta, children, }) => {
|
|
|
18
18
|
if (spec.required || !input.value) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: onDrop });
|
|
22
|
-
}, [spec.required, input.value, onDrop]);
|
|
21
|
+
return react_1.default.createElement(RemoveButton_1.RemoveButton, { name: name, onDrop: onDrop });
|
|
22
|
+
}, [spec.required, input.value, onDrop, name]);
|
|
23
23
|
(0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
|
|
24
|
-
return (react_1.default.createElement(SimpleVerticalAccordeon_1.SimpleVerticalAccordeon, { title: spec.viewSpec.layoutTitle || '', note: spec.viewSpec.layoutDescription || '', open: open, onOpenChange: setOpen, headerActionsTemplate: removeButton, hideInsteadOfDestroy: true, withBranchView: true },
|
|
24
|
+
return (react_1.default.createElement(SimpleVerticalAccordeon_1.SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', note: spec.viewSpec.layoutDescription || '', open: open, onOpenChange: setOpen, headerActionsTemplate: removeButton, hideInsteadOfDestroy: true, withBranchView: true },
|
|
25
25
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
26
26
|
};
|
|
27
27
|
exports.Accordeon = Accordeon;
|
|
@@ -6,9 +6,9 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const icons_1 = require("@gravity-ui/icons");
|
|
7
7
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
8
|
const i18n_1 = tslib_1.__importDefault(require("../../../i18n"));
|
|
9
|
-
const RemoveButton = ({ onDrop }) => {
|
|
9
|
+
const RemoveButton = ({ name, onDrop }) => {
|
|
10
10
|
const items = react_1.default.useMemo(() => [{ text: (0, i18n_1.default)('label_delete'), action: onDrop, theme: 'danger' }], [onDrop]);
|
|
11
|
-
const switcher = react_1.default.useMemo(() => (react_1.default.createElement(uikit_1.Button, { view: "flat" },
|
|
11
|
+
const switcher = react_1.default.useMemo(() => (react_1.default.createElement(uikit_1.Button, { view: "flat", qa: `${name}-drop-item` },
|
|
12
12
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Ellipsis, size: 16 }))), []);
|
|
13
13
|
return react_1.default.createElement(uikit_1.DropdownMenu, { switcher: switcher, items: items });
|
|
14
14
|
};
|
|
@@ -21,10 +21,10 @@ const AccordeonCardLayout = ({ name, spec, input, meta, children, }) => {
|
|
|
21
21
|
if (spec.required || !input.value) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: onDrop });
|
|
25
|
-
}, [spec.required, input.value, onDrop]);
|
|
24
|
+
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: onDrop, name: name });
|
|
25
|
+
}, [spec.required, input.value, onDrop, name]);
|
|
26
26
|
(0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
|
|
27
|
-
return (react_1.default.createElement(__1.AccordeonCard, { header: spec.viewSpec.layoutTitle || '', description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, headerActionsTemplate: removeButton, className: b() },
|
|
27
|
+
return (react_1.default.createElement(__1.AccordeonCard, { name: name, header: spec.viewSpec.layoutTitle || '', description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, headerActionsTemplate: removeButton, className: b() },
|
|
28
28
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
29
29
|
};
|
|
30
30
|
exports.AccordeonCardLayout = AccordeonCardLayout;
|
|
@@ -18,10 +18,10 @@ const CardAccordeon = ({ name, spec, input, meta, children, }) => {
|
|
|
18
18
|
if (spec.required || !input.value) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: onDrop });
|
|
22
|
-
}, [spec.required, input.value, onDrop]);
|
|
21
|
+
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: onDrop, name: name });
|
|
22
|
+
}, [spec.required, input.value, onDrop, name]);
|
|
23
23
|
(0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
|
|
24
|
-
return (react_1.default.createElement(components_1.Card, { title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, open: open, onToggle: onToggle },
|
|
24
|
+
return (react_1.default.createElement(components_1.Card, { name: name, title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, open: open, onToggle: onToggle },
|
|
25
25
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
26
26
|
};
|
|
27
27
|
exports.CardAccordeon = CardAccordeon;
|