@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
|
@@ -10,9 +10,9 @@ const CardSection = ({ name, spec, input, meta, children, }) => {
|
|
|
10
10
|
if (spec.required || !input.value) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop });
|
|
14
|
-
}, [spec.required, input.value, input.onDrop]);
|
|
15
|
-
return (react_1.default.createElement(components_1.Card, { title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, alwaysOpen: true },
|
|
13
|
+
return react_1.default.createElement(RemoveButton_1.RemoveButton, { onDrop: input.onDrop, name: name });
|
|
14
|
+
}, [spec.required, input.value, input.onDrop, name]);
|
|
15
|
+
return (react_1.default.createElement(components_1.Card, { name: name, title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, alwaysOpen: true },
|
|
16
16
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
17
17
|
};
|
|
18
18
|
exports.CardSection = CardSection;
|
|
@@ -21,7 +21,7 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
|
|
|
21
21
|
react_1.default.createElement("div", { className: b('right') },
|
|
22
22
|
react_1.default.createElement("div", { className: b('right-inner') },
|
|
23
23
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: (0, core_1.isArraySpec)(spec) || (0, core_1.isObjectSpec)(spec) }, children),
|
|
24
|
-
arrayItem ? (react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop },
|
|
24
|
+
arrayItem ? (react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop, qa: `${name}-remove-item` },
|
|
25
25
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 16 }))) : null),
|
|
26
26
|
verboseDescription && spec.viewSpec.layoutDescription ? (react_1.default.createElement("div", { className: b('description'), dangerouslySetInnerHTML: { __html: spec.viewSpec.layoutDescription } })) : null)));
|
|
27
27
|
};
|
|
@@ -18,7 +18,7 @@ const Row2 = ({ name, spec, input, meta, children, }) => {
|
|
|
18
18
|
react_1.default.createElement("div", { className: b('right') },
|
|
19
19
|
react_1.default.createElement("div", { className: b('right-inner') },
|
|
20
20
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: (0, core_1.isArraySpec)(spec) || (0, core_1.isObjectSpec)(spec) }, children),
|
|
21
|
-
(0, core_1.isArrayItem)(name) ? (react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop },
|
|
21
|
+
(0, core_1.isArrayItem)(name) ? (react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop, qa: `${name}-remove-item` },
|
|
22
22
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 16 }))) : null),
|
|
23
23
|
spec.viewSpec.layoutDescription ? (react_1.default.createElement("div", { className: b('description'), dangerouslySetInnerHTML: { __html: spec.viewSpec.layoutDescription } })) : null)));
|
|
24
24
|
};
|
|
@@ -16,7 +16,7 @@ const SectionCardBase = (_a) => {
|
|
|
16
16
|
if (meta) {
|
|
17
17
|
content = (react_1.default.createElement(__2.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: arrOrObjFlag }, content));
|
|
18
18
|
}
|
|
19
|
-
return (react_1.default.createElement(__1.AccordeonCard, { className: b(), header: spec.viewSpec.layoutTitle, description: ignoreDescription ? undefined : spec.viewSpec.layoutDescription, titleSize: titleSize, alwaysOpen: true }, content));
|
|
19
|
+
return (react_1.default.createElement(__1.AccordeonCard, { className: b(), name: name, header: spec.viewSpec.layoutTitle, description: ignoreDescription ? undefined : spec.viewSpec.layoutDescription, titleSize: titleSize, alwaysOpen: true }, content));
|
|
20
20
|
};
|
|
21
21
|
const SectionCard = (props) => react_1.default.createElement(SectionCardBase, Object.assign({}, props, { titleSize: "m" }));
|
|
22
22
|
exports.SectionCard = SectionCard;
|
|
@@ -14,11 +14,11 @@ const Transparent = ({ name, spec, input, meta, children, }) => {
|
|
|
14
14
|
const arrOrObjFlag = react_1.default.useMemo(() => (0, core_1.isArraySpec)(spec) || (0, core_1.isObjectSpec)(spec), [spec]);
|
|
15
15
|
const removeButton = react_1.default.useMemo(() => {
|
|
16
16
|
if (arrayItem) {
|
|
17
|
-
return (react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop },
|
|
17
|
+
return (react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop, qa: `${name}-remove-item` },
|
|
18
18
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 16 })));
|
|
19
19
|
}
|
|
20
20
|
return null;
|
|
21
|
-
}, [input.onDrop, arrayItem]);
|
|
21
|
+
}, [input.onDrop, arrayItem, name]);
|
|
22
22
|
return (react_1.default.createElement("div", { className: b({
|
|
23
23
|
'array-item': arrayItem && !arrOrObjFlag,
|
|
24
24
|
'without-max-width': arrOrObjFlag,
|
|
@@ -47,7 +47,7 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
47
47
|
this.checkVisibility();
|
|
48
48
|
}
|
|
49
49
|
render() {
|
|
50
|
-
const { titleSize, children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, } = this.props;
|
|
50
|
+
const { titleSize, children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
|
|
51
51
|
const { open, hidden, isFirstRender } = this.state;
|
|
52
52
|
const content = hideInsteadOfDestroy ? (react_1.default.createElement("div", { ref: this.componentRef, className: b('body', { hidden: !open }) }, children)) : (open && (react_1.default.createElement("div", { ref: this.componentRef, className: b('body', contentClassName) }, children)));
|
|
53
53
|
if (viewLayout && !isFirstRender && hidden) {
|
|
@@ -55,7 +55,7 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
55
55
|
}
|
|
56
56
|
return (Boolean(react_1.default.Children.count(children)) && (react_1.default.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
|
|
57
57
|
react_1.default.createElement("div", { className: b('header') },
|
|
58
|
-
react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick },
|
|
58
|
+
react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick, qa: `${name}-accordeon-toggler` },
|
|
59
59
|
react_1.default.createElement("b", { className: b('title', { size: titleSize }) }, this.getTitle()),
|
|
60
60
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ChevronDown, className: b('chevron', { open }), size: 16 })),
|
|
61
61
|
this.getTooltip(),
|
|
@@ -5,11 +5,11 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const SimpleVerticalAccordeon_1 = require("../../SimpleVerticalAccordeon");
|
|
8
|
-
const ViewAccordeon = ({ value, spec, children, }) => {
|
|
8
|
+
const ViewAccordeon = ({ name, value, spec, children, }) => {
|
|
9
9
|
const [open, setOpen] = react_1.default.useState(true);
|
|
10
10
|
if (!(0, utils_1.isNotEmptyValue)(value, spec)) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
return (react_1.default.createElement(SimpleVerticalAccordeon_1.SimpleVerticalAccordeon, { title: spec.viewSpec.layoutTitle || '', open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true }, children));
|
|
13
|
+
return (react_1.default.createElement(SimpleVerticalAccordeon_1.SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true }, children));
|
|
14
14
|
};
|
|
15
15
|
exports.ViewAccordeon = ViewAccordeon;
|
|
@@ -5,12 +5,12 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const __1 = require("../../");
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
|
-
const ViewAccordeonCard = ({ value, spec, children, }) => {
|
|
8
|
+
const ViewAccordeonCard = ({ name, value, spec, children, }) => {
|
|
9
9
|
const [open, setOpen] = react_1.default.useState(true);
|
|
10
10
|
const onToggle = react_1.default.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
11
11
|
if (!(0, utils_1.isNotEmptyValue)(value, spec)) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
|
-
return (react_1.default.createElement(__1.AccordeonCard, { header: spec.viewSpec.layoutTitle || '', open: open, onToggle: onToggle, className: "df-accordeon-card-layout" }, children));
|
|
14
|
+
return (react_1.default.createElement(__1.AccordeonCard, { name: name, header: spec.viewSpec.layoutTitle || '', open: open, onToggle: onToggle, className: "df-accordeon-card-layout" }, children));
|
|
15
15
|
};
|
|
16
16
|
exports.ViewAccordeonCard = ViewAccordeonCard;
|
|
@@ -5,12 +5,12 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const __1 = require("../");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
|
-
const ViewCardAccordeon = ({ value, spec, children, }) => {
|
|
8
|
+
const ViewCardAccordeon = ({ name, value, spec, children, }) => {
|
|
9
9
|
const [open, setOpen] = react_1.default.useState(true);
|
|
10
10
|
const onToggle = react_1.default.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
11
11
|
if (!(0, utils_1.isNotEmptyValue)(value, spec)) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
|
-
return (react_1.default.createElement(__1.Card, { title: spec.viewSpec.layoutTitle, open: open, onToggle: onToggle, checkEmptyBody: true }, children));
|
|
14
|
+
return (react_1.default.createElement(__1.Card, { name: name, title: spec.viewSpec.layoutTitle, open: open, onToggle: onToggle, checkEmptyBody: true }, children));
|
|
15
15
|
};
|
|
16
16
|
exports.ViewCardAccordeon = ViewCardAccordeon;
|
|
@@ -5,10 +5,10 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const components_1 = require("../../components");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
|
-
const ViewCardSection = ({ value, spec, children, }) => {
|
|
8
|
+
const ViewCardSection = ({ name, value, spec, children, }) => {
|
|
9
9
|
if (!(0, utils_1.isNotEmptyValue)(value, spec)) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
return (react_1.default.createElement(components_1.Card, { title: spec.viewSpec.layoutTitle, alwaysOpen: true, checkEmptyBody: true }, children));
|
|
12
|
+
return (react_1.default.createElement(components_1.Card, { name: name, title: spec.viewSpec.layoutTitle, alwaysOpen: true, checkEmptyBody: true }, children));
|
|
13
13
|
};
|
|
14
14
|
exports.ViewCardSection = ViewCardSection;
|
|
@@ -23,6 +23,6 @@ const CardOneOfView = (props) => {
|
|
|
23
23
|
if (!value || !Object.keys(value).length) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
return (react_1.default.createElement(__1.Card, { title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
|
|
26
|
+
return (react_1.default.createElement(__1.Card, { name: name, title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
|
|
27
27
|
};
|
|
28
28
|
exports.CardOneOfView = CardOneOfView;
|
|
@@ -3,13 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ObjectValueInputView = 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 OBJECT_VALUE_PROPERTY_NAME = 'value';
|
|
8
|
-
const ObjectValueInputView = (
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const ObjectValueInputView = (_a) => {
|
|
10
|
+
var { spec, name, Layout } = _a, restProps = tslib_1.__rest(_a, ["spec", "name", "Layout"]);
|
|
11
|
+
const childSpec = react_1.default.useMemo(() => {
|
|
12
|
+
var _a;
|
|
13
|
+
if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME]) {
|
|
14
|
+
const childSpec = lodash_1.default.cloneDeep(spec.properties[OBJECT_VALUE_PROPERTY_NAME]);
|
|
15
|
+
childSpec.viewSpec.layout = '';
|
|
16
|
+
return childSpec;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}, [spec.properties]);
|
|
20
|
+
if (!childSpec) {
|
|
11
21
|
return null;
|
|
12
22
|
}
|
|
13
|
-
|
|
23
|
+
const content = (react_1.default.createElement(core_1.ViewController, { spec: childSpec, name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}` }));
|
|
24
|
+
if (Layout) {
|
|
25
|
+
return (react_1.default.createElement(Layout, Object.assign({ spec: spec, name: name }, restProps), content));
|
|
26
|
+
}
|
|
27
|
+
return react_1.default.createElement(react_1.default.Fragment, null, content);
|
|
14
28
|
};
|
|
15
29
|
exports.ObjectValueInputView = ObjectValueInputView;
|
|
@@ -28,6 +28,6 @@ const OneOfCardView = (props) => {
|
|
|
28
28
|
if (!value || !Object.keys(value).length) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
return (react_1.default.createElement(__1.AccordeonCard, { className: "df-accordeon-card-layout", header: wrappedValue, open: open, onToggle: onToggle, ignoreHeaderToggle: true }, specProperties[valueKey] ? (react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
|
|
31
|
+
return (react_1.default.createElement(__1.AccordeonCard, { className: "df-accordeon-card-layout", name: name, header: wrappedValue, open: open, onToggle: onToggle, ignoreHeaderToggle: true }, specProperties[valueKey] ? (react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
|
|
32
32
|
};
|
|
33
33
|
exports.OneOfCardView = OneOfCardView;
|
|
@@ -3,15 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TextLinkView = 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 TEXT_LINK_PROPERTY_NAME = 'text';
|
|
8
|
-
const TextLinkView = (
|
|
9
|
-
|
|
10
|
-
const
|
|
9
|
+
const TextLinkView = (_a) => {
|
|
10
|
+
var { value, spec, name, Layout } = _a, restProps = tslib_1.__rest(_a, ["value", "spec", "name", "Layout"]);
|
|
11
|
+
const childSpec = react_1.default.useMemo(() => {
|
|
11
12
|
var _a;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME]) &&
|
|
14
|
+
(0, core_1.isStringSpec)(spec.properties[TEXT_LINK_PROPERTY_NAME])) {
|
|
15
|
+
const childSpec = lodash_1.default.cloneDeep(spec.properties[TEXT_LINK_PROPERTY_NAME]);
|
|
16
|
+
childSpec.viewSpec.layout = '';
|
|
17
|
+
childSpec.viewSpec.link = value === null || value === void 0 ? void 0 : value.link;
|
|
18
|
+
return childSpec;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}, [spec.properties, value === null || value === void 0 ? void 0 : value.link]);
|
|
22
|
+
if (!childSpec || !(value === null || value === void 0 ? void 0 : value.text)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const content = react_1.default.createElement(core_1.ViewController, { spec: childSpec, name: `${name}.${TEXT_LINK_PROPERTY_NAME}` });
|
|
26
|
+
if (Layout) {
|
|
27
|
+
return (react_1.default.createElement(Layout, Object.assign({ spec: spec, name: name, value: value }, restProps), content));
|
|
28
|
+
}
|
|
29
|
+
return react_1.default.createElement(react_1.default.Fragment, null, content);
|
|
16
30
|
};
|
|
17
31
|
exports.TextLinkView = TextLinkView;
|
|
@@ -7,7 +7,7 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
7
7
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
8
8
|
const MAX_TAB_TITLE_LENGTH = 20;
|
|
9
9
|
const useOneOf = ({ props, onTogglerChange }) => {
|
|
10
|
-
const { input, spec, Layout } = props;
|
|
10
|
+
const { name, input, spec, Layout } = props;
|
|
11
11
|
const specProperties = react_1.default.useMemo(() => (lodash_1.default.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
|
|
12
12
|
const [oneOfValue, setOneOfValue] = react_1.default.useState(() => {
|
|
13
13
|
let valueKeys;
|
|
@@ -41,10 +41,10 @@ const useOneOf = ({ props, onTogglerChange }) => {
|
|
|
41
41
|
const togglerInput = react_1.default.useMemo(() => {
|
|
42
42
|
if (options.length > 3 ||
|
|
43
43
|
lodash_1.default.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH)) {
|
|
44
|
-
return (react_1.default.createElement(uikit_1.Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: spec.viewSpec.disabled, filterable: options.length > 7 }));
|
|
44
|
+
return (react_1.default.createElement(uikit_1.Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: spec.viewSpec.disabled, filterable: options.length > 7, qa: name }));
|
|
45
45
|
}
|
|
46
|
-
return (react_1.default.createElement(uikit_1.RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: spec.viewSpec.disabled }, options.map((option) => (react_1.default.createElement(uikit_1.RadioButton.Option, { key: option.value, value: option.value }, option.title)))));
|
|
47
|
-
}, [options, oneOfValue, onOneOfChange]);
|
|
46
|
+
return (react_1.default.createElement(uikit_1.RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: spec.viewSpec.disabled, qa: name }, options.map((option) => (react_1.default.createElement(uikit_1.RadioButton.Option, { key: option.value, value: option.value }, option.title)))));
|
|
47
|
+
}, [options, oneOfValue, onOneOfChange, name]);
|
|
48
48
|
const toggler = react_1.default.useMemo(() => {
|
|
49
49
|
if (Layout) {
|
|
50
50
|
return react_1.default.createElement(Layout, Object.assign({}, props), togglerInput);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import { isArraySpec, isObjectSpec } from '../../../helpers';
|
|
3
|
+
import { isArraySpec, isObjectSpec, isReact18OrMore } from '../../../helpers';
|
|
4
4
|
import { OBJECT_ARRAY_CNT, OBJECT_ARRAY_FLAG, REMOVED_ITEM } from '../constants';
|
|
5
5
|
import { isArrayItem, transformArrIn, transformArrOut } from '../utils';
|
|
6
6
|
export const useField = ({ name, spec, initialValue, validate: propsValidate, tools, parentOnChange, parentOnUnmount, }) => {
|
|
@@ -129,6 +129,9 @@ export const useField = ({ name, spec, initialValue, validate: propsValidate, to
|
|
|
129
129
|
React.useEffect(() => {
|
|
130
130
|
firstRenderRef.current = false;
|
|
131
131
|
return () => {
|
|
132
|
+
if (isReact18OrMore()) {
|
|
133
|
+
firstRenderRef.current = true;
|
|
134
|
+
}
|
|
132
135
|
(parentOnUnmount ? parentOnUnmount : tools.onUnmount)(name);
|
|
133
136
|
};
|
|
134
137
|
}, []);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { useForm } from 'react-final-form';
|
|
4
|
+
import { isReact18OrMore } from '../../../helpers';
|
|
4
5
|
import { transformArrIn } from '../utils';
|
|
5
6
|
export const useStore = (name) => {
|
|
6
7
|
const form = useForm();
|
|
@@ -38,6 +39,11 @@ export const useStore = (name) => {
|
|
|
38
39
|
}, [name]);
|
|
39
40
|
React.useEffect(() => {
|
|
40
41
|
firstRenderRef.current = false;
|
|
42
|
+
return () => {
|
|
43
|
+
if (isReact18OrMore()) {
|
|
44
|
+
firstRenderRef.current = true;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
41
47
|
}, []);
|
|
42
48
|
return { tools, store };
|
|
43
49
|
};
|
|
@@ -5,3 +5,4 @@ export declare const isBooleanSpec: (candidate: any) => candidate is BooleanSpec
|
|
|
5
5
|
export declare const isNumberSpec: (candidate: any) => candidate is NumberSpec<any>;
|
|
6
6
|
export declare const isObjectSpec: (candidate: any) => candidate is ObjectSpec<any>;
|
|
7
7
|
export declare const isStringSpec: (candidate: any) => candidate is StringSpec<any>;
|
|
8
|
+
export declare const isReact18OrMore: () => boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import _ from 'lodash';
|
|
2
3
|
import { SpecTypes } from './constants';
|
|
3
4
|
export const isCorrectSpec = (candidate) => _.isObjectLike(candidate) &&
|
|
@@ -13,3 +14,4 @@ export const isBooleanSpec = (candidate) => (candidate === null || candidate ===
|
|
|
13
14
|
export const isNumberSpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === SpecTypes.Number;
|
|
14
15
|
export const isObjectSpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === SpecTypes.Object;
|
|
15
16
|
export const isStringSpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === SpecTypes.String;
|
|
17
|
+
export const isReact18OrMore = () => Number(React.version.split('.')[0]) >= 18;
|
|
@@ -5,7 +5,7 @@ import _ from 'lodash';
|
|
|
5
5
|
import { block } from '../../utils';
|
|
6
6
|
import './AccordeonCard.css';
|
|
7
7
|
const b = block('accordeon-card');
|
|
8
|
-
export const AccordeonCard = ({ className, header, description, open: propsOpen, onToggle, headerActionsTemplate, ignoreHeaderToggle, titleSize = 'm', alwaysOpen, children, }) => {
|
|
8
|
+
export const AccordeonCard = ({ className, name, header, description, open: propsOpen, onToggle, headerActionsTemplate, ignoreHeaderToggle, titleSize = 'm', alwaysOpen, children, }) => {
|
|
9
9
|
const accordeonRef = React.useRef(null);
|
|
10
10
|
const bodyRef = React.useRef(null);
|
|
11
11
|
const [open, setOpen] = React.useState(alwaysOpen || propsOpen || false);
|
|
@@ -40,7 +40,7 @@ export const AccordeonCard = ({ className, header, description, open: propsOpen,
|
|
|
40
40
|
description ? (React.createElement("span", { className: b('header-content-description'), dangerouslySetInnerHTML: { __html: description } })) : null),
|
|
41
41
|
!emptyBody && !alwaysOpen ? (React.createElement("div", { className: b('header-toggle-btn'), onClick: preventEvent },
|
|
42
42
|
headerActionsTemplate ? (React.createElement("div", { className: b('interal-actions') }, headerActionsTemplate)) : null,
|
|
43
|
-
React.createElement(Button, { view: "flat", onClick: handleToggle },
|
|
43
|
+
React.createElement(Button, { view: "flat", onClick: handleToggle, qa: `${name}-accordeon-toggler` },
|
|
44
44
|
React.createElement(Icon, { className: b('toggle-icon', { open }), data: ChevronDown, size: 16 })))) : null),
|
|
45
45
|
React.createElement("div", { ref: bodyRef, className: b('body', { open: open && !emptyBody }) }, children)));
|
|
46
46
|
};
|
|
@@ -5,7 +5,7 @@ import _ from 'lodash';
|
|
|
5
5
|
import { block } from '../../utils';
|
|
6
6
|
import './Card.css';
|
|
7
7
|
const b = block('card');
|
|
8
|
-
export const Card = ({ title: propsTitle, description, actions, open: propsOpen, onToggle, alwaysOpen, disableHeaderToggle, checkEmptyBody, children, }) => {
|
|
8
|
+
export const Card = ({ name, title: propsTitle, description, actions, open: propsOpen, onToggle, alwaysOpen, disableHeaderToggle, checkEmptyBody, children, }) => {
|
|
9
9
|
const containerRef = React.useRef(null);
|
|
10
10
|
const bodyRef = React.useRef(null);
|
|
11
11
|
const [open, setOpen] = React.useState(alwaysOpen || propsOpen || false);
|
|
@@ -55,7 +55,7 @@ export const Card = ({ title: propsTitle, description, actions, open: propsOpen,
|
|
|
55
55
|
React.createElement("div", { className: b('header-right'), onClick: preventEvent },
|
|
56
56
|
actions ? React.createElement("div", { className: b('actions') }, actions) : null,
|
|
57
57
|
alwaysOpen ? null : (React.createElement("div", { className: b('toggler') },
|
|
58
|
-
React.createElement(Button, { view: "flat", onClick: handleToggle },
|
|
58
|
+
React.createElement(Button, { view: "flat", onClick: handleToggle, qa: `${name}-accordeon-toggler` },
|
|
59
59
|
React.createElement(Icon, { className: b('toggler-icon', { open }), data: ChevronDown, size: 16 })))))),
|
|
60
60
|
React.createElement("div", { ref: bodyRef, className: b('body', { open }) }, children)));
|
|
61
61
|
};
|
|
@@ -49,9 +49,9 @@ export const ArrayBase = ({ spec, name, arrayInput, input }) => {
|
|
|
49
49
|
}
|
|
50
50
|
return (React.createElement(React.Fragment, null,
|
|
51
51
|
items,
|
|
52
|
-
!arrayInput.value && spec.defaultValue ? (React.createElement(Button, { onClick: () => input.onChange(transformArrIn(spec.defaultValue)), disabled: spec.viewSpec.disabled },
|
|
52
|
+
!arrayInput.value && spec.defaultValue ? (React.createElement(Button, { onClick: () => input.onChange(transformArrIn(spec.defaultValue)), disabled: spec.viewSpec.disabled, qa: `${name}-init-arr` },
|
|
53
53
|
React.createElement(Icon, { data: Plus, size: 14 }),
|
|
54
|
-
spec.viewSpec.layoutTitle || null)) : (React.createElement(Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled },
|
|
54
|
+
spec.viewSpec.layoutTitle || null)) : (React.createElement(Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled, qa: `${name}-add-item` },
|
|
55
55
|
React.createElement(Icon, { data: Plus, size: 14 }),
|
|
56
56
|
spec.viewSpec.itemLabel || null))));
|
|
57
57
|
};
|
|
@@ -18,7 +18,7 @@ export const CardOneOf = (props) => {
|
|
|
18
18
|
const toggler = React.useMemo(() => (React.createElement(Row, Object.assign({}, props, { name: "__stub-name" }), togglerInput)), [togglerInput, props]);
|
|
19
19
|
const actions = React.useMemo(() => {
|
|
20
20
|
if (isArrayItem(name)) {
|
|
21
|
-
return React.createElement(RemoveButton, { onDrop: input.onDrop });
|
|
21
|
+
return React.createElement(RemoveButton, { onDrop: input.onDrop, name: name });
|
|
22
22
|
}
|
|
23
23
|
return;
|
|
24
24
|
}, [name, input.onDrop]);
|
|
@@ -28,5 +28,5 @@ export const CardOneOf = (props) => {
|
|
|
28
28
|
}, [input.onChange, input.name]);
|
|
29
29
|
const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
30
30
|
useErrorChecker({ name, meta, open, setOpen });
|
|
31
|
-
return (React.createElement(Card, { title: toggler, description: spec.viewSpec.layoutDescription, actions: actions, open: open, onToggle: onToggle, disableHeaderToggle: true }, specProperties[oneOfValue] ? (React.createElement(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));
|
|
31
|
+
return (React.createElement(Card, { name: name, title: toggler, description: spec.viewSpec.layoutDescription, actions: actions, open: open, onToggle: onToggle, disableHeaderToggle: true }, specProperties[oneOfValue] ? (React.createElement(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));
|
|
32
32
|
};
|
|
@@ -3,9 +3,9 @@ import { Checkbox as CheckboxBase } from '@gravity-ui/uikit';
|
|
|
3
3
|
import { block } from '../../../utils';
|
|
4
4
|
import './Checkbox.css';
|
|
5
5
|
const b = block('checkbox');
|
|
6
|
-
export const Checkbox = ({ input, spec }) => {
|
|
6
|
+
export const Checkbox = ({ name, input, spec }) => {
|
|
7
7
|
const { value, onBlur, onChange, onFocus } = input;
|
|
8
8
|
const handleChange = React.useCallback((e) => onChange(e.target.checked), [onChange]);
|
|
9
9
|
return (React.createElement("div", { className: b() },
|
|
10
|
-
React.createElement(CheckboxBase, { checked: value, onChange: handleChange, onBlur: onBlur, onFocus: onFocus, disabled: spec.viewSpec.disabled })));
|
|
10
|
+
React.createElement(CheckboxBase, { checked: value, onChange: handleChange, onBlur: onBlur, onFocus: onFocus, disabled: spec.viewSpec.disabled, qa: name })));
|
|
11
11
|
};
|
|
@@ -6,7 +6,7 @@ import { block } from '../../../utils';
|
|
|
6
6
|
import { readFile } from './utils';
|
|
7
7
|
import './FileInput.css';
|
|
8
8
|
const b = block('file-input');
|
|
9
|
-
export const FileInput = ({ input, spec }) => {
|
|
9
|
+
export const FileInput = ({ name, input, spec }) => {
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const { value, onChange } = input;
|
|
12
12
|
const inputRef = React.useRef(null);
|
|
@@ -38,9 +38,9 @@ export const FileInput = ({ input, spec }) => {
|
|
|
38
38
|
return null;
|
|
39
39
|
}, [fileName, value]);
|
|
40
40
|
return (React.createElement("div", { className: b() },
|
|
41
|
-
React.createElement(Button, { disabled: spec.viewSpec.disabled, onClick: handleClick }, i18n('button-upload_file')),
|
|
41
|
+
React.createElement(Button, { disabled: spec.viewSpec.disabled, onClick: handleClick, qa: `${name}-file-upload` }, i18n('button-upload_file')),
|
|
42
42
|
React.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 }),
|
|
43
43
|
React.createElement("span", { className: b('file-name') }, fileNameContent),
|
|
44
|
-
value ? (React.createElement(Button, { view: "flat", onClick: handleReset, disabled: spec.viewSpec.disabled },
|
|
44
|
+
value ? (React.createElement(Button, { view: "flat", onClick: handleReset, disabled: spec.viewSpec.disabled, qa: `${name}-file-remove` },
|
|
45
45
|
React.createElement(Icon, { data: Xmark, size: 16 }))) : null));
|
|
46
46
|
};
|
|
@@ -8,7 +8,7 @@ import { MonacoInputDialog } from './MonacoInputDialog';
|
|
|
8
8
|
import { useMonacoOptions } from './useMonacoOptions';
|
|
9
9
|
import './MonacoInputBase.css';
|
|
10
10
|
const b = block('monaco-input');
|
|
11
|
-
export const MonacoInputBase = ({ input, spec, card, MonacoComponent, withoutDialog, }) => {
|
|
11
|
+
export const MonacoInputBase = ({ name, input, spec, card, MonacoComponent, withoutDialog, }) => {
|
|
12
12
|
const { value, onChange } = input;
|
|
13
13
|
const MonacoEditor = useMonaco() || MonacoComponent;
|
|
14
14
|
const { monacoParams, disabled, layoutTitle } = spec.viewSpec;
|
|
@@ -18,21 +18,21 @@ export const MonacoInputBase = ({ input, spec, card, MonacoComponent, withoutDia
|
|
|
18
18
|
const handleMonacoEditorDialogClose = React.useCallback(() => setMonacoEditorDialog(false), []);
|
|
19
19
|
const dialogButton = React.useMemo(() => {
|
|
20
20
|
if (!withoutDialog) {
|
|
21
|
-
return (React.createElement(Button, { onClick: () => setMonacoEditorDialog(true) },
|
|
21
|
+
return (React.createElement(Button, { onClick: () => setMonacoEditorDialog(true), qa: `${name}-open-dialog` },
|
|
22
22
|
React.createElement(Icon, { data: ChevronsExpandUpRight, size: 16 })));
|
|
23
23
|
}
|
|
24
24
|
return;
|
|
25
|
-
}, [withoutDialog, setMonacoEditorDialog]);
|
|
25
|
+
}, [withoutDialog, setMonacoEditorDialog, name]);
|
|
26
26
|
React.useEffect(() => onChange(monacoValue), [monacoValue]);
|
|
27
27
|
const options = useMonacoOptions(fontSize, disabled !== null && disabled !== void 0 ? disabled : false);
|
|
28
28
|
if (!MonacoEditor) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
return (React.createElement("div", { className: b({ card }) },
|
|
32
|
-
React.createElement("div", { className: b('container') },
|
|
32
|
+
React.createElement("div", { className: b('container'), "data-qa": name },
|
|
33
33
|
React.createElement(MonacoHeader, { language: language, card: card, editButton: dialogButton }),
|
|
34
34
|
React.createElement(MonacoEditor, { language: language, value: monacoValue, height: "300", onChange: setMonacoValue, options: options })),
|
|
35
|
-
React.createElement(MonacoInputDialog, { title: layoutTitle, fontSize: fontSize, value: monacoValue, visible: monacoEditorDialog, language: language, card: card, changeMonacoValue: setMonacoValue, onChange: onChange, onClose: handleMonacoEditorDialogClose, MonacoComponent: MonacoComponent })));
|
|
35
|
+
React.createElement(MonacoInputDialog, { name: name, title: layoutTitle, fontSize: fontSize, value: monacoValue, visible: monacoEditorDialog, language: language, card: card, changeMonacoValue: setMonacoValue, onChange: onChange, onClose: handleMonacoEditorDialogClose, MonacoComponent: MonacoComponent })));
|
|
36
36
|
};
|
|
37
37
|
export const MonacoInput = (props) => (React.createElement(MonacoInputBase, Object.assign({}, props)));
|
|
38
38
|
export const MonacoInputCard = (props) => (React.createElement(MonacoInputBase, Object.assign({}, props, { card: true })));
|
|
@@ -7,7 +7,7 @@ import { MonacoHeader } from './MonacoHeader';
|
|
|
7
7
|
import { useMonacoOptions } from './useMonacoOptions';
|
|
8
8
|
import './MonacoInputDialog.css';
|
|
9
9
|
const b = block('monaco-input-dialog');
|
|
10
|
-
export const MonacoInputDialog = ({ value, title, visible, language, card, onChange, onClose, changeMonacoValue, fontSize, MonacoComponent, }) => {
|
|
10
|
+
export const MonacoInputDialog = ({ name, value, title, visible, language, card, onChange, onClose, changeMonacoValue, fontSize, MonacoComponent, }) => {
|
|
11
11
|
const MonacoEditor = useMonaco() || MonacoComponent;
|
|
12
12
|
const handleClose = React.useCallback(() => {
|
|
13
13
|
onChange(value);
|
|
@@ -20,7 +20,7 @@ export const MonacoInputDialog = ({ value, title, visible, language, card, onCha
|
|
|
20
20
|
return (React.createElement(Dialog, { open: visible, onClose: handleClose, className: b() },
|
|
21
21
|
React.createElement(Dialog.Header, { caption: title, className: b('dialog-header') }),
|
|
22
22
|
React.createElement(Dialog.Body, null,
|
|
23
|
-
React.createElement("div", { className: b('container') },
|
|
23
|
+
React.createElement("div", { className: b('container'), "data-qa": `${name}-dialog` },
|
|
24
24
|
React.createElement(MonacoHeader, { language: language, card: card }),
|
|
25
25
|
React.createElement(MonacoEditor, { language: language, height: "600", width: "900", value: value, onChange: changeMonacoValue, options: options }))),
|
|
26
26
|
React.createElement(Dialog.Footer, { textButtonApply: i18n('button_cancel'), onClickButtonApply: handleClose })));
|
|
@@ -4,7 +4,7 @@ import { transformArrIn, transformArrOut } from '../../../../core';
|
|
|
4
4
|
import { block } from '../../../utils';
|
|
5
5
|
import './MultiSelect.css';
|
|
6
6
|
const b = block('multi-select');
|
|
7
|
-
export const MultiSelect = ({ input, spec }) => {
|
|
7
|
+
export const MultiSelect = ({ name, input, spec }) => {
|
|
8
8
|
var _a;
|
|
9
9
|
const { value, onBlur, onChange, onFocus } = input;
|
|
10
10
|
const filterable = React.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]);
|
|
@@ -30,5 +30,5 @@ export const MultiSelect = ({ input, spec }) => {
|
|
|
30
30
|
}, [onFocus, onBlur]);
|
|
31
31
|
const _value = React.useMemo(() => transformArrOut(value), [value]);
|
|
32
32
|
const handleChange = React.useCallback((value) => onChange(transformArrIn(value)), [onChange]);
|
|
33
|
-
return (React.createElement(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 }));
|
|
33
|
+
return (React.createElement(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 }));
|
|
34
34
|
};
|
|
@@ -4,7 +4,7 @@ import { block, divide, isCorrectSizeParams, multiply } from '../../../utils';
|
|
|
4
4
|
import { useInitial } from './useInitial';
|
|
5
5
|
import './NumberWithScale.css';
|
|
6
6
|
const b = block('number-with-scale');
|
|
7
|
-
const NumberWithScaleBase = ({ input, spec }) => {
|
|
7
|
+
const NumberWithScaleBase = ({ name, input, spec }) => {
|
|
8
8
|
const { value = '', onBlur, onFocus, onChange } = input;
|
|
9
9
|
const { sizeParams, disabled, placeholder } = spec.viewSpec;
|
|
10
10
|
const { defaultType, scale } = sizeParams;
|
|
@@ -61,7 +61,7 @@ const NumberWithScaleBase = ({ input, spec }) => {
|
|
|
61
61
|
}
|
|
62
62
|
}, [setPreparedValue, setScaleValue, incorrectStringNumber, value, scale, defaultType]);
|
|
63
63
|
return (React.createElement("div", { className: b('wrapper') },
|
|
64
|
-
React.createElement(TextInput, { value: preparedValue, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, placeholder: placeholder, disabled: disabled }),
|
|
65
|
-
React.createElement(Select, { width: "max", className: b('select', 'df-error-wrapper-ignore'), value: [scaleValue], options: scaleOptions, onUpdate: handleScaleChange, disabled: disabled || incorrectStringNumber })));
|
|
64
|
+
React.createElement(TextInput, { value: preparedValue, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, placeholder: placeholder, disabled: disabled, qa: name }),
|
|
65
|
+
React.createElement(Select, { width: "max", className: b('select', 'df-error-wrapper-ignore'), value: [scaleValue], options: scaleOptions, onUpdate: handleScaleChange, disabled: disabled || incorrectStringNumber, qa: `${name}-scale` })));
|
|
66
66
|
};
|
|
67
67
|
export const NumberWithScale = (props) => isCorrectSizeParams(props.spec) ? React.createElement(NumberWithScaleBase, Object.assign({}, props)) : null;
|
|
@@ -8,7 +8,7 @@ export const ObjectBase = (_a) => {
|
|
|
8
8
|
var { spec, name, Layout } = _a, restProps = __rest(_a, ["spec", "name", "Layout"]);
|
|
9
9
|
const addBtn = React.useMemo(() => {
|
|
10
10
|
var _a;
|
|
11
|
-
return (React.createElement(Button, { onClick: () => restProps.input.onChange(transformArrIn(spec.defaultValue) || {}), disabled: (_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.disabled },
|
|
11
|
+
return (React.createElement(Button, { onClick: () => restProps.input.onChange(transformArrIn(spec.defaultValue) || {}), disabled: (_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.disabled, qa: `${name}-init-obj` },
|
|
12
12
|
React.createElement(Icon, { data: Plus, size: 14 }),
|
|
13
13
|
spec.viewSpec.layoutTitle || null));
|
|
14
14
|
}, [spec.defaultValue, spec.viewSpec.layoutTitle, restProps.input.onChange]);
|
|
@@ -18,7 +18,7 @@ export const ObjectBase = (_a) => {
|
|
|
18
18
|
if (!_.isObjectLike(spec.properties) || !Object.keys(spec.properties || {}).length) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
if (!restProps.input.value
|
|
21
|
+
if (!restProps.input.value) {
|
|
22
22
|
return addBtn;
|
|
23
23
|
}
|
|
24
24
|
const specProperties = Object.assign({}, spec.properties);
|