@gravity-ui/dynamic-forms 5.32.0 → 5.33.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/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.d.ts +2 -0
- package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +6 -7
- package/build/cjs/lib/unstable/kit/components/CopyButton/CopyButton.css +1 -0
- package/build/cjs/lib/unstable/kit/components/CopyButton/CopyButton.d.ts +3 -1
- package/build/cjs/lib/unstable/kit/components/CopyButton/CopyButton.js +6 -2
- package/build/cjs/lib/unstable/kit/components/DropButton/DropButton.css +3 -0
- package/build/cjs/lib/unstable/kit/components/DropButton/DropButton.d.ts +10 -0
- package/build/cjs/lib/unstable/kit/components/DropButton/DropButton.js +32 -0
- package/build/cjs/lib/unstable/kit/components/DropButton/index.d.ts +1 -0
- package/build/cjs/lib/unstable/kit/components/DropButton/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/EntityContainer/EntityContainer.css +1 -0
- package/build/cjs/lib/unstable/kit/components/EntityContainer/EntityContainer.d.ts +1 -0
- package/build/cjs/lib/unstable/kit/components/EntityContainer/EntityContainer.js +2 -2
- package/build/cjs/lib/unstable/kit/components/LayoutButtons/LayoutButtons.d.ts +10 -0
- package/build/cjs/lib/unstable/kit/components/LayoutButtons/LayoutButtons.js +15 -0
- package/build/cjs/lib/unstable/kit/components/LayoutButtons/index.d.ts +1 -0
- package/build/cjs/lib/unstable/kit/components/LayoutButtons/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +30 -1
- package/build/cjs/lib/unstable/kit/components/index.d.ts +2 -0
- package/build/cjs/lib/unstable/kit/components/index.js +5 -1
- package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.css +1 -1
- package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +33 -4
- package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.css +13 -3
- package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +47 -15
- package/build/cjs/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.css +3 -0
- package/build/cjs/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.js +33 -1
- package/build/cjs/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.css +3 -5
- package/build/cjs/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +1 -1
- package/build/cjs/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.css +1 -0
- package/build/cjs/lib/unstable/kit/form-layouts/FormColumn/FormColumn.css +3 -3
- package/build/cjs/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +6 -5
- package/build/cjs/lib/unstable/kit/form-layouts/FormRow/FormRow.js +2 -2
- package/build/cjs/lib/unstable/kit/layouts/Accordeon/Accordeon.css +2 -6
- package/build/cjs/lib/unstable/kit/layouts/Accordeon/Accordeon.js +3 -16
- package/build/cjs/lib/unstable/kit/layouts/Card/Card.css +0 -6
- package/build/cjs/lib/unstable/kit/layouts/Card/Card.js +2 -3
- package/build/cjs/lib/unstable/kit/layouts/Section/Section.css +0 -6
- package/build/cjs/lib/unstable/kit/layouts/Section/Section.js +2 -3
- package/build/cjs/lib/unstable/kit/layouts/Transparent/Transparent.css +0 -6
- package/build/cjs/lib/unstable/kit/layouts/Transparent/Transparent.js +2 -3
- package/build/cjs/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +3 -3
- package/build/cjs/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +3 -3
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.d.ts +2 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +7 -8
- package/build/esm/lib/unstable/kit/components/CopyButton/CopyButton.css +1 -0
- package/build/esm/lib/unstable/kit/components/CopyButton/CopyButton.d.ts +3 -1
- package/build/esm/lib/unstable/kit/components/CopyButton/CopyButton.js +6 -2
- package/build/esm/lib/unstable/kit/components/DropButton/DropButton.css +3 -0
- package/build/esm/lib/unstable/kit/components/DropButton/DropButton.d.ts +11 -0
- package/build/esm/lib/unstable/kit/components/DropButton/DropButton.js +28 -0
- package/build/esm/lib/unstable/kit/components/DropButton/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/DropButton/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/EntityContainer/EntityContainer.css +1 -0
- package/build/esm/lib/unstable/kit/components/EntityContainer/EntityContainer.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/EntityContainer/EntityContainer.js +2 -2
- package/build/esm/lib/unstable/kit/components/LayoutButtons/LayoutButtons.d.ts +10 -0
- package/build/esm/lib/unstable/kit/components/LayoutButtons/LayoutButtons.js +10 -0
- package/build/esm/lib/unstable/kit/components/LayoutButtons/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/LayoutButtons/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +30 -1
- package/build/esm/lib/unstable/kit/components/index.d.ts +2 -0
- package/build/esm/lib/unstable/kit/components/index.js +2 -0
- package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.css +1 -1
- package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +33 -4
- package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.css +13 -3
- package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +48 -16
- package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.css +3 -0
- package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.d.ts +1 -0
- package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.js +35 -2
- package/build/esm/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.css +3 -5
- package/build/esm/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +1 -1
- package/build/esm/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.css +1 -0
- package/build/esm/lib/unstable/kit/form-layouts/FormColumn/FormColumn.css +3 -3
- package/build/esm/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +7 -6
- package/build/esm/lib/unstable/kit/form-layouts/FormRow/FormRow.js +3 -3
- package/build/esm/lib/unstable/kit/layouts/Accordeon/Accordeon.css +2 -6
- package/build/esm/lib/unstable/kit/layouts/Accordeon/Accordeon.js +4 -17
- package/build/esm/lib/unstable/kit/layouts/Card/Card.css +0 -6
- package/build/esm/lib/unstable/kit/layouts/Card/Card.js +3 -4
- package/build/esm/lib/unstable/kit/layouts/Section/Section.css +0 -6
- package/build/esm/lib/unstable/kit/layouts/Section/Section.js +3 -4
- package/build/esm/lib/unstable/kit/layouts/Transparent/Transparent.css +0 -6
- package/build/esm/lib/unstable/kit/layouts/Transparent/Transparent.js +3 -4
- package/build/esm/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +4 -4
- package/build/esm/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +4 -4
- package/package.json +1 -1
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
.sr-accordeon:last-child {
|
|
5
5
|
margin-bottom: 0;
|
|
6
6
|
}
|
|
7
|
-
.sr-accordeon:hover .sr-accordeon__copy-button {
|
|
8
|
-
display: block;
|
|
9
|
-
}
|
|
10
7
|
.sr-accordeon .g-disclosure__trigger {
|
|
11
8
|
padding-left: 6.5px;
|
|
12
9
|
}
|
|
@@ -17,6 +14,8 @@
|
|
|
17
14
|
display: none;
|
|
18
15
|
}
|
|
19
16
|
.sr-accordeon__toggler {
|
|
17
|
+
height: auto;
|
|
18
|
+
min-height: 28px;
|
|
20
19
|
padding-left: 6px;
|
|
21
20
|
}
|
|
22
21
|
.sr-accordeon__title_required::after {
|
|
@@ -40,7 +39,4 @@
|
|
|
40
39
|
position: absolute;
|
|
41
40
|
left: calc(var(--g-spacing-base) * 3 + 1.5px);
|
|
42
41
|
bottom: 0;
|
|
43
|
-
}
|
|
44
|
-
.sr-accordeon__copy-button {
|
|
45
|
-
display: none;
|
|
46
42
|
}
|
|
@@ -13,10 +13,10 @@ const b = (0, utils_1.block)('accordeon');
|
|
|
13
13
|
const Accordeon = ({ children, headName, input, meta, mode, schema, props, }) => {
|
|
14
14
|
var _a;
|
|
15
15
|
const { titleProps, togglerProps, withIndent = false, withDefaultSummary = false } = props, restLayoutProps = tslib_1.__rest(props, ["titleProps", "togglerProps", "withIndent", "withDefaultSummary"]);
|
|
16
|
-
const {
|
|
16
|
+
const { required, hidden, open } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
17
17
|
const { expanded, setExpanded } = (0, hooks_1.useExpanded)({ headName, name: input.name, open });
|
|
18
18
|
const overviewFlag = mode === core_1.SchemaRendererMode.Overview;
|
|
19
|
-
const summary = react_1.default.useMemo(() => (react_1.default.createElement(uikit_1.Text, Object.assign({ variant: "subheader-1", color: "complementary" }, titleProps, { className: b('title', { required: required && !overviewFlag }, titleProps === null || titleProps === void 0 ? void 0 : titleProps.className) }), schema.title)), [overviewFlag, required, schema.title, titleProps]);
|
|
19
|
+
const summary = react_1.default.useMemo(() => (react_1.default.createElement(uikit_1.Text, Object.assign({ variant: "subheader-1", color: "complementary" }, titleProps, { className: b('title', { required: required && !overviewFlag }, titleProps === null || titleProps === void 0 ? void 0 : titleProps.className), whiteSpace: "break-spaces", wordBreak: "break-word" }), schema.title)), [overviewFlag, required, schema.title, titleProps]);
|
|
20
20
|
const helpMark = react_1.default.useMemo(() => {
|
|
21
21
|
if (schema.description) {
|
|
22
22
|
return (react_1.default.createElement(uikit_1.HelpMark, null,
|
|
@@ -24,18 +24,6 @@ const Accordeon = ({ children, headName, input, meta, mode, schema, props, }) =>
|
|
|
24
24
|
}
|
|
25
25
|
return null;
|
|
26
26
|
}, [schema.description, headName]);
|
|
27
|
-
const copyButton = react_1.default.useMemo(() => {
|
|
28
|
-
if (overviewFlag) {
|
|
29
|
-
return react_1.default.createElement(components_1.CopyButton, { className: b('copy-button'), copy: copy, value: input.value });
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}, [overviewFlag, copy, input.value]);
|
|
33
|
-
const removeButton = react_1.default.useMemo(() => {
|
|
34
|
-
if (overviewFlag) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return react_1.default.createElement(components_1.ArrayRemoveButton, { name: input.name, headName: headName });
|
|
38
|
-
}, [overviewFlag, input.name, headName]);
|
|
39
27
|
return (react_1.default.createElement(components_1.LayoutContainer, { className: b({ 'without-default-summary': !withDefaultSummary }), hideEmpty: overviewFlag, hidden: hidden },
|
|
40
28
|
react_1.default.createElement(uikit_1.Disclosure, Object.assign({ summary: summary, expanded: expanded, onUpdate: setExpanded }, restLayoutProps),
|
|
41
29
|
react_1.default.createElement(uikit_1.Disclosure.Summary, null, ({ expanded, onClick }, defaultSummary) => (react_1.default.createElement(uikit_1.Flex, { minHeight: "28px", alignItems: "center", gap: 2 },
|
|
@@ -44,8 +32,7 @@ const Accordeon = ({ children, headName, input, meta, mode, schema, props, }) =>
|
|
|
44
32
|
react_1.default.createElement(uikit_1.Icon, { data: expanded ? icons_1.ChevronUp : icons_1.ChevronDown }),
|
|
45
33
|
summary))),
|
|
46
34
|
helpMark,
|
|
47
|
-
|
|
48
|
-
removeButton))),
|
|
35
|
+
react_1.default.createElement(components_1.LayoutButtons, { mode: mode, name: input.name, headName: headName, schema: schema, value: input.value })))),
|
|
49
36
|
react_1.default.createElement(uikit_1.Flex, { direction: "column", gap: 0.5, grow: 1 },
|
|
50
37
|
react_1.default.createElement("div", { className: b('content', { 'with-indent': withIndent }) }, children),
|
|
51
38
|
overviewFlag ? null : (react_1.default.createElement(components_1.EntityError, { errorMessage: meta.error, validationState: (0, utils_1.getValidationState)(meta) }))))));
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
.sr-card:last-child {
|
|
5
5
|
margin-bottom: 0;
|
|
6
6
|
}
|
|
7
|
-
.sr-card:hover .sr-card__copy-button {
|
|
8
|
-
display: block;
|
|
9
|
-
}
|
|
10
7
|
.sr-card__inner {
|
|
11
8
|
display: flex;
|
|
12
9
|
flex-direction: column;
|
|
@@ -35,7 +32,4 @@
|
|
|
35
32
|
content: "*";
|
|
36
33
|
margin-left: calc(var(--g-spacing-base) * 1);
|
|
37
34
|
color: var(--g-color-text-danger);
|
|
38
|
-
}
|
|
39
|
-
.sr-card__copy-button {
|
|
40
|
-
display: none;
|
|
41
35
|
}
|
|
@@ -13,7 +13,7 @@ const b = (0, utils_1.block)('card');
|
|
|
13
13
|
const Card = ({ children, headName, input, meta, mode, schema, props, }) => {
|
|
14
14
|
var _a;
|
|
15
15
|
const { descriptionType = 'tooltip', likeAccordeon = true } = props, restLayoutProps = tslib_1.__rest(props, ["descriptionType", "likeAccordeon"]);
|
|
16
|
-
const {
|
|
16
|
+
const { required, hidden, open = true } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
17
17
|
const overviewFlag = mode === core_1.SchemaRendererMode.Overview;
|
|
18
18
|
const { expanded, toggleExpanded } = (0, hooks_1.useExpanded)({
|
|
19
19
|
headName,
|
|
@@ -42,8 +42,7 @@ const Card = ({ children, headName, input, meta, mode, schema, props, }) => {
|
|
|
42
42
|
react_1.default.createElement(uikit_1.Text, { variant: "subheader-1", color: "complementary", className: b('title', { required: required && !overviewFlag }) }, schema.title),
|
|
43
43
|
tooltip),
|
|
44
44
|
react_1.default.createElement(uikit_1.Flex, { className: b('header-actions'), alignItems: "center", gap: 2 },
|
|
45
|
-
|
|
46
|
-
overviewFlag ? null : (react_1.default.createElement(components_1.ArrayRemoveButton, { name: input.name, headName: headName })),
|
|
45
|
+
react_1.default.createElement(components_1.LayoutButtons, { mode: mode, name: input.name, headName: headName, schema: schema, value: input.value }),
|
|
47
46
|
likeAccordeon ? (react_1.default.createElement(uikit_1.Flex, { width: "28px", justifyContent: "center" },
|
|
48
47
|
react_1.default.createElement(uikit_1.Button, { onClick: toggleExpanded, size: "s", view: "flat-secondary" },
|
|
49
48
|
react_1.default.createElement(uikit_1.Icon, { data: expanded ? icons_1.ChevronUp : icons_1.ChevronDown, size: 16 })))) : null)),
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
.sr-section:last-child {
|
|
5
5
|
margin-bottom: 0;
|
|
6
6
|
}
|
|
7
|
-
.sr-section:hover .sr-section__copy-button {
|
|
8
|
-
display: block;
|
|
9
|
-
}
|
|
10
7
|
.sr-section__header {
|
|
11
8
|
min-height: 28px;
|
|
12
9
|
}
|
|
@@ -28,7 +25,4 @@
|
|
|
28
25
|
position: absolute;
|
|
29
26
|
left: calc(var(--g-spacing-base) * 3 + 1.5px);
|
|
30
27
|
bottom: 0;
|
|
31
|
-
}
|
|
32
|
-
.sr-section__copy-button {
|
|
33
|
-
display: none;
|
|
34
28
|
}
|
|
@@ -11,7 +11,7 @@ const b = (0, utils_1.block)('section');
|
|
|
11
11
|
const Section = ({ children, headName, input, meta, mode, schema, props, }) => {
|
|
12
12
|
var _a;
|
|
13
13
|
const { descriptionType = 'tooltip', withIndent = false } = props, restLayoutProps = tslib_1.__rest(props, ["descriptionType", "withIndent"]);
|
|
14
|
-
const {
|
|
14
|
+
const { required, hidden } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
15
15
|
const overviewFlag = mode === core_1.SchemaRendererMode.Overview;
|
|
16
16
|
const tooltip = react_1.default.useMemo(() => {
|
|
17
17
|
if (!schema.description || descriptionType === 'bottom') {
|
|
@@ -32,8 +32,7 @@ const Section = ({ children, headName, input, meta, mode, schema, props, }) => {
|
|
|
32
32
|
react_1.default.createElement(uikit_1.Flex, { className: b('header'), gap: 2, alignItems: "center" },
|
|
33
33
|
react_1.default.createElement(uikit_1.Text, Object.assign({ variant: "subheader-1", color: "complementary" }, restLayoutProps, { className: b('title', { required: required && !overviewFlag }, restLayoutProps === null || restLayoutProps === void 0 ? void 0 : restLayoutProps.className) }), schema.title),
|
|
34
34
|
tooltip,
|
|
35
|
-
|
|
36
|
-
overviewFlag ? null : (react_1.default.createElement(components_1.ArrayRemoveButton, { name: input.name, headName: headName }))),
|
|
35
|
+
react_1.default.createElement(components_1.LayoutButtons, { mode: mode, name: input.name, headName: headName, schema: schema, value: input.value })),
|
|
37
36
|
bottomDescription),
|
|
38
37
|
react_1.default.createElement("div", { className: b('content', { 'with-indent': withIndent }) }, children)),
|
|
39
38
|
overviewFlag ? null : (react_1.default.createElement(components_1.EntityError, { errorMessage: meta.error, validationState: (0, utils_1.getValidationState)(meta) }))));
|
|
@@ -11,13 +11,12 @@ const utils_1 = require("../../utils");
|
|
|
11
11
|
const b = (0, utils_1.block)('transparent');
|
|
12
12
|
const Transparent = ({ children, headName, input, meta, mode, props, schema, }) => {
|
|
13
13
|
var _a;
|
|
14
|
-
const {
|
|
14
|
+
const { hidden } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
15
15
|
const overviewFlag = mode === core_1.SchemaRendererMode.Overview;
|
|
16
16
|
return (react_1.default.createElement(components_1.LayoutContainer, { className: b(), gap: 0.5, hideEmpty: (0, isBoolean_1.default)(props.hideEmpty) ? props.hideEmpty : overviewFlag, hidden: hidden },
|
|
17
17
|
react_1.default.createElement(uikit_1.Flex, { gap: 2 },
|
|
18
18
|
children,
|
|
19
|
-
|
|
20
|
-
overviewFlag ? (react_1.default.createElement(components_1.CopyButton, { className: b('copy-button'), copy: copy, value: input.value })) : null),
|
|
19
|
+
react_1.default.createElement(components_1.LayoutButtons, { mode: mode, name: input.name, headName: headName, schema: schema, value: input.value })),
|
|
21
20
|
overviewFlag ? null : (react_1.default.createElement(components_1.EntityError, { errorMessage: meta.error, validationState: (0, utils_1.getValidationState)(meta) }))));
|
|
22
21
|
};
|
|
23
22
|
exports.Transparent = Transparent;
|
|
@@ -7,9 +7,9 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
7
7
|
const components_1 = require("../../components");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const b = (0, utils_1.block)('overview-column');
|
|
10
|
-
const OverviewColumn = ({ children, headName, input, schema }) => {
|
|
10
|
+
const OverviewColumn = ({ children, headName, input, mode, schema, }) => {
|
|
11
11
|
var _a;
|
|
12
|
-
const {
|
|
12
|
+
const { hidden } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
13
13
|
const tooltip = react_1.default.useMemo(() => {
|
|
14
14
|
if (!schema.description) {
|
|
15
15
|
return null;
|
|
@@ -25,6 +25,6 @@ const OverviewColumn = ({ children, headName, input, schema }) => {
|
|
|
25
25
|
react_1.default.createElement(uikit_1.Flex, { className: b('bottom'), direction: "column", gap: 0.5, grow: 1 },
|
|
26
26
|
react_1.default.createElement(uikit_1.Flex, { grow: 1, gap: 2 },
|
|
27
27
|
children,
|
|
28
|
-
react_1.default.createElement(components_1.
|
|
28
|
+
react_1.default.createElement(components_1.LayoutButtons, { mode: mode, name: input.name, headName: headName, schema: schema, value: input.value })))));
|
|
29
29
|
};
|
|
30
30
|
exports.OverviewColumn = OverviewColumn;
|
|
@@ -7,9 +7,9 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
7
7
|
const components_1 = require("../../components");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const b = (0, utils_1.block)('overview-row');
|
|
10
|
-
const OverviewRow = ({ children, headName, input, schema }) => {
|
|
10
|
+
const OverviewRow = ({ children, headName, input, mode, schema }) => {
|
|
11
11
|
var _a;
|
|
12
|
-
const {
|
|
12
|
+
const { hidden } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
13
13
|
const tooltip = react_1.default.useMemo(() => {
|
|
14
14
|
if (!schema.description) {
|
|
15
15
|
return null;
|
|
@@ -25,6 +25,6 @@ const OverviewRow = ({ children, headName, input, schema }) => {
|
|
|
25
25
|
react_1.default.createElement(uikit_1.Flex, { className: b('right'), direction: "column", gap: 0.5, grow: 1 },
|
|
26
26
|
react_1.default.createElement(uikit_1.Flex, { grow: 1, gap: 2 },
|
|
27
27
|
children,
|
|
28
|
-
react_1.default.createElement(components_1.
|
|
28
|
+
react_1.default.createElement(components_1.LayoutButtons, { mode: mode, name: input.name, headName: headName, schema: schema, value: input.value })))));
|
|
29
29
|
};
|
|
30
30
|
exports.OverviewRow = OverviewRow;
|
|
@@ -2,12 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { TrashBin } from '@gravity-ui/icons';
|
|
3
3
|
import { Button, Icon } from '@gravity-ui/uikit';
|
|
4
4
|
import { useForm } from 'react-final-form';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { SchemaRendererMode } from '../../../core';
|
|
6
|
+
import { block, getArrayItemIndex, getArrayItemParentName, isArrayItem, isTupleItem, } from '../../utils';
|
|
7
|
+
const b = block('array-remove-button');
|
|
8
|
+
export const ArrayRemoveButton = ({ mode, name, headName, onClick, }) => {
|
|
7
9
|
const form = useForm();
|
|
8
|
-
const [ready, setReady] = React.useState(false);
|
|
9
10
|
const arrayItem = isArrayItem(name);
|
|
10
11
|
const tupleItem = isTupleItem(name, headName, form);
|
|
12
|
+
const overviewFlag = mode === SchemaRendererMode.Overview;
|
|
11
13
|
const removeItem = React.useCallback((event) => {
|
|
12
14
|
var _a;
|
|
13
15
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
@@ -20,11 +22,8 @@ export const ArrayRemoveButton = ({ name, headName, onClick }) => {
|
|
|
20
22
|
form.blur(parentName);
|
|
21
23
|
}
|
|
22
24
|
}, [form, name, onClick]);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, []);
|
|
26
|
-
if (ready && arrayItem && !tupleItem) {
|
|
27
|
-
return (React.createElement(Button, { view: "flat-secondary", onClick: removeItem, qa: `${name}-remove-button` },
|
|
25
|
+
if (arrayItem && !tupleItem && !overviewFlag) {
|
|
26
|
+
return (React.createElement(Button, { className: b(), view: "flat-secondary", onClick: removeItem, qa: `${name}-remove-button` },
|
|
28
27
|
React.createElement(Icon, { data: TrashBin, size: 16 })));
|
|
29
28
|
}
|
|
30
29
|
return null;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type JsonSchema, SchemaRendererMode } from '../../../core';
|
|
2
3
|
import './CopyButton.css';
|
|
3
4
|
export interface CopyButtonProps {
|
|
4
5
|
className?: string;
|
|
5
|
-
|
|
6
|
+
mode: SchemaRendererMode;
|
|
7
|
+
schema: JsonSchema;
|
|
6
8
|
value: unknown;
|
|
7
9
|
}
|
|
8
10
|
export declare const CopyButton: React.FC<CopyButtonProps>;
|
|
@@ -2,11 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import { ClipboardButton } from '@gravity-ui/uikit';
|
|
3
3
|
import isNumber from 'lodash/isNumber';
|
|
4
4
|
import isString from 'lodash/isString';
|
|
5
|
+
import { SchemaRendererMode } from '../../../core';
|
|
5
6
|
import { block } from '../../utils';
|
|
6
7
|
import './CopyButton.css';
|
|
7
8
|
const b = block('copy-button');
|
|
8
|
-
export const CopyButton = ({ className,
|
|
9
|
-
|
|
9
|
+
export const CopyButton = ({ className, mode, schema, value }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { copy } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
12
|
+
const overviewFlag = mode === SchemaRendererMode.Overview;
|
|
13
|
+
if (copy && (isString(value) || isNumber(value)) && overviewFlag) {
|
|
10
14
|
return (React.createElement("div", { className: b(null, className) },
|
|
11
15
|
React.createElement(ClipboardButton, { text: String(value), view: "flat", size: "s" })));
|
|
12
16
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FieldValue, type JsonSchema, SchemaRendererMode } from '../../../core';
|
|
3
|
+
import './DropButton.css';
|
|
4
|
+
export interface DropButtonProps {
|
|
5
|
+
mode: SchemaRendererMode;
|
|
6
|
+
name: string;
|
|
7
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
8
|
+
schema?: JsonSchema;
|
|
9
|
+
value: FieldValue;
|
|
10
|
+
}
|
|
11
|
+
export declare const DropButton: React.FC<DropButtonProps>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { unstable_Menu as Menu, unstable_MenuItem as MenuItem, unstable_MenuTrigger as MenuTrigger, } from '@gravity-ui/uikit/unstable';
|
|
3
|
+
import { useForm } from 'react-final-form';
|
|
4
|
+
import i18n from '../../../../kit/i18n';
|
|
5
|
+
import { SchemaRendererMode } from '../../../core';
|
|
6
|
+
import { block, isArrayItem } from '../../utils';
|
|
7
|
+
import './DropButton.css';
|
|
8
|
+
const b = block('drop-button');
|
|
9
|
+
export const DropButton = ({ mode, name, onClick, schema, value }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const form = useForm();
|
|
12
|
+
const [open, setOpen] = React.useState(false);
|
|
13
|
+
const { required } = ((_a = schema === null || schema === void 0 ? void 0 : schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
14
|
+
const arrayItem = isArrayItem(name);
|
|
15
|
+
const overviewFlag = mode === SchemaRendererMode.Overview;
|
|
16
|
+
const removeItem = React.useCallback((event) => {
|
|
17
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
18
|
+
form.focus(name);
|
|
19
|
+
form.change(name, undefined);
|
|
20
|
+
form.blur(name);
|
|
21
|
+
}, [form, name, onClick]);
|
|
22
|
+
if (!required && value !== undefined && !arrayItem && !overviewFlag) {
|
|
23
|
+
return (React.createElement("div", { className: b({ open }) },
|
|
24
|
+
React.createElement(Menu, { trigger: React.createElement(MenuTrigger, { view: "flat-secondary" }), onOpenChange: setOpen, placement: "right" },
|
|
25
|
+
React.createElement(MenuItem, { theme: "danger", onClick: removeItem }, i18n('label_delete')))));
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropButton, type DropButtonProps } from './DropButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropButton } from './DropButton';
|
|
@@ -3,6 +3,7 @@ import { type FlexProps } from '@gravity-ui/uikit';
|
|
|
3
3
|
import './EntityContainer.css';
|
|
4
4
|
export interface EntityContainerProps extends FlexProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
+
droppable?: boolean;
|
|
6
7
|
fill?: 'populated' | 'empty' | 'by-child';
|
|
7
8
|
ref?: React.ComponentPropsWithRef<'div'>['ref'];
|
|
8
9
|
stretch: 'max' | 'fit' | 'by-child';
|
|
@@ -5,7 +5,7 @@ import { block } from '../../utils';
|
|
|
5
5
|
import './EntityContainer.css';
|
|
6
6
|
const b = block('entity-container');
|
|
7
7
|
export const EntityContainer = (_a) => {
|
|
8
|
-
var { children, fill, stretch } = _a, restFlexProps = __rest(_a, ["children", "fill", "stretch"]);
|
|
9
|
-
return (React.createElement("div", { className: b({ stretch }), "data-
|
|
8
|
+
var { children, droppable, fill, stretch } = _a, restFlexProps = __rest(_a, ["children", "droppable", "fill", "stretch"]);
|
|
9
|
+
return (React.createElement("div", { className: b({ stretch }), "data-fill": fill, "data-droppable": droppable, "data-stretch": stretch },
|
|
10
10
|
React.createElement(Flex, Object.assign({ direction: "column", minWidth: 0 }, restFlexProps, { grow: 1 }), children)));
|
|
11
11
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FieldValue, JsonSchema, SchemaRendererMode } from '../../../core';
|
|
3
|
+
export interface LayoutButtonsProps {
|
|
4
|
+
name: string;
|
|
5
|
+
headName: string;
|
|
6
|
+
mode: SchemaRendererMode;
|
|
7
|
+
schema: JsonSchema;
|
|
8
|
+
value: FieldValue;
|
|
9
|
+
}
|
|
10
|
+
export declare const LayoutButtons: React.FC<LayoutButtonsProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArrayRemoveButton } from '../ArrayRemoveButton';
|
|
3
|
+
import { CopyButton } from '../CopyButton';
|
|
4
|
+
import { DropButton } from '../DropButton';
|
|
5
|
+
export const LayoutButtons = ({ mode, name, headName, schema, value, }) => {
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(ArrayRemoveButton, { mode: mode, name: name, headName: headName }),
|
|
8
|
+
React.createElement(CopyButton, { mode: mode, schema: schema, value: value }),
|
|
9
|
+
React.createElement(DropButton, { mode: mode, name: name, schema: schema, value: value })));
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LayoutButtons, type LayoutButtonsProps } from './LayoutButtons';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LayoutButtons } from './LayoutButtons';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
.sr-layout-container {
|
|
2
|
+
max-width: 100%;
|
|
3
|
+
min-width: 0;
|
|
2
4
|
width: fit-content;
|
|
3
|
-
flex: 0
|
|
5
|
+
flex: 0 1 auto;
|
|
4
6
|
}
|
|
5
7
|
.sr-layout-container:has([data-stretch=max]) {
|
|
6
8
|
width: 100%;
|
|
@@ -11,4 +13,31 @@
|
|
|
11
13
|
}
|
|
12
14
|
.sr-layout-container_hidden {
|
|
13
15
|
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@scope (.sr-layout-container) to (.sr-layout-container) {
|
|
19
|
+
:scope:has([data-droppable=true]:not(:scope .sr-layout-container *)) .sr-drop-button {
|
|
20
|
+
display: block;
|
|
21
|
+
}
|
|
22
|
+
:scope:has(.sr-drop-button:not(:scope .sr-layout-container *):hover),
|
|
23
|
+
:scope:has(.sr-drop-button_open:not(:scope .sr-layout-container *)),
|
|
24
|
+
:scope:has(.sr-array-remove-button:not(:scope .sr-layout-container *):hover) {
|
|
25
|
+
position: relative;
|
|
26
|
+
}
|
|
27
|
+
:scope:has(.sr-drop-button:not(:scope .sr-layout-container *):hover):before,
|
|
28
|
+
:scope:has(.sr-drop-button_open:not(:scope .sr-layout-container *)):before,
|
|
29
|
+
:scope:has(.sr-array-remove-button:not(:scope .sr-layout-container *):hover):before {
|
|
30
|
+
content: "";
|
|
31
|
+
z-index: -1;
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: -8px;
|
|
34
|
+
left: -8px;
|
|
35
|
+
width: calc(100% + 16px);
|
|
36
|
+
height: calc(100% + 16px);
|
|
37
|
+
background-color: var(--g-color-base-simple-hover);
|
|
38
|
+
border-radius: 6px;
|
|
39
|
+
}
|
|
40
|
+
:scope:hover .sr-copy-button {
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
14
43
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { ArrayRemoveButton, type ArrayRemoveButtonProps } from './ArrayRemoveButton';
|
|
2
2
|
export { CopyButton, type CopyButtonProps } from './CopyButton';
|
|
3
|
+
export { DropButton, type DropButtonProps } from './DropButton';
|
|
3
4
|
export { EmptyEntityValue } from './EmptyEntityValue';
|
|
4
5
|
export { EntityContainer, type EntityContainerProps } from './EntityContainer';
|
|
5
6
|
export { EntityError, type EntityErrorProps } from './EntityError';
|
|
6
7
|
export { HTMLContent, type HTMLContentProps } from './HTMLContent';
|
|
7
8
|
export { LayoutContainer, type LayoutContainerProps } from './LayoutContainer';
|
|
9
|
+
export { LayoutButtons, type LayoutButtonsProps } from './LayoutButtons';
|
|
8
10
|
export { LongValue, type LongValueProps } from './LongValue';
|
|
9
11
|
export { MonacoContainer, type MonacoContainerProps } from './MonacoContainer';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { ArrayRemoveButton } from './ArrayRemoveButton';
|
|
2
2
|
export { CopyButton } from './CopyButton';
|
|
3
|
+
export { DropButton } from './DropButton';
|
|
3
4
|
export { EmptyEntityValue } from './EmptyEntityValue';
|
|
4
5
|
export { EntityContainer } from './EntityContainer';
|
|
5
6
|
export { EntityError } from './EntityError';
|
|
6
7
|
export { HTMLContent } from './HTMLContent';
|
|
7
8
|
export { LayoutContainer } from './LayoutContainer';
|
|
9
|
+
export { LayoutButtons } from './LayoutButtons';
|
|
8
10
|
export { LongValue } from './LongValue';
|
|
9
11
|
export { MonacoContainer } from './MonacoContainer';
|
|
@@ -9,8 +9,37 @@ const b = block('array-entity');
|
|
|
9
9
|
export const ArrayEntity = ({ headName, input, mode, props, schema, schemaPath, }) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const { name, onBlur, onChange, onFocus, value } = input;
|
|
12
|
-
const { disabled } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
12
|
+
const { disabled, required } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
|
|
13
13
|
const overviewFlag = mode === SchemaRendererMode.Overview;
|
|
14
|
+
const initButton = React.useMemo(() => {
|
|
15
|
+
if (required || value !== undefined || overviewFlag) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const itemsSchema = schema.items;
|
|
19
|
+
const initValue = Array.isArray(itemsSchema)
|
|
20
|
+
? itemsSchema.map(() => undefined)
|
|
21
|
+
: [undefined];
|
|
22
|
+
const onClick = () => {
|
|
23
|
+
onFocus();
|
|
24
|
+
onChange(initValue);
|
|
25
|
+
onBlur();
|
|
26
|
+
};
|
|
27
|
+
return (React.createElement(Button, { className: b('init-button'), onClick: onClick, disabled: disabled || schema.readOnly, qa: `${name}-init-button` },
|
|
28
|
+
React.createElement(Icon, { data: Plus, size: 14 }),
|
|
29
|
+
props.addButtonText || null));
|
|
30
|
+
}, [
|
|
31
|
+
props.addButtonText,
|
|
32
|
+
disabled,
|
|
33
|
+
name,
|
|
34
|
+
onBlur,
|
|
35
|
+
onChange,
|
|
36
|
+
onFocus,
|
|
37
|
+
overviewFlag,
|
|
38
|
+
required,
|
|
39
|
+
schema.items,
|
|
40
|
+
schema.readOnly,
|
|
41
|
+
value,
|
|
42
|
+
]);
|
|
14
43
|
const addButton = React.useMemo(() => {
|
|
15
44
|
const itemsSchema = schema.items;
|
|
16
45
|
if (Array.isArray(itemsSchema) || overviewFlag) {
|
|
@@ -18,7 +47,7 @@ export const ArrayEntity = ({ headName, input, mode, props, schema, schemaPath,
|
|
|
18
47
|
}
|
|
19
48
|
const onClick = () => {
|
|
20
49
|
onFocus();
|
|
21
|
-
onChange([...(value || []),
|
|
50
|
+
onChange([...(value || []), undefined]);
|
|
22
51
|
onBlur();
|
|
23
52
|
};
|
|
24
53
|
return (React.createElement(Button, { className: b('add-button'), onClick: onClick, disabled: disabled || schema.readOnly, qa: `${name}-add-button` },
|
|
@@ -49,7 +78,7 @@ export const ArrayEntity = ({ headName, input, mode, props, schema, schemaPath,
|
|
|
49
78
|
if (overviewFlag && !(value === null || value === void 0 ? void 0 : value.length)) {
|
|
50
79
|
return React.createElement(EmptyEntityValue, null);
|
|
51
80
|
}
|
|
52
|
-
return (React.createElement(EntityContainer, { stretch: "by-child", gap: 4, fill: "by-child" },
|
|
81
|
+
return (React.createElement(EntityContainer, { stretch: "by-child", gap: 4, fill: "by-child", droppable: true }, initButton ? (initButton) : (React.createElement(React.Fragment, null,
|
|
53
82
|
(items === null || items === void 0 ? void 0 : items.length) ? React.createElement(Flex, { direction: "column" }, items) : null,
|
|
54
|
-
addButton));
|
|
83
|
+
addButton))));
|
|
55
84
|
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
.sr-array-table__row-divider {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: calc(var(--g-spacing-base) * 5 + 1px);
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
.sr-array-table__row-divider::before {
|
|
8
|
+
content: "";
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 1px;
|
|
11
|
+
background-color: var(--g-color-line-generic);
|
|
12
|
+
}
|
|
1
13
|
.sr-array-table__row {
|
|
2
14
|
width: 100%;
|
|
3
15
|
display: grid;
|
|
4
16
|
align-items: start;
|
|
5
17
|
grid-template-columns: 28px repeat(var(--columns-count), 1fr);
|
|
6
18
|
gap: calc(var(--g-spacing-base) * 3);
|
|
7
|
-
padding: calc(var(--g-spacing-base) * 2) 0;
|
|
8
|
-
border-bottom: 1px solid var(--g-color-line-generic);
|
|
9
19
|
}
|
|
10
20
|
.sr-array-table__row_head {
|
|
11
21
|
align-items: center;
|
|
@@ -40,6 +50,6 @@
|
|
|
40
50
|
gap: 0 calc(var(--g-spacing-base) * 1);
|
|
41
51
|
flex-wrap: wrap;
|
|
42
52
|
}
|
|
43
|
-
.sr-array-table__add-button {
|
|
53
|
+
.sr-array-table__add-button, .sr-array-table__init-button {
|
|
44
54
|
align-self: flex-start;
|
|
45
55
|
}
|