@gravity-ui/dynamic-forms 5.2.0 → 5.4.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.
Files changed (43) hide show
  1. package/build/cjs/lib/kit/components/Card/Card.js +3 -1
  2. package/build/cjs/lib/kit/components/ErrorWrapper/ErrorWrapper.css +1 -1
  3. package/build/cjs/lib/kit/components/HTMLContent/HTMLContent.js +9 -0
  4. package/build/cjs/lib/kit/components/HTMLContent/index.js +4 -0
  5. package/build/cjs/lib/kit/components/Inputs/RadioGroup/RadioGroup.css +28 -0
  6. package/build/cjs/lib/kit/components/Inputs/RadioGroup/RadioGroup.js +38 -0
  7. package/build/cjs/lib/kit/components/Inputs/RadioGroup/index.js +4 -0
  8. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -1
  9. package/build/cjs/lib/kit/components/Inputs/index.js +1 -0
  10. package/build/cjs/lib/kit/components/Layouts/Column/Column.js +3 -1
  11. package/build/cjs/lib/kit/components/Layouts/Row/Row.js +3 -1
  12. package/build/cjs/lib/kit/components/Layouts/Section/Section.js +3 -1
  13. package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +3 -1
  14. package/build/cjs/lib/kit/components/TogglerCard/TogglerCard.js +3 -1
  15. package/build/cjs/lib/kit/components/ViewLayouts/ViewColumn/ViewColumn.js +3 -1
  16. package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +3 -1
  17. package/build/cjs/lib/kit/components/Views/TableArrayView/TableArrayView.js +3 -1
  18. package/build/cjs/lib/kit/constants/config.js +2 -0
  19. package/build/esm/lib/core/types/specs.d.ts +4 -0
  20. package/build/esm/lib/kit/components/Card/Card.js +3 -1
  21. package/build/esm/lib/kit/components/ErrorWrapper/ErrorWrapper.css +1 -1
  22. package/build/esm/lib/kit/components/HTMLContent/HTMLContent.d.ts +6 -0
  23. package/build/esm/lib/kit/components/HTMLContent/HTMLContent.js +4 -0
  24. package/build/esm/lib/kit/components/HTMLContent/index.d.ts +1 -0
  25. package/build/esm/lib/kit/components/HTMLContent/index.js +1 -0
  26. package/build/esm/lib/kit/components/Inputs/RadioGroup/RadioGroup.css +28 -0
  27. package/build/esm/lib/kit/components/Inputs/RadioGroup/RadioGroup.d.ts +7 -0
  28. package/build/esm/lib/kit/components/Inputs/RadioGroup/RadioGroup.js +34 -0
  29. package/build/esm/lib/kit/components/Inputs/RadioGroup/index.d.ts +1 -0
  30. package/build/esm/lib/kit/components/Inputs/RadioGroup/index.js +1 -0
  31. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -1
  32. package/build/esm/lib/kit/components/Inputs/index.d.ts +1 -0
  33. package/build/esm/lib/kit/components/Inputs/index.js +1 -0
  34. package/build/esm/lib/kit/components/Layouts/Column/Column.js +3 -1
  35. package/build/esm/lib/kit/components/Layouts/Row/Row.js +3 -1
  36. package/build/esm/lib/kit/components/Layouts/Section/Section.js +3 -1
  37. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +3 -1
  38. package/build/esm/lib/kit/components/TogglerCard/TogglerCard.js +3 -1
  39. package/build/esm/lib/kit/components/ViewLayouts/ViewColumn/ViewColumn.js +3 -1
  40. package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +3 -1
  41. package/build/esm/lib/kit/components/Views/TableArrayView/TableArrayView.js +3 -1
  42. package/build/esm/lib/kit/constants/config.js +3 -1
  43. package/package.json +2 -1
@@ -8,6 +8,7 @@ const uikit_1 = require("@gravity-ui/uikit");
8
8
  const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
9
9
  const common_1 = require("../../constants/common");
10
10
  const utils_1 = require("../../utils");
11
+ const HTMLContent_1 = require("../HTMLContent");
11
12
  const b = (0, utils_1.block)('card');
12
13
  const Card = ({ name, title: propsTitle, description, actions, open: propsOpen, onToggle, alwaysOpen, disableHeaderToggle, checkEmptyBody, children, }) => {
13
14
  var _a;
@@ -41,7 +42,8 @@ const Card = ({ name, title: propsTitle, description, actions, open: propsOpen,
41
42
  description ? (react_1.default.createElement("div", { className: b('note') },
42
43
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
43
44
  placement: common_1.COMMON_POPOVER_PLACEMENT,
44
- } }, description))) : null));
45
+ } },
46
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: description })))) : null));
45
47
  }
46
48
  return propsTitle;
47
49
  }, [propsTitle, titlePopoverDisabled, description]);
@@ -39,7 +39,7 @@
39
39
  .df-error-wrapper_error .g-text-input_view_normal:not(.df-error-wrapper-ignore) .g-text-input__content,
40
40
  .df-error-wrapper_error .yc-checkbox__indicator:not(.df-error-wrapper-ignore)::before,
41
41
  .df-error-wrapper_error .g-checkbox__indicator:not(.df-error-wrapper-ignore)::before {
42
- border-color: var(--g-color-text-danger);
42
+ border-color: var(--g-color-line-danger);
43
43
  }
44
44
  .df-error-wrapper__error-text {
45
45
  color: var(--g-color-text-danger);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTMLContent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const HTMLContent = ({ html }) => {
7
+ return react_1.default.createElement("div", { dangerouslySetInnerHTML: { __html: html } });
8
+ };
9
+ exports.HTMLContent = HTMLContent;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./HTMLContent"), exports);
@@ -0,0 +1,28 @@
1
+ /*
2
+ @mixin variables {
3
+ --g-spacing-base: 4px;
4
+
5
+ --g-spacing-0: calc(var(--g-spacing-base) * 0); //0px
6
+ --g-spacing-half: calc(var(--g-spacing-base) * 0.5); //2px
7
+ --g-spacing-1: var(--g-spacing-base); // 4px
8
+ --g-spacing-2: calc(var(--g-spacing-base) * 2); // 8px
9
+ --g-spacing-3: calc(var(--g-spacing-base) * 3); // 12px
10
+ --g-spacing-4: calc(var(--g-spacing-base) * 4); // 16px
11
+ --g-spacing-5: calc(var(--g-spacing-base) * 5); // 20px
12
+ --g-spacing-6: calc(var(--g-spacing-base) * 6); // 24px
13
+ --g-spacing-7: calc(var(--g-spacing-base) * 7); // 28px
14
+ --g-spacing-8: calc(var(--g-spacing-base) * 8); // 32px
15
+ --g-spacing-9: calc(var(--g-spacing-base) * 9); // 36px
16
+ --g-spacing-10: calc(var(--g-spacing-base) * 10); // 40px
17
+ }
18
+ */
19
+ /* Border-radius */
20
+ .df-radio-group {
21
+ align-items: center;
22
+ height: var(--df-radio-group-height, 28px);
23
+ }
24
+ .df-radio-group_vertical {
25
+ align-items: flex-start;
26
+ margin-top: var(--df-radio-group-vertical-margin-top, var(--g-spacing-2));
27
+ height: auto;
28
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RadioGroup = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const uikit_1 = require("@gravity-ui/uikit");
7
+ const utils_1 = require("../../../utils");
8
+ const b = (0, utils_1.block)('radio-group');
9
+ const RadioGroup = ({ name, input, spec, inputProps }) => {
10
+ var _a, _b, _c;
11
+ const { value, onBlur, onChange, onFocus } = input;
12
+ const { withCustomOptions, options: externalOptions } = inputProps || {};
13
+ const options = react_1.default.useMemo(() => {
14
+ var _a;
15
+ return withCustomOptions
16
+ ? externalOptions || []
17
+ : ((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.map((id) => {
18
+ var _a, _b, _c;
19
+ return ({
20
+ value: id,
21
+ content: ((_a = spec.description) === null || _a === void 0 ? void 0 : _a[id]) || id,
22
+ disabled: ((_c = (_b = spec.viewSpec.radioGroupParams) === null || _b === void 0 ? void 0 : _b.disabled) === null || _c === void 0 ? void 0 : _c[id]) || false,
23
+ });
24
+ })) || [];
25
+ }, [
26
+ withCustomOptions,
27
+ externalOptions,
28
+ spec.enum,
29
+ spec.description,
30
+ (_a = spec.viewSpec.radioGroupParams) === null || _a === void 0 ? void 0 : _a.disabled,
31
+ ]);
32
+ if (options.length === 0) {
33
+ return null;
34
+ }
35
+ return (react_1.default.createElement(uikit_1.Flex, { className: b({ vertical: ((_b = spec.viewSpec.radioGroupParams) === null || _b === void 0 ? void 0 : _b.direction) === 'vertical' }) },
36
+ react_1.default.createElement(uikit_1.RadioGroup, Object.assign({}, inputProps, { name: name, qa: name, disabled: spec.viewSpec.disabled, onUpdate: onChange, onBlur: onBlur, onFocus: onFocus, value: value, options: options, direction: ((_c = spec.viewSpec.radioGroupParams) === null || _c === void 0 ? void 0 : _c.direction) || 'horizontal' }))));
37
+ };
38
+ exports.RadioGroup = RadioGroup;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./RadioGroup"), exports);
@@ -11,6 +11,7 @@ const core_1 = require("../../../../core");
11
11
  const hooks_1 = require("../../../../core/components/Form/hooks");
12
12
  const common_1 = require("../../../constants/common");
13
13
  const utils_1 = require("../../../utils");
14
+ const HTMLContent_1 = require("../../HTMLContent");
14
15
  const b = (0, utils_1.block)('table-array');
15
16
  const TableArrayInput = ({ spec, name, arrayInput, input }) => {
16
17
  const { isHiddenField } = (0, hooks_1.useSearchContext)();
@@ -54,7 +55,8 @@ const TableArrayInput = ({ spec, name, arrayInput, input }) => {
54
55
  label,
55
56
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
56
57
  placement: common_1.COMMON_POPOVER_PLACEMENT,
57
- } }, description))),
58
+ } },
59
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: description })))),
58
60
  template: ({ key, }, idx) => {
59
61
  var _a, _b, _c;
60
62
  const entitySpec = (_a = items === null || items === void 0 ? void 0 : items.properties) === null || _a === void 0 ? void 0 : _a[property];
@@ -14,6 +14,7 @@ tslib_1.__exportStar(require("./NumberWithScale"), exports);
14
14
  tslib_1.__exportStar(require("./ObjectBase"), exports);
15
15
  tslib_1.__exportStar(require("./ObjectValueInput"), exports);
16
16
  tslib_1.__exportStar(require("./OneOf"), exports);
17
+ tslib_1.__exportStar(require("./RadioGroup"), exports);
17
18
  tslib_1.__exportStar(require("./Secret"), exports);
18
19
  tslib_1.__exportStar(require("./Select"), exports);
19
20
  tslib_1.__exportStar(require("./Switch"), exports);
@@ -9,6 +9,7 @@ const core_1 = require("../../../../core");
9
9
  const components_1 = require("../../../components");
10
10
  const common_1 = require("../../../constants/common");
11
11
  const utils_1 = require("../../../utils");
12
+ const HTMLContent_1 = require("../../HTMLContent");
12
13
  const b = (0, utils_1.block)('column');
13
14
  const ColumnBase = ({ name, spec, input, meta, children, }) => {
14
15
  const arrayItem = react_1.default.useMemo(() => (0, core_1.isArrayItem)(name), [name]);
@@ -21,7 +22,8 @@ const ColumnBase = ({ name, spec, input, meta, children, }) => {
21
22
  react_1.default.createElement(uikit_1.Text, { className: b('note-inner') },
22
23
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
23
24
  placement: common_1.COMMON_POPOVER_PLACEMENT,
24
- } }, spec.viewSpec.layoutDescription)))) : null)),
25
+ } },
26
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: spec.viewSpec.layoutDescription }))))) : null)),
25
27
  react_1.default.createElement("div", { className: b('second-row') },
26
28
  react_1.default.createElement("div", { className: b('second-row-inner') },
27
29
  react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles:
@@ -9,6 +9,7 @@ const core_1 = require("../../../../core");
9
9
  const components_1 = require("../../../components");
10
10
  const common_1 = require("../../../constants/common");
11
11
  const utils_1 = require("../../../utils");
12
+ const HTMLContent_1 = require("../../HTMLContent");
12
13
  const b = (0, utils_1.block)('row');
13
14
  const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) => {
14
15
  const arrayItem = react_1.default.useMemo(() => (0, core_1.isArrayItem)(name), [name]);
@@ -21,7 +22,8 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
21
22
  react_1.default.createElement(uikit_1.Text, { className: b('note-inner') },
22
23
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
23
24
  placement: common_1.COMMON_POPOVER_PLACEMENT,
24
- } }, spec.viewSpec.layoutDescription)))) : null)),
25
+ } },
26
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: spec.viewSpec.layoutDescription }))))) : null)),
25
27
  react_1.default.createElement("div", { className: b('right') },
26
28
  react_1.default.createElement("div", { className: b('right-inner') },
27
29
  react_1.default.createElement(components_1.ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles:
@@ -8,6 +8,7 @@ const __1 = require("../../");
8
8
  const __2 = require("../../../");
9
9
  const core_1 = require("../../../../core");
10
10
  const utils_1 = require("../../../utils");
11
+ const HTMLContent_1 = require("../../HTMLContent");
11
12
  const RemoveButton_1 = require("../../RemoveButton");
12
13
  const b = (0, utils_1.block)('section');
13
14
  const SectionBase = (_a) => {
@@ -60,7 +61,8 @@ const SectionBase = (_a) => {
60
61
  description = (react_1.default.createElement(uikit_1.Text, { className: b('note') },
61
62
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
62
63
  placement: __2.COMMON_POPOVER_PLACEMENT,
63
- } }, spec.viewSpec.layoutDescription)));
64
+ } },
65
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: spec.viewSpec.layoutDescription }))));
64
66
  }
65
67
  }
66
68
  const layoutTitle = spec.viewSpec.layoutTitle;
@@ -7,6 +7,7 @@ const icons_1 = require("@gravity-ui/icons");
7
7
  const uikit_1 = require("@gravity-ui/uikit");
8
8
  const common_1 = require("../../constants/common");
9
9
  const utils_1 = require("../../utils");
10
+ const HTMLContent_1 = require("../HTMLContent");
10
11
  const b = (0, utils_1.block)('simple-vertical-accordeon');
11
12
  const TITLE_TEXT_MAX_WIDTH = 485; /** 533px (COMMON_TITLE_MAX_WIDTH) - 48px of padding */
12
13
  class SimpleVerticalAccordeon extends react_1.default.Component {
@@ -92,7 +93,8 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
92
93
  return note ? (react_1.default.createElement(uikit_1.Text, { className: b('tooltip') },
93
94
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
94
95
  placement: common_1.COMMON_POPOVER_PLACEMENT,
95
- } }, note))) : null;
96
+ } },
97
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: note })))) : null;
96
98
  }
97
99
  }
98
100
  exports.SimpleVerticalAccordeon = SimpleVerticalAccordeon;
@@ -6,6 +6,7 @@ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const uikit_1 = require("@gravity-ui/uikit");
7
7
  const common_1 = require("../../constants/common");
8
8
  const utils_1 = require("../../utils");
9
+ const HTMLContent_1 = require("../HTMLContent");
9
10
  const b = (0, utils_1.block)('toggler-card');
10
11
  const TogglerCard = ({ description, title, text, onClick, disabled, selected, }) => {
11
12
  return (react_1.default.createElement(uikit_1.Card, { onClick: onClick, type: "selection", disabled: disabled ? !selected : disabled, selected: selected, size: "m", className: b() },
@@ -13,7 +14,8 @@ const TogglerCard = ({ description, title, text, onClick, disabled, selected, })
13
14
  react_1.default.createElement(uikit_1.Text, { variant: "subheader-2", ellipsis: true }, title),
14
15
  description ? (react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
15
16
  placement: common_1.COMMON_POPOVER_PLACEMENT,
16
- } }, description)) : null),
17
+ } },
18
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: description }))) : null),
17
19
  react_1.default.createElement(uikit_1.Text, { variant: "body-1", color: "secondary", className: b('text') }, text)));
18
20
  };
19
21
  exports.TogglerCard = TogglerCard;
@@ -8,6 +8,7 @@ const core_1 = require("../../../../core");
8
8
  const kit_1 = require("../../../../kit");
9
9
  const common_1 = require("../../../constants/common");
10
10
  const utils_1 = require("../../../utils");
11
+ const HTMLContent_1 = require("../../HTMLContent");
11
12
  const b = (0, utils_1.block)('view-column');
12
13
  const ViewColumn = ({ value, spec, children, }) => {
13
14
  const { showLayoutDescription } = (0, core_1.useDynamicFormsCtx)();
@@ -19,7 +20,8 @@ const ViewColumn = ({ value, spec, children, }) => {
19
20
  react_1.default.createElement(uikit_1.Text, { color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
20
21
  showLayoutDescription && spec.viewSpec.layoutDescription ? (react_1.default.createElement(uikit_1.HelpMark, { className: b('note'), popoverProps: {
21
22
  placement: common_1.COMMON_POPOVER_PLACEMENT,
22
- } }, spec.viewSpec.layoutDescription)) : null),
23
+ } },
24
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: spec.viewSpec.layoutDescription }))) : null),
23
25
  react_1.default.createElement("div", { className: b('second-row') }, children),
24
26
  react_1.default.createElement(kit_1.CopyButton, { spec: spec, value: value })));
25
27
  };
@@ -8,6 +8,7 @@ const core_1 = require("../../../../core");
8
8
  const kit_1 = require("../../../../kit");
9
9
  const common_1 = require("../../../constants/common");
10
10
  const utils_1 = require("../../../utils");
11
+ const HTMLContent_1 = require("../../HTMLContent");
11
12
  const b = (0, utils_1.block)('view-row');
12
13
  const ViewRow = ({ value, spec, children, }) => {
13
14
  const { showLayoutDescription } = (0, core_1.useDynamicFormsCtx)();
@@ -19,7 +20,8 @@ const ViewRow = ({ value, spec, children, }) => {
19
20
  react_1.default.createElement(uikit_1.Text, { whiteSpace: "nowrap", color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
20
21
  showLayoutDescription && spec.viewSpec.layoutDescription ? (react_1.default.createElement(uikit_1.HelpMark, { className: b('note'), popoverProps: {
21
22
  placement: common_1.COMMON_POPOVER_PLACEMENT,
22
- } }, spec.viewSpec.layoutDescription)) : null,
23
+ } },
24
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: spec.viewSpec.layoutDescription }))) : null,
23
25
  react_1.default.createElement("div", { className: b('dots') })),
24
26
  react_1.default.createElement("div", { className: b('right') }, children),
25
27
  react_1.default.createElement(kit_1.CopyButton, { spec: spec, value: value })));
@@ -7,6 +7,7 @@ const uikit_1 = require("@gravity-ui/uikit");
7
7
  const core_1 = require("../../../../core");
8
8
  const common_1 = require("../../../constants/common");
9
9
  const utils_1 = require("../../../utils");
10
+ const HTMLContent_1 = require("../../HTMLContent");
10
11
  const b = (0, utils_1.block)('table-array-view');
11
12
  const TableArrayView = ({ value = [], spec, name }) => {
12
13
  const { showLayoutDescription } = (0, core_1.useDynamicFormsCtx)();
@@ -28,7 +29,8 @@ const TableArrayView = ({ value = [], spec, name }) => {
28
29
  label,
29
30
  react_1.default.createElement(uikit_1.HelpMark, { popoverProps: {
30
31
  placement: common_1.COMMON_POPOVER_PLACEMENT,
31
- } }, description)))
32
+ } },
33
+ react_1.default.createElement(HTMLContent_1.HTMLContent, { html: description }))))
32
34
  : label,
33
35
  template: (_, idx) => {
34
36
  var _a;
@@ -104,6 +104,7 @@ exports.dynamicConfig = {
104
104
  number_with_scale: { Component: components_1.NumberWithScale },
105
105
  monaco_input: { Component: components_1.MonacoInput },
106
106
  text_content: { Component: components_1.TextContent, independent: true },
107
+ radio_group: { Component: components_1.RadioGroup },
107
108
  },
108
109
  layouts: {
109
110
  row: components_1.Row,
@@ -212,6 +213,7 @@ exports.dynamicViewConfig = {
212
213
  number_with_scale: { Component: components_1.NumberWithScaleView },
213
214
  monaco_input: { Component: components_1.MonacoView },
214
215
  text_content: { Component: components_1.TextContentView, independent: true },
216
+ radio_group: { Component: components_1.BaseView },
215
217
  },
216
218
  layouts: {
217
219
  row: components_1.ViewRow,
@@ -168,6 +168,10 @@ export interface StringSpec<LinkType = any, InputComponentProps extends Record<s
168
168
  filterPlaceholder?: string;
169
169
  meta?: Record<string, string>;
170
170
  };
171
+ radioGroupParams?: {
172
+ direction?: 'horizontal' | 'vertical';
173
+ disabled?: Record<string, boolean>;
174
+ };
171
175
  inputProps?: InputComponentProps;
172
176
  layoutProps?: LayoutComponentProps;
173
177
  generateRandomValueButton?: boolean;
@@ -4,6 +4,7 @@ import { Button, Card as CardBase, HelpMark, Icon, Popover, Text } from '@gravit
4
4
  import isString from 'lodash/isString';
5
5
  import { COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH } from '../../constants/common';
6
6
  import { block } from '../../utils';
7
+ import { HTMLContent } from '../HTMLContent';
7
8
  import './Card.css';
8
9
  const b = block('card');
9
10
  export const Card = ({ name, title: propsTitle, description, actions, open: propsOpen, onToggle, alwaysOpen, disableHeaderToggle, checkEmptyBody, children, }) => {
@@ -38,7 +39,8 @@ export const Card = ({ name, title: propsTitle, description, actions, open: prop
38
39
  description ? (React.createElement("div", { className: b('note') },
39
40
  React.createElement(HelpMark, { popoverProps: {
40
41
  placement: COMMON_POPOVER_PLACEMENT,
41
- } }, description))) : null));
42
+ } },
43
+ React.createElement(HTMLContent, { html: description })))) : null));
42
44
  }
43
45
  return propsTitle;
44
46
  }, [propsTitle, titlePopoverDisabled, description]);
@@ -39,7 +39,7 @@
39
39
  .df-error-wrapper_error .g-text-input_view_normal:not(.df-error-wrapper-ignore) .g-text-input__content,
40
40
  .df-error-wrapper_error .yc-checkbox__indicator:not(.df-error-wrapper-ignore)::before,
41
41
  .df-error-wrapper_error .g-checkbox__indicator:not(.df-error-wrapper-ignore)::before {
42
- border-color: var(--g-color-text-danger);
42
+ border-color: var(--g-color-line-danger);
43
43
  }
44
44
  .df-error-wrapper__error-text {
45
45
  color: var(--g-color-text-danger);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface HTMLContentProps {
3
+ html: string;
4
+ }
5
+ export declare const HTMLContent: React.FC<HTMLContentProps>;
6
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export const HTMLContent = ({ html }) => {
3
+ return React.createElement("div", { dangerouslySetInnerHTML: { __html: html } });
4
+ };
@@ -0,0 +1 @@
1
+ export * from './HTMLContent';
@@ -0,0 +1 @@
1
+ export * from './HTMLContent';
@@ -0,0 +1,28 @@
1
+ /*
2
+ @mixin variables {
3
+ --g-spacing-base: 4px;
4
+
5
+ --g-spacing-0: calc(var(--g-spacing-base) * 0); //0px
6
+ --g-spacing-half: calc(var(--g-spacing-base) * 0.5); //2px
7
+ --g-spacing-1: var(--g-spacing-base); // 4px
8
+ --g-spacing-2: calc(var(--g-spacing-base) * 2); // 8px
9
+ --g-spacing-3: calc(var(--g-spacing-base) * 3); // 12px
10
+ --g-spacing-4: calc(var(--g-spacing-base) * 4); // 16px
11
+ --g-spacing-5: calc(var(--g-spacing-base) * 5); // 20px
12
+ --g-spacing-6: calc(var(--g-spacing-base) * 6); // 24px
13
+ --g-spacing-7: calc(var(--g-spacing-base) * 7); // 28px
14
+ --g-spacing-8: calc(var(--g-spacing-base) * 8); // 32px
15
+ --g-spacing-9: calc(var(--g-spacing-base) * 9); // 36px
16
+ --g-spacing-10: calc(var(--g-spacing-base) * 10); // 40px
17
+ }
18
+ */
19
+ /* Border-radius */
20
+ .df-radio-group {
21
+ align-items: center;
22
+ height: var(--df-radio-group-height, 28px);
23
+ }
24
+ .df-radio-group_vertical {
25
+ align-items: flex-start;
26
+ margin-top: var(--df-radio-group-vertical-margin-top, var(--g-spacing-2));
27
+ height: auto;
28
+ }
@@ -0,0 +1,7 @@
1
+ import { type RadioGroupProps as RadioGroupBaseProps } from '@gravity-ui/uikit';
2
+ import type { StringInput } from '../../../../core';
3
+ import './RadioGroup.css';
4
+ export interface RadioGroupProps extends Omit<RadioGroupBaseProps, 'direction' | 'onChange' | 'onBlur' | 'onFocus' | 'disabled' | 'qa' | 'content'> {
5
+ withCustomOptions?: boolean;
6
+ }
7
+ export declare const RadioGroup: StringInput<RadioGroupProps>;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { Flex, RadioGroup as RadioGroupBase, } from '@gravity-ui/uikit';
3
+ import { block } from '../../../utils';
4
+ import './RadioGroup.css';
5
+ const b = block('radio-group');
6
+ export const RadioGroup = ({ name, input, spec, inputProps }) => {
7
+ var _a, _b, _c;
8
+ const { value, onBlur, onChange, onFocus } = input;
9
+ const { withCustomOptions, options: externalOptions } = inputProps || {};
10
+ const options = React.useMemo(() => {
11
+ var _a;
12
+ return withCustomOptions
13
+ ? externalOptions || []
14
+ : ((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.map((id) => {
15
+ var _a, _b, _c;
16
+ return ({
17
+ value: id,
18
+ content: ((_a = spec.description) === null || _a === void 0 ? void 0 : _a[id]) || id,
19
+ disabled: ((_c = (_b = spec.viewSpec.radioGroupParams) === null || _b === void 0 ? void 0 : _b.disabled) === null || _c === void 0 ? void 0 : _c[id]) || false,
20
+ });
21
+ })) || [];
22
+ }, [
23
+ withCustomOptions,
24
+ externalOptions,
25
+ spec.enum,
26
+ spec.description,
27
+ (_a = spec.viewSpec.radioGroupParams) === null || _a === void 0 ? void 0 : _a.disabled,
28
+ ]);
29
+ if (options.length === 0) {
30
+ return null;
31
+ }
32
+ return (React.createElement(Flex, { className: b({ vertical: ((_b = spec.viewSpec.radioGroupParams) === null || _b === void 0 ? void 0 : _b.direction) === 'vertical' }) },
33
+ React.createElement(RadioGroupBase, Object.assign({}, inputProps, { name: name, qa: name, disabled: spec.viewSpec.disabled, onUpdate: onChange, onBlur: onBlur, onFocus: onFocus, value: value, options: options, direction: ((_c = spec.viewSpec.radioGroupParams) === null || _c === void 0 ? void 0 : _c.direction) || 'horizontal' }))));
34
+ };
@@ -0,0 +1 @@
1
+ export * from './RadioGroup';
@@ -0,0 +1 @@
1
+ export * from './RadioGroup';
@@ -7,6 +7,7 @@ import { Controller, OBJECT_ARRAY_CNT, OBJECT_ARRAY_FLAG, isArraySpec, isBoolean
7
7
  import { useSearchContext } from '../../../../core/components/Form/hooks';
8
8
  import { COMMON_POPOVER_PLACEMENT } from '../../../constants/common';
9
9
  import { block } from '../../../utils';
10
+ import { HTMLContent } from '../../HTMLContent';
10
11
  import './TableArrayInput.css';
11
12
  const b = block('table-array');
12
13
  export const TableArrayInput = ({ spec, name, arrayInput, input }) => {
@@ -51,7 +52,8 @@ export const TableArrayInput = ({ spec, name, arrayInput, input }) => {
51
52
  label,
52
53
  React.createElement(HelpMark, { popoverProps: {
53
54
  placement: COMMON_POPOVER_PLACEMENT,
54
- } }, description))),
55
+ } },
56
+ React.createElement(HTMLContent, { html: description })))),
55
57
  template: ({ key, }, idx) => {
56
58
  var _a, _b, _c;
57
59
  const entitySpec = (_a = items === null || items === void 0 ? void 0 : items.properties) === null || _a === void 0 ? void 0 : _a[property];
@@ -11,6 +11,7 @@ export * from './NumberWithScale';
11
11
  export * from './ObjectBase';
12
12
  export * from './ObjectValueInput';
13
13
  export * from './OneOf';
14
+ export * from './RadioGroup';
14
15
  export * from './Secret';
15
16
  export * from './Select';
16
17
  export * from './Switch';
@@ -11,6 +11,7 @@ export * from './NumberWithScale';
11
11
  export * from './ObjectBase';
12
12
  export * from './ObjectValueInput';
13
13
  export * from './OneOf';
14
+ export * from './RadioGroup';
14
15
  export * from './Secret';
15
16
  export * from './Select';
16
17
  export * from './Switch';
@@ -5,6 +5,7 @@ import { isArrayItem, isArraySpec, isObjectSpec, withGenerateButton } from '../.
5
5
  import { ErrorWrapper, GenerateRandomValueButton } from '../../../components';
6
6
  import { COMMON_POPOVER_PLACEMENT } from '../../../constants/common';
7
7
  import { block } from '../../../utils';
8
+ import { HTMLContent } from '../../HTMLContent';
8
9
  import './Column.css';
9
10
  const b = block('column');
10
11
  const ColumnBase = ({ name, spec, input, meta, children, }) => {
@@ -18,7 +19,8 @@ const ColumnBase = ({ name, spec, input, meta, children, }) => {
18
19
  React.createElement(Text, { className: b('note-inner') },
19
20
  React.createElement(HelpMark, { popoverProps: {
20
21
  placement: COMMON_POPOVER_PLACEMENT,
21
- } }, spec.viewSpec.layoutDescription)))) : null)),
22
+ } },
23
+ React.createElement(HTMLContent, { html: spec.viewSpec.layoutDescription }))))) : null)),
22
24
  React.createElement("div", { className: b('second-row') },
23
25
  React.createElement("div", { className: b('second-row-inner') },
24
26
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles:
@@ -5,6 +5,7 @@ import { isArrayItem, isArraySpec, isObjectSpec, withGenerateButton } from '../.
5
5
  import { ErrorWrapper, GenerateRandomValueButton } from '../../../components';
6
6
  import { COMMON_POPOVER_PLACEMENT } from '../../../constants/common';
7
7
  import { block } from '../../../utils';
8
+ import { HTMLContent } from '../../HTMLContent';
8
9
  import './Row.css';
9
10
  const b = block('row');
10
11
  const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) => {
@@ -18,7 +19,8 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
18
19
  React.createElement(Text, { className: b('note-inner') },
19
20
  React.createElement(HelpMark, { popoverProps: {
20
21
  placement: COMMON_POPOVER_PLACEMENT,
21
- } }, spec.viewSpec.layoutDescription)))) : null)),
22
+ } },
23
+ React.createElement(HTMLContent, { html: spec.viewSpec.layoutDescription }))))) : null)),
22
24
  React.createElement("div", { className: b('right') },
23
25
  React.createElement("div", { className: b('right-inner') },
24
26
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles:
@@ -5,6 +5,7 @@ import { GroupIndent } from '../../';
5
5
  import { COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH, ErrorWrapper } from '../../../';
6
6
  import { isArrayItem, isArraySpec, isObjectSpec } from '../../../../core';
7
7
  import { block } from '../../../utils';
8
+ import { HTMLContent } from '../../HTMLContent';
8
9
  import { RemoveButton } from '../../RemoveButton';
9
10
  import './Section.css';
10
11
  const b = block('section');
@@ -58,7 +59,8 @@ const SectionBase = (_a) => {
58
59
  description = (React.createElement(Text, { className: b('note') },
59
60
  React.createElement(HelpMark, { popoverProps: {
60
61
  placement: COMMON_POPOVER_PLACEMENT,
61
- } }, spec.viewSpec.layoutDescription)));
62
+ } },
63
+ React.createElement(HTMLContent, { html: spec.viewSpec.layoutDescription }))));
62
64
  }
63
65
  }
64
66
  const layoutTitle = spec.viewSpec.layoutTitle;
@@ -3,6 +3,7 @@ import { ChevronDown } from '@gravity-ui/icons';
3
3
  import { Button, HelpMark, Icon, Popover, Text } from '@gravity-ui/uikit';
4
4
  import { COMMON_POPOVER_PLACEMENT } from '../../constants/common';
5
5
  import { block } from '../../utils';
6
+ import { HTMLContent } from '../HTMLContent';
6
7
  import './SimpleVerticalAccordeon.css';
7
8
  const b = block('simple-vertical-accordeon');
8
9
  const TITLE_TEXT_MAX_WIDTH = 485; /** 533px (COMMON_TITLE_MAX_WIDTH) - 48px of padding */
@@ -89,7 +90,8 @@ export class SimpleVerticalAccordeon extends React.Component {
89
90
  return note ? (React.createElement(Text, { className: b('tooltip') },
90
91
  React.createElement(HelpMark, { popoverProps: {
91
92
  placement: COMMON_POPOVER_PLACEMENT,
92
- } }, note))) : null;
93
+ } },
94
+ React.createElement(HTMLContent, { html: note })))) : null;
93
95
  }
94
96
  }
95
97
  SimpleVerticalAccordeon.defaultProps = {
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { Card, HelpMark, Text } from '@gravity-ui/uikit';
3
3
  import { COMMON_POPOVER_PLACEMENT } from '../../constants/common';
4
4
  import { block } from '../../utils';
5
+ import { HTMLContent } from '../HTMLContent';
5
6
  import './TogglerCard.css';
6
7
  const b = block('toggler-card');
7
8
  export const TogglerCard = ({ description, title, text, onClick, disabled, selected, }) => {
@@ -10,6 +11,7 @@ export const TogglerCard = ({ description, title, text, onClick, disabled, selec
10
11
  React.createElement(Text, { variant: "subheader-2", ellipsis: true }, title),
11
12
  description ? (React.createElement(HelpMark, { popoverProps: {
12
13
  placement: COMMON_POPOVER_PLACEMENT,
13
- } }, description)) : null),
14
+ } },
15
+ React.createElement(HTMLContent, { html: description }))) : null),
14
16
  React.createElement(Text, { variant: "body-1", color: "secondary", className: b('text') }, text)));
15
17
  };
@@ -4,6 +4,7 @@ import { useDynamicFormsCtx } from '../../../../core';
4
4
  import { CopyButton } from '../../../../kit';
5
5
  import { COMMON_POPOVER_PLACEMENT } from '../../../constants/common';
6
6
  import { block, isNotEmptyValue } from '../../../utils';
7
+ import { HTMLContent } from '../../HTMLContent';
7
8
  import './ViewColumn.css';
8
9
  const b = block('view-column');
9
10
  export const ViewColumn = ({ value, spec, children, }) => {
@@ -16,7 +17,8 @@ export const ViewColumn = ({ value, spec, children, }) => {
16
17
  React.createElement(Text, { color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
17
18
  showLayoutDescription && spec.viewSpec.layoutDescription ? (React.createElement(HelpMark, { className: b('note'), popoverProps: {
18
19
  placement: COMMON_POPOVER_PLACEMENT,
19
- } }, spec.viewSpec.layoutDescription)) : null),
20
+ } },
21
+ React.createElement(HTMLContent, { html: spec.viewSpec.layoutDescription }))) : null),
20
22
  React.createElement("div", { className: b('second-row') }, children),
21
23
  React.createElement(CopyButton, { spec: spec, value: value })));
22
24
  };
@@ -4,6 +4,7 @@ import { useDynamicFormsCtx } from '../../../../core';
4
4
  import { CopyButton } from '../../../../kit';
5
5
  import { COMMON_POPOVER_PLACEMENT } from '../../../constants/common';
6
6
  import { block, isNotEmptyValue } from '../../../utils';
7
+ import { HTMLContent } from '../../HTMLContent';
7
8
  import './ViewRow.css';
8
9
  const b = block('view-row');
9
10
  export const ViewRow = ({ value, spec, children, }) => {
@@ -16,7 +17,8 @@ export const ViewRow = ({ value, spec, children, }) => {
16
17
  React.createElement(Text, { whiteSpace: "nowrap", color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
17
18
  showLayoutDescription && spec.viewSpec.layoutDescription ? (React.createElement(HelpMark, { className: b('note'), popoverProps: {
18
19
  placement: COMMON_POPOVER_PLACEMENT,
19
- } }, spec.viewSpec.layoutDescription)) : null,
20
+ } },
21
+ React.createElement(HTMLContent, { html: spec.viewSpec.layoutDescription }))) : null,
20
22
  React.createElement("div", { className: b('dots') })),
21
23
  React.createElement("div", { className: b('right') }, children),
22
24
  React.createElement(CopyButton, { spec: spec, value: value })));
@@ -3,6 +3,7 @@ import { Flex, HelpMark, Table } from '@gravity-ui/uikit';
3
3
  import { ViewController, isArraySpec, isBooleanSpec, isObjectSpec, useDynamicFormsCtx, } from '../../../../core';
4
4
  import { COMMON_POPOVER_PLACEMENT } from '../../../constants/common';
5
5
  import { block } from '../../../utils';
6
+ import { HTMLContent } from '../../HTMLContent';
6
7
  import './TableArrayView.css';
7
8
  const b = block('table-array-view');
8
9
  export const TableArrayView = ({ value = [], spec, name }) => {
@@ -25,7 +26,8 @@ export const TableArrayView = ({ value = [], spec, name }) => {
25
26
  label,
26
27
  React.createElement(HelpMark, { popoverProps: {
27
28
  placement: COMMON_POPOVER_PLACEMENT,
28
- } }, description)))
29
+ } },
30
+ React.createElement(HTMLContent, { html: description }))))
29
31
  : label,
30
32
  template: (_, idx) => {
31
33
  var _a;
@@ -1,4 +1,4 @@
1
- import { Accordeon, AccordeonCardForm, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, CheckboxGroup, CheckboxGroupView, Column, DateInput, DateView, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoView, MultiOneOf, MultiOneOfFlat, MultiOneOfFlatView, MultiOneOfView, MultiSelect, MultiSelectView, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, ObjectInline, ObjectInlineView, ObjectValueInput, ObjectValueInputView, OneOf, OneOfFlat, OneOfFlatView, OneOfView, Row, RowVerbose, Secret, Section, Section2, Select, Switch, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextContentView, TextLink, TextLinkView, TimeRangeSelector, TimeRangeSelectorView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewColumn, ViewGroup, ViewGroup2, ViewRow, ViewSection, ViewSection2, ViewTableCell, ViewTransparent, } from '../components';
1
+ import { Accordeon, AccordeonCardForm, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, CheckboxGroup, CheckboxGroupView, Column, DateInput, DateView, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoView, MultiOneOf, MultiOneOfFlat, MultiOneOfFlatView, MultiOneOfView, MultiSelect, MultiSelectView, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, ObjectInline, ObjectInlineView, ObjectValueInput, ObjectValueInputView, OneOf, OneOfFlat, OneOfFlatView, OneOfView, RadioGroup, Row, RowVerbose, Secret, Section, Section2, Select, Switch, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextContentView, TextLink, TextLinkView, TimeRangeSelector, TimeRangeSelectorView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewColumn, ViewGroup, ViewGroup2, ViewRow, ViewSection, ViewSection2, ViewTableCell, ViewTransparent, } from '../components';
2
2
  import { getArrayValidator, getBooleanValidator, getNumberValidator, getObjectValidator, getStringValidator, } from '../validators';
3
3
  export const dynamicConfig = {
4
4
  array: {
@@ -101,6 +101,7 @@ export const dynamicConfig = {
101
101
  number_with_scale: { Component: NumberWithScale },
102
102
  monaco_input: { Component: MonacoInput },
103
103
  text_content: { Component: TextContent, independent: true },
104
+ radio_group: { Component: RadioGroup },
104
105
  },
105
106
  layouts: {
106
107
  row: Row,
@@ -209,6 +210,7 @@ export const dynamicViewConfig = {
209
210
  number_with_scale: { Component: NumberWithScaleView },
210
211
  monaco_input: { Component: MonacoView },
211
212
  text_content: { Component: TextContentView, independent: true },
213
+ radio_group: { Component: BaseView },
212
214
  },
213
215
  layouts: {
214
216
  row: ViewRow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",
@@ -80,6 +80,7 @@
80
80
  "@types/react-is": "^17.0.3",
81
81
  "@types/uuid": "^9.0.4",
82
82
  "@vitejs/plugin-react": "^4.2.0",
83
+ "ajv": "^8.17.1",
83
84
  "css-loader": "^5.2.6",
84
85
  "eslint": "^8.49.0",
85
86
  "final-form": "^4.20.2",