@gravity-ui/dynamic-forms 4.16.1 → 4.17.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/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Accordeon/Accordeon.js +2 -1
- package/build/cjs/lib/kit/components/Layouts/Section/Section.js +21 -2
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -1
- package/build/cjs/lib/kit/utils/common.js +6 -2
- package/build/esm/lib/core/components/View/types/layout.d.ts +1 -1
- package/build/esm/lib/core/components/View/types/views.d.ts +1 -1
- package/build/esm/lib/core/types/specs.d.ts +2 -1
- package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.d.ts +6 -1
- package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.js +2 -1
- package/build/esm/lib/kit/components/Layouts/Section/Section.js +21 -2
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.d.ts +2 -0
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.d.ts +7 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -1
- package/build/esm/lib/kit/utils/common.js +6 -2
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ const TextContentComponent = ({ spec, value, Layout, }) => {
|
|
|
25
25
|
: undefined;
|
|
26
26
|
content = (react_1.default.createElement(uikit_1.Alert, { icon: iconLib, message: content,
|
|
27
27
|
// If the title is an empty line, then you need to explicitly write undefined, otherwise there will be an additional indent
|
|
28
|
-
title: titleAlert, theme: textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert }));
|
|
28
|
+
title: titleAlert, theme: textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert, view: textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.viewAlert }));
|
|
29
29
|
}
|
|
30
30
|
else if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeLabel) {
|
|
31
31
|
content = (react_1.default.createElement(uikit_1.Label, { size: "m", theme: textContentParams.themeLabel, className: b(), value: value, icon: iconLib }, content));
|
|
@@ -10,6 +10,7 @@ const RemoveButton_1 = require("../../RemoveButton");
|
|
|
10
10
|
const SimpleVerticalAccordeon_1 = require("../../SimpleVerticalAccordeon");
|
|
11
11
|
const Accordeon = ({ name, spec, input, meta, children, }) => {
|
|
12
12
|
var _a;
|
|
13
|
+
const { variantTitle } = spec.viewSpec.layoutProps || {};
|
|
13
14
|
const [open, setOpen] = react_1.default.useState(Boolean((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen));
|
|
14
15
|
const onDrop = react_1.default.useCallback(() => {
|
|
15
16
|
setOpen(false);
|
|
@@ -22,7 +23,7 @@ const Accordeon = ({ name, spec, input, meta, children, }) => {
|
|
|
22
23
|
return react_1.default.createElement(RemoveButton_1.RemoveButton, { name: name, onDrop: onDrop });
|
|
23
24
|
}, [spec.required, input.value, onDrop, name]);
|
|
24
25
|
(0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
|
|
25
|
-
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 },
|
|
26
|
+
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, variantTitle: variantTitle },
|
|
26
27
|
react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
27
28
|
};
|
|
28
29
|
exports.Accordeon = Accordeon;
|
|
@@ -19,6 +19,25 @@ const SectionBase = (_a) => {
|
|
|
19
19
|
const arrOrObjFlag = (0, core_1.isArraySpec)(spec) || (0, core_1.isObjectSpec)(spec);
|
|
20
20
|
const titleRef = react_1.default.useRef(null);
|
|
21
21
|
let content = children;
|
|
22
|
+
const { variantTitle: variantTitleProp } = spec.viewSpec.layoutProps || {};
|
|
23
|
+
const { sizeTitle, variantTitle } = react_1.default.useMemo(() => {
|
|
24
|
+
if (variantTitleProp) {
|
|
25
|
+
return {
|
|
26
|
+
sizeTitle: undefined,
|
|
27
|
+
variantTitle: variantTitleProp,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (titleSize === 'm') {
|
|
31
|
+
return {
|
|
32
|
+
sizeTitle: titleSize,
|
|
33
|
+
variantTitle: 'body-2',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
sizeTitle: titleSize,
|
|
38
|
+
variantTitle: 'body-1',
|
|
39
|
+
};
|
|
40
|
+
}, [variantTitleProp, titleSize]);
|
|
22
41
|
const removeButton = react_1.default.useMemo(() => {
|
|
23
42
|
if ((input === null || input === void 0 ? void 0 : input.value) && (input === null || input === void 0 ? void 0 : input.onDrop) && (0, core_1.isArrayItem)(name)) {
|
|
24
43
|
return (react_1.default.createElement(RemoveButton_1.RemoveButton, { name: name, onDrop: input.onDrop, switcherClassName: b('remove-button') }));
|
|
@@ -48,10 +67,10 @@ const SectionBase = (_a) => {
|
|
|
48
67
|
return (react_1.default.createElement("section", { className: b() },
|
|
49
68
|
layoutTitle ? (react_1.default.createElement("div", { className: b('header', {
|
|
50
69
|
'with-popover': !descriptionAsSubtitle,
|
|
51
|
-
size:
|
|
70
|
+
size: sizeTitle,
|
|
52
71
|
}) },
|
|
53
72
|
react_1.default.createElement(uikit_1.Popover, { className: b('title-popover'), content: layoutTitle, placement: __2.COMMON_POPOVER_PLACEMENT, disabled: layoutTitlePopoverDisabled },
|
|
54
|
-
react_1.default.createElement(uikit_1.Text, { className: b('title'), variant:
|
|
73
|
+
react_1.default.createElement(uikit_1.Text, { className: b('title'), variant: variantTitle, ref: titleRef, ellipsis: true }, layoutTitle)),
|
|
55
74
|
description,
|
|
56
75
|
removeButton)) : null,
|
|
57
76
|
react_1.default.createElement("div", { className: b('content') }, content)));
|
|
@@ -52,7 +52,7 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
52
52
|
}
|
|
53
53
|
render() {
|
|
54
54
|
var _a;
|
|
55
|
-
const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
|
|
55
|
+
const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, variantTitle, } = this.props;
|
|
56
56
|
const { open, hidden, isFirstRender } = this.state;
|
|
57
57
|
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)));
|
|
58
58
|
if (viewLayout && !isFirstRender && hidden) {
|
|
@@ -60,7 +60,7 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
60
60
|
}
|
|
61
61
|
const title = this.getTitle();
|
|
62
62
|
const titlePopoverDisabled = (((_a = this.titleRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0) <= TITLE_TEXT_MAX_WIDTH;
|
|
63
|
-
const currentTitleVariant = this.getCurrentTitleVariant();
|
|
63
|
+
const currentTitleVariant = variantTitle || this.getCurrentTitleVariant();
|
|
64
64
|
return (Boolean(react_1.default.Children.count(children)) && (react_1.default.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
|
|
65
65
|
react_1.default.createElement("div", { className: b('header') },
|
|
66
66
|
react_1.default.createElement(uikit_1.Popover, { content: title, disabled: titlePopoverDisabled, placement: common_1.COMMON_POPOVER_PLACEMENT },
|
|
@@ -10,11 +10,12 @@ const SimpleVerticalAccordeon_1 = require("../../SimpleVerticalAccordeon");
|
|
|
10
10
|
const ViewAccordeon = ({ name, value, spec, children, }) => {
|
|
11
11
|
const { showLayoutDescription } = (0, core_1.useDynamicFormsCtx)();
|
|
12
12
|
const [open, setOpen] = react_1.default.useState((0, isBoolean_1.default)(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true);
|
|
13
|
+
const { variantTitle } = spec.viewSpec.layoutProps || {};
|
|
13
14
|
if (!(0, utils_1.isNotEmptyValue)(value, spec)) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
return (react_1.default.createElement(SimpleVerticalAccordeon_1.SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', note: showLayoutDescription && spec.viewSpec.layoutDescription
|
|
17
18
|
? spec.viewSpec.layoutDescription
|
|
18
|
-
: undefined, open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true }, children));
|
|
19
|
+
: undefined, open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true, variantTitle: variantTitle }, children));
|
|
19
20
|
};
|
|
20
21
|
exports.ViewAccordeon = ViewAccordeon;
|
|
@@ -42,7 +42,7 @@ const isNotEmptyValue = (value, spec) => {
|
|
|
42
42
|
};
|
|
43
43
|
exports.isNotEmptyValue = isNotEmptyValue;
|
|
44
44
|
const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
45
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
46
46
|
if ((0, isObjectLike_1.default)(spec)) {
|
|
47
47
|
const result = (0, cloneDeep_1.default)(spec);
|
|
48
48
|
if ((0, isString_1.default)(result.type)) {
|
|
@@ -54,7 +54,7 @@ const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
|
54
54
|
try {
|
|
55
55
|
_defaultValue = JSON.parse(result.defaultValue);
|
|
56
56
|
}
|
|
57
|
-
catch (
|
|
57
|
+
catch (_m) {
|
|
58
58
|
_defaultValue = undefined;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -86,6 +86,10 @@ const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
|
86
86
|
result.viewSpec.textContentParams.themeAlert =
|
|
87
87
|
result.viewSpec.textContentParams.themeAlert.toLowerCase();
|
|
88
88
|
}
|
|
89
|
+
if ((0, isString_1.default)((_l = (_k = result.viewSpec) === null || _k === void 0 ? void 0 : _k.textContentParams) === null || _l === void 0 ? void 0 : _l.viewAlert)) {
|
|
90
|
+
result.viewSpec.textContentParams.viewAlert =
|
|
91
|
+
result.viewSpec.textContentParams.viewAlert.toLowerCase();
|
|
92
|
+
}
|
|
89
93
|
if ((0, isString_1.default)(result.validator)) {
|
|
90
94
|
result.validator = result.validator.toLowerCase();
|
|
91
95
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormValue, Spec } from '../../../';
|
|
3
3
|
import { ViewProps } from './';
|
|
4
|
-
export type ViewLayoutProps<Value extends FormValue, SpecType extends Spec> = {
|
|
4
|
+
export type ViewLayoutProps<Value extends FormValue, SpecType extends Spec<undefined, undefined, Record<string, any> | undefined> = Spec> = {
|
|
5
5
|
children: React.ReactElement;
|
|
6
6
|
} & ViewProps<Value, SpecType>;
|
|
7
7
|
export type ViewLayoutType<Value extends FormValue, SpecType extends Spec> = (props: ViewLayoutProps<Value, SpecType>) => React.ReactElement | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormValue, Spec } from '../../../';
|
|
3
3
|
import { ViewLayoutType } from './';
|
|
4
|
-
export type ViewProps<Value extends FormValue, SpecType extends Spec> = {
|
|
4
|
+
export type ViewProps<Value extends FormValue, SpecType extends Spec<undefined, undefined, Record<string, any> | undefined> = Spec> = {
|
|
5
5
|
spec: SpecType;
|
|
6
6
|
name: string;
|
|
7
7
|
value?: Value;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlertProps, LabelProps } from '@gravity-ui/uikit';
|
|
1
|
+
import type { AlertProps, LabelProps } from '@gravity-ui/uikit';
|
|
2
2
|
import { ColorTextBaseProps } from '@gravity-ui/uikit/build/esm/components/Text/colorText/colorText';
|
|
3
3
|
import { ReadAsMethod, SpecTypes } from '../constants';
|
|
4
4
|
import { ArrayValue, ObjectValue } from './';
|
|
@@ -151,6 +151,7 @@ export interface StringSpec<LinkType = any, InputComponentProps extends Record<s
|
|
|
151
151
|
iconColor?: ColorTextBaseProps['color'];
|
|
152
152
|
titleAlert?: string;
|
|
153
153
|
themeAlert?: AlertProps['theme'];
|
|
154
|
+
viewAlert?: AlertProps['view'];
|
|
154
155
|
};
|
|
155
156
|
fileInput?: {
|
|
156
157
|
accept?: string;
|
|
@@ -22,7 +22,7 @@ export const TextContentComponent = ({ spec, value, Layout, }) => {
|
|
|
22
22
|
: undefined;
|
|
23
23
|
content = (React.createElement(Alert, { icon: iconLib, message: content,
|
|
24
24
|
// If the title is an empty line, then you need to explicitly write undefined, otherwise there will be an additional indent
|
|
25
|
-
title: titleAlert, theme: textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert }));
|
|
25
|
+
title: titleAlert, theme: textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert, view: textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.viewAlert }));
|
|
26
26
|
}
|
|
27
27
|
else if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeLabel) {
|
|
28
28
|
content = (React.createElement(Label, { size: "m", theme: textContentParams.themeLabel, className: b(), value: value, icon: iconLib }, content));
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import { TextProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { ArrayLayoutProps, ObjectLayoutProps } from '../../../../core';
|
|
2
|
-
|
|
3
|
+
interface AccordeonLayoutProps {
|
|
4
|
+
variantTitle?: TextProps['variant'];
|
|
5
|
+
}
|
|
6
|
+
export declare const Accordeon: <T extends ArrayLayoutProps<Record<string, any> | undefined, AccordeonLayoutProps | undefined> | ObjectLayoutProps<Record<string, any> | undefined, AccordeonLayoutProps | undefined>>({ name, spec, input, meta, children, }: T) => JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -6,6 +6,7 @@ import { RemoveButton } from '../../RemoveButton';
|
|
|
6
6
|
import { SimpleVerticalAccordeon } from '../../SimpleVerticalAccordeon';
|
|
7
7
|
export const Accordeon = ({ name, spec, input, meta, children, }) => {
|
|
8
8
|
var _a;
|
|
9
|
+
const { variantTitle } = spec.viewSpec.layoutProps || {};
|
|
9
10
|
const [open, setOpen] = React.useState(Boolean((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen));
|
|
10
11
|
const onDrop = React.useCallback(() => {
|
|
11
12
|
setOpen(false);
|
|
@@ -18,6 +19,6 @@ export const Accordeon = ({ name, spec, input, meta, children, }) => {
|
|
|
18
19
|
return React.createElement(RemoveButton, { name: name, onDrop: onDrop });
|
|
19
20
|
}, [spec.required, input.value, onDrop, name]);
|
|
20
21
|
useErrorChecker({ name, meta, open, setOpen });
|
|
21
|
-
return (React.createElement(SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', note: spec.viewSpec.layoutDescription || '', open: open, onOpenChange: setOpen, headerActionsTemplate: removeButton, hideInsteadOfDestroy: true, withBranchView: true },
|
|
22
|
+
return (React.createElement(SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', note: spec.viewSpec.layoutDescription || '', open: open, onOpenChange: setOpen, headerActionsTemplate: removeButton, hideInsteadOfDestroy: true, withBranchView: true, variantTitle: variantTitle },
|
|
22
23
|
React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
23
24
|
};
|
|
@@ -17,6 +17,25 @@ const SectionBase = (_a) => {
|
|
|
17
17
|
const arrOrObjFlag = isArraySpec(spec) || isObjectSpec(spec);
|
|
18
18
|
const titleRef = React.useRef(null);
|
|
19
19
|
let content = children;
|
|
20
|
+
const { variantTitle: variantTitleProp } = spec.viewSpec.layoutProps || {};
|
|
21
|
+
const { sizeTitle, variantTitle } = React.useMemo(() => {
|
|
22
|
+
if (variantTitleProp) {
|
|
23
|
+
return {
|
|
24
|
+
sizeTitle: undefined,
|
|
25
|
+
variantTitle: variantTitleProp,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (titleSize === 'm') {
|
|
29
|
+
return {
|
|
30
|
+
sizeTitle: titleSize,
|
|
31
|
+
variantTitle: 'body-2',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
sizeTitle: titleSize,
|
|
36
|
+
variantTitle: 'body-1',
|
|
37
|
+
};
|
|
38
|
+
}, [variantTitleProp, titleSize]);
|
|
20
39
|
const removeButton = React.useMemo(() => {
|
|
21
40
|
if ((input === null || input === void 0 ? void 0 : input.value) && (input === null || input === void 0 ? void 0 : input.onDrop) && isArrayItem(name)) {
|
|
22
41
|
return (React.createElement(RemoveButton, { name: name, onDrop: input.onDrop, switcherClassName: b('remove-button') }));
|
|
@@ -46,10 +65,10 @@ const SectionBase = (_a) => {
|
|
|
46
65
|
return (React.createElement("section", { className: b() },
|
|
47
66
|
layoutTitle ? (React.createElement("div", { className: b('header', {
|
|
48
67
|
'with-popover': !descriptionAsSubtitle,
|
|
49
|
-
size:
|
|
68
|
+
size: sizeTitle,
|
|
50
69
|
}) },
|
|
51
70
|
React.createElement(Popover, { className: b('title-popover'), content: layoutTitle, placement: COMMON_POPOVER_PLACEMENT, disabled: layoutTitlePopoverDisabled },
|
|
52
|
-
React.createElement(Text, { className: b('title'), variant:
|
|
71
|
+
React.createElement(Text, { className: b('title'), variant: variantTitle, ref: titleRef, ellipsis: true }, layoutTitle)),
|
|
53
72
|
description,
|
|
54
73
|
removeButton)) : null,
|
|
55
74
|
React.createElement("div", { className: b('content') }, content)));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TextProps } from '@gravity-ui/uikit';
|
|
2
3
|
import './SimpleVerticalAccordeon.css';
|
|
3
4
|
interface SimpleVerticalAccordeonProps {
|
|
4
5
|
children: React.ReactNode;
|
|
@@ -16,6 +17,7 @@ interface SimpleVerticalAccordeonProps {
|
|
|
16
17
|
hideInsteadOfDestroy?: boolean;
|
|
17
18
|
withBranchView?: boolean;
|
|
18
19
|
viewLayout?: boolean;
|
|
20
|
+
variantTitle?: TextProps['variant'];
|
|
19
21
|
}
|
|
20
22
|
interface SimpleVerticalAccordeonState {
|
|
21
23
|
open: boolean;
|
|
@@ -49,7 +49,7 @@ export class SimpleVerticalAccordeon extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
render() {
|
|
51
51
|
var _a;
|
|
52
|
-
const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
|
|
52
|
+
const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, variantTitle, } = this.props;
|
|
53
53
|
const { open, hidden, isFirstRender } = this.state;
|
|
54
54
|
const content = hideInsteadOfDestroy ? (React.createElement("div", { ref: this.componentRef, className: b('body', { hidden: !open }) }, children)) : (open && (React.createElement("div", { ref: this.componentRef, className: b('body', contentClassName) }, children)));
|
|
55
55
|
if (viewLayout && !isFirstRender && hidden) {
|
|
@@ -57,7 +57,7 @@ export class SimpleVerticalAccordeon extends React.Component {
|
|
|
57
57
|
}
|
|
58
58
|
const title = this.getTitle();
|
|
59
59
|
const titlePopoverDisabled = (((_a = this.titleRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0) <= TITLE_TEXT_MAX_WIDTH;
|
|
60
|
-
const currentTitleVariant = this.getCurrentTitleVariant();
|
|
60
|
+
const currentTitleVariant = variantTitle || this.getCurrentTitleVariant();
|
|
61
61
|
return (Boolean(React.Children.count(children)) && (React.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
|
|
62
62
|
React.createElement("div", { className: b('header') },
|
|
63
63
|
React.createElement(Popover, { content: title, disabled: titlePopoverDisabled, placement: COMMON_POPOVER_PLACEMENT },
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TextProps } from '@gravity-ui/uikit';
|
|
2
|
+
import { ArrayValue, ObjectValue, Spec, ViewLayoutProps } from '../../../../core';
|
|
3
|
+
interface ViewAccordeonLayoutProps {
|
|
4
|
+
variantTitle?: TextProps['variant'];
|
|
5
|
+
}
|
|
6
|
+
export declare const ViewAccordeon: <T extends ViewLayoutProps<ArrayValue | ObjectValue, Spec<any, any, ViewAccordeonLayoutProps>>>({ name, value, spec, children, }: T) => JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -6,10 +6,11 @@ import { SimpleVerticalAccordeon } from '../../SimpleVerticalAccordeon';
|
|
|
6
6
|
export const ViewAccordeon = ({ name, value, spec, children, }) => {
|
|
7
7
|
const { showLayoutDescription } = useDynamicFormsCtx();
|
|
8
8
|
const [open, setOpen] = React.useState(isBoolean(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true);
|
|
9
|
+
const { variantTitle } = spec.viewSpec.layoutProps || {};
|
|
9
10
|
if (!isNotEmptyValue(value, spec)) {
|
|
10
11
|
return null;
|
|
11
12
|
}
|
|
12
13
|
return (React.createElement(SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', note: showLayoutDescription && spec.viewSpec.layoutDescription
|
|
13
14
|
? spec.viewSpec.layoutDescription
|
|
14
|
-
: undefined, open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true }, children));
|
|
15
|
+
: undefined, open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true, variantTitle: variantTitle }, children));
|
|
15
16
|
};
|
|
@@ -37,7 +37,7 @@ export const isNotEmptyValue = (value, spec) => {
|
|
|
37
37
|
return true;
|
|
38
38
|
};
|
|
39
39
|
export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
|
|
40
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
41
41
|
if (isObjectLike(spec)) {
|
|
42
42
|
const result = cloneDeep(spec);
|
|
43
43
|
if (isString(result.type)) {
|
|
@@ -49,7 +49,7 @@ export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) =
|
|
|
49
49
|
try {
|
|
50
50
|
_defaultValue = JSON.parse(result.defaultValue);
|
|
51
51
|
}
|
|
52
|
-
catch (
|
|
52
|
+
catch (_m) {
|
|
53
53
|
_defaultValue = undefined;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -81,6 +81,10 @@ export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) =
|
|
|
81
81
|
result.viewSpec.textContentParams.themeAlert =
|
|
82
82
|
result.viewSpec.textContentParams.themeAlert.toLowerCase();
|
|
83
83
|
}
|
|
84
|
+
if (isString((_l = (_k = result.viewSpec) === null || _k === void 0 ? void 0 : _k.textContentParams) === null || _l === void 0 ? void 0 : _l.viewAlert)) {
|
|
85
|
+
result.viewSpec.textContentParams.viewAlert =
|
|
86
|
+
result.viewSpec.textContentParams.viewAlert.toLowerCase();
|
|
87
|
+
}
|
|
84
88
|
if (isString(result.validator)) {
|
|
85
89
|
result.validator = result.validator.toLowerCase();
|
|
86
90
|
}
|