@gravity-ui/dynamic-forms 1.5.0 → 1.6.1

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 (102) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/build/cjs/lib/core/components/Form/hooks/useField.js +3 -0
  3. package/build/cjs/lib/core/components/Form/hooks/useStore.js +6 -0
  4. package/build/cjs/lib/core/helpers.js +4 -1
  5. package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
  6. package/build/cjs/lib/kit/components/Card/Card.js +2 -2
  7. package/build/cjs/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
  8. package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
  9. package/build/cjs/lib/kit/components/Inputs/Checkbox/Checkbox.js +2 -2
  10. package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.js +3 -3
  11. package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputBase.js +5 -5
  12. package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.js +2 -2
  13. package/build/cjs/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +2 -2
  14. package/build/cjs/lib/kit/components/Inputs/NumberWithScale/NumberWithScale.js +3 -3
  15. package/build/cjs/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -2
  16. package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +18 -5
  17. package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.css +8 -8
  18. package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
  19. package/build/cjs/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +3 -3
  20. package/build/cjs/lib/kit/components/Inputs/Secret/Secret.js +16 -6
  21. package/build/cjs/lib/kit/components/Inputs/Select/Select.js +2 -2
  22. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -3
  23. package/build/cjs/lib/kit/components/Inputs/Text/Text.js +2 -2
  24. package/build/cjs/lib/kit/components/Inputs/TextArea/TextArea.js +2 -2
  25. package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +18 -5
  26. package/build/cjs/lib/kit/components/Layouts/Accordeon/Accordeon.js +3 -3
  27. package/build/cjs/lib/kit/components/Layouts/Accordeon/RemoveButton.js +2 -2
  28. package/build/cjs/lib/kit/components/Layouts/AccordeonCardLayout/AccordeonCardLayout.js +3 -3
  29. package/build/cjs/lib/kit/components/Layouts/CardAccordeon.js +3 -3
  30. package/build/cjs/lib/kit/components/Layouts/CardSection.js +3 -3
  31. package/build/cjs/lib/kit/components/Layouts/Row/Row.js +1 -1
  32. package/build/cjs/lib/kit/components/Layouts/Row2/Row2.js +1 -1
  33. package/build/cjs/lib/kit/components/Layouts/SectionCard/SectionCard.js +1 -1
  34. package/build/cjs/lib/kit/components/Layouts/Transparent/Transparent.js +2 -2
  35. package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +1 -1
  36. package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +2 -2
  37. package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
  38. package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
  39. package/build/cjs/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
  40. package/build/cjs/lib/kit/components/ViewLayouts/ViewCardSection.js +2 -2
  41. package/build/cjs/lib/kit/components/Views/CardOneOfView.js +1 -1
  42. package/build/cjs/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +18 -4
  43. package/build/cjs/lib/kit/components/Views/OneOfCardView.js +1 -1
  44. package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +21 -7
  45. package/build/cjs/lib/kit/hooks/useOneOf.js +4 -4
  46. package/build/esm/lib/core/components/Form/hooks/useField.js +4 -1
  47. package/build/esm/lib/core/components/Form/hooks/useStore.js +6 -0
  48. package/build/esm/lib/core/helpers.d.ts +1 -0
  49. package/build/esm/lib/core/helpers.js +2 -0
  50. package/build/esm/lib/core/types/specs.d.ts +0 -1
  51. package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.d.ts +1 -0
  52. package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
  53. package/build/esm/lib/kit/components/Card/Card.d.ts +1 -0
  54. package/build/esm/lib/kit/components/Card/Card.js +2 -2
  55. package/build/esm/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
  56. package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
  57. package/build/esm/lib/kit/components/Inputs/Checkbox/Checkbox.js +2 -2
  58. package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.js +3 -3
  59. package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputBase.js +5 -5
  60. package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.d.ts +1 -0
  61. package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.js +2 -2
  62. package/build/esm/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +2 -2
  63. package/build/esm/lib/kit/components/Inputs/NumberWithScale/NumberWithScale.js +3 -3
  64. package/build/esm/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -2
  65. package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +18 -5
  66. package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.css +8 -8
  67. package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
  68. package/build/esm/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +3 -3
  69. package/build/esm/lib/kit/components/Inputs/Secret/Secret.js +17 -7
  70. package/build/esm/lib/kit/components/Inputs/Select/Select.js +2 -2
  71. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -3
  72. package/build/esm/lib/kit/components/Inputs/Text/Text.d.ts +1 -1
  73. package/build/esm/lib/kit/components/Inputs/Text/Text.js +2 -2
  74. package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.js +2 -2
  75. package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +18 -5
  76. package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.js +3 -3
  77. package/build/esm/lib/kit/components/Layouts/Accordeon/RemoveButton.d.ts +1 -0
  78. package/build/esm/lib/kit/components/Layouts/Accordeon/RemoveButton.js +2 -2
  79. package/build/esm/lib/kit/components/Layouts/AccordeonCardLayout/AccordeonCardLayout.js +3 -3
  80. package/build/esm/lib/kit/components/Layouts/CardAccordeon.js +3 -3
  81. package/build/esm/lib/kit/components/Layouts/CardSection.js +3 -3
  82. package/build/esm/lib/kit/components/Layouts/Row/Row.js +1 -1
  83. package/build/esm/lib/kit/components/Layouts/Row2/Row2.js +1 -1
  84. package/build/esm/lib/kit/components/Layouts/SectionCard/SectionCard.js +1 -1
  85. package/build/esm/lib/kit/components/Layouts/Transparent/Transparent.js +2 -2
  86. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +1 -1
  87. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.d.ts +1 -0
  88. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +2 -2
  89. package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.d.ts +1 -1
  90. package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
  91. package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.d.ts +1 -1
  92. package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
  93. package/build/esm/lib/kit/components/ViewLayouts/ViewCardAccordeon.d.ts +1 -1
  94. package/build/esm/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
  95. package/build/esm/lib/kit/components/ViewLayouts/ViewCardSection.d.ts +1 -1
  96. package/build/esm/lib/kit/components/ViewLayouts/ViewCardSection.js +2 -2
  97. package/build/esm/lib/kit/components/Views/CardOneOfView.js +1 -1
  98. package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +19 -4
  99. package/build/esm/lib/kit/components/Views/OneOfCardView.js +1 -1
  100. package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +23 -8
  101. package/build/esm/lib/kit/hooks/useOneOf.js +4 -4
  102. package/package.json +4 -4
@@ -2,13 +2,26 @@ import React from 'react';
2
2
  import _ from 'lodash';
3
3
  import { Controller } from '../../../../core';
4
4
  const OBJECT_VALUE_PROPERTY_NAME = 'value';
5
- export const ObjectValueInput = ({ spec, input, name }) => {
5
+ export const ObjectValueInput = (props) => {
6
6
  var _a;
7
- const parentOnChange = React.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => _.set(Object.assign({}, (currentValue || {})), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
7
+ const { spec, input, name, Layout } = props;
8
+ const parentOnChange = React.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => _.set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
8
9
  const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
9
- const specProperties = Object.assign({}, spec.properties);
10
- if (!specProperties[OBJECT_VALUE_PROPERTY_NAME]) {
10
+ const childSpec = React.useMemo(() => {
11
+ var _a;
12
+ if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME]) {
13
+ const childSpec = _.cloneDeep(spec.properties[OBJECT_VALUE_PROPERTY_NAME]);
14
+ childSpec.viewSpec.layout = 'transparent';
15
+ return childSpec;
16
+ }
17
+ return undefined;
18
+ }, [spec.properties]);
19
+ if (!childSpec) {
11
20
  return null;
12
21
  }
13
- return (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME], spec: specProperties[OBJECT_VALUE_PROPERTY_NAME], name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, key: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
22
+ const content = (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME], spec: childSpec, name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, key: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
23
+ if (Layout) {
24
+ return React.createElement(Layout, Object.assign({}, props), content);
25
+ }
26
+ return React.createElement(React.Fragment, null, content);
14
27
  };
@@ -1,27 +1,27 @@
1
1
  .df-oneof {
2
2
  display: flex;
3
- flex-direction: column-reverse;
3
+ flex-direction: column;
4
4
  }
5
5
  .df-oneof:last-child > .df-group-indent {
6
6
  margin-bottom: 0;
7
7
  }
8
- .df-oneof:last-child > .df-group-indent:empty + .df-oneof__toggler {
9
- margin-bottom: 0;
10
- }
11
- .df-oneof__toggler {
12
- margin-bottom: 15px;
13
- }
14
8
  .df-oneof .df-group-indent {
15
9
  all: unset;
16
10
  }
17
11
  .df-oneof .df-group-indent > .df-use-search {
18
12
  padding-top: 11px;
19
13
  padding-left: 20px;
20
- margin-top: -11px;
14
+ margin-top: 4px;
21
15
  margin-bottom: 20px;
22
16
  margin-left: 5px;
23
17
  border-left: 1px solid var(--yc-color-line-generic-accent);
24
18
  }
25
19
  .df-oneof .df-group-indent > .df-use-search:empty {
26
20
  display: none;
21
+ }
22
+ .df-oneof .df-group-indent > .df-use-search:last-child {
23
+ margin-bottom: 0;
24
+ }
25
+ .df-oneof .df-group-indent > .df-use-search > .df-simple-vertical-accordeon_view {
26
+ margin-top: -10px;
27
27
  }
@@ -15,7 +15,7 @@ export const OneOf = (props) => {
15
15
  }, [props.input.onChange, props.input.name]);
16
16
  const parentOnUnmount = React.useCallback((childName) => props.input.onChange((currentValue) => currentValue, { [childName]: false }), [props.input.onChange]);
17
17
  return (React.createElement("div", { className: b() },
18
+ React.createElement("div", null, toggler),
18
19
  specProperties[oneOfValue] ? (React.createElement(GroupIndent, null,
19
- React.createElement(Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${props.name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${props.name}.${oneOfValue}` }))) : null,
20
- React.createElement("div", { className: b('toggler') }, toggler)));
20
+ React.createElement(Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${props.name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${props.name}.${oneOfValue}` }))) : null));
21
21
  };
@@ -26,15 +26,15 @@ export const OneOfCard = (props) => {
26
26
  }, [togglerInput, props, arrayItem]);
27
27
  const headerActionsTemplate = React.useMemo(() => {
28
28
  if (arrayItem) {
29
- return React.createElement(RemoveButton, { onDrop: input.onDrop });
29
+ return React.createElement(RemoveButton, { onDrop: input.onDrop, name: name });
30
30
  }
31
31
  return null;
32
- }, [arrayItem, input.onDrop]);
32
+ }, [arrayItem, input.onDrop, name]);
33
33
  const parentOnChange = React.useCallback((childName, childValue, childErrors) => {
34
34
  const value = _.set({}, childName.split(`${input.name}.`).join(''), childValue);
35
35
  input.onChange(value, childErrors);
36
36
  }, [input.onChange, input.name]);
37
37
  const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
38
38
  useErrorChecker({ name, meta, open, setOpen });
39
- return (React.createElement(AccordeonCard, { className: b(), header: toggler, description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, ignoreHeaderToggle: true, headerActionsTemplate: headerActionsTemplate }, specProperties[oneOfValue] ? (React.createElement(Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
39
+ return (React.createElement(AccordeonCard, { className: b(), name: name, header: toggler, description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, ignoreHeaderToggle: true, headerActionsTemplate: headerActionsTemplate }, specProperties[oneOfValue] ? (React.createElement(Controller, { initialValue: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
40
40
  };
@@ -1,17 +1,27 @@
1
1
  import React from 'react';
2
2
  import _ from 'lodash';
3
- import { Controller, } from '../../../../core';
3
+ import { Controller } from '../../../../core';
4
4
  const SECRET_PROPERTY_NAME = 'raw';
5
- export const Secret = ({ spec, name, input }) => {
5
+ export const Secret = (props) => {
6
6
  var _a;
7
+ const { spec, name, input, Layout } = props;
8
+ const childSpec = React.useMemo(() => {
9
+ var _a, _b;
10
+ if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[SECRET_PROPERTY_NAME]) {
11
+ const childSpec = _.cloneDeep((_b = spec.properties) === null || _b === void 0 ? void 0 : _b[SECRET_PROPERTY_NAME]);
12
+ childSpec.viewSpec.layout = 'transparent';
13
+ return childSpec;
14
+ }
15
+ return undefined;
16
+ }, [spec.properties]);
7
17
  const parentOnChange = React.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => _.set(Object.assign({}, currentValue), childName.split(`${input.name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
8
18
  const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
9
- if (!_.isObjectLike(spec.properties)) {
19
+ if (!childSpec) {
10
20
  return null;
11
21
  }
12
- const specProperties = Object.assign({}, spec.properties);
13
- if (!specProperties[SECRET_PROPERTY_NAME]) {
14
- return null;
22
+ const content = (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[SECRET_PROPERTY_NAME], spec: childSpec, name: `${name}.${SECRET_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${SECRET_PROPERTY_NAME}` }));
23
+ if (Layout) {
24
+ return React.createElement(Layout, Object.assign({}, props), content);
15
25
  }
16
- return (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[SECRET_PROPERTY_NAME], spec: specProperties[SECRET_PROPERTY_NAME], name: `${name}.${SECRET_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${SECRET_PROPERTY_NAME}` }));
26
+ return React.createElement(React.Fragment, null, content);
17
27
  };
@@ -3,7 +3,7 @@ import { Select as SelectBase } from '@gravity-ui/uikit';
3
3
  import { block } from '../../../utils';
4
4
  import './Select.css';
5
5
  const b = block('select');
6
- export const Select = ({ input, spec }) => {
6
+ export const Select = ({ name, input, spec }) => {
7
7
  var _a;
8
8
  const { value, onBlur, onChange, onFocus } = input;
9
9
  const filterable = React.useMemo(() => { var _a; return (((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length) || 0) > 9; }, [(_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length]);
@@ -28,5 +28,5 @@ export const Select = ({ input, spec }) => {
28
28
  onBlur();
29
29
  }
30
30
  }, [onFocus, onBlur]);
31
- return (React.createElement(SelectBase, { className: b(), width: "max", value: [value], options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterable: filterable }));
31
+ return (React.createElement(SelectBase, { className: b(), width: "max", value: [value], options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterable: filterable, qa: name }));
32
32
  };
@@ -41,7 +41,7 @@ export const TableArrayInput = ({ spec, name, arrayInput, input }) => {
41
41
  id: 'remove',
42
42
  name: '',
43
43
  sticky: 'right',
44
- template: ({ key }) => (React.createElement(Button, { view: "flat", onClick: () => onItemRemove(key), key: `remove-${key}` },
44
+ template: ({ key }) => (React.createElement(Button, { view: "flat", onClick: () => onItemRemove(key), key: `remove-${key}`, qa: `${name}-item-remove-${key}` },
45
45
  React.createElement(Icon, { data: Xmark, size: 16 }))),
46
46
  };
47
47
  const columns = table.map(({ property, label }) => ({
@@ -74,9 +74,9 @@ export const TableArrayInput = ({ spec, name, arrayInput, input }) => {
74
74
  }
75
75
  return (React.createElement("div", { className: b() },
76
76
  keys.length ? (React.createElement(Table, { className: b('table'), data: keys, columns: columns, getRowId: (_, idx) => `${name}-${idx}`, verticalAlign: "top", getRowClassNames: getRowClassNames })) : null,
77
- !arrayInput.value && spec.defaultValue ? (React.createElement(Button, { onClick: () => input.onChange(transformArrIn(spec.defaultValue)), disabled: spec.viewSpec.disabled },
77
+ !arrayInput.value && spec.defaultValue ? (React.createElement(Button, { onClick: () => input.onChange(transformArrIn(spec.defaultValue)), disabled: spec.viewSpec.disabled, qa: `${name}-init-arr` },
78
78
  React.createElement(Icon, { data: Plus, size: 14 }),
79
- spec.viewSpec.layoutTitle || null)) : (React.createElement(Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled },
79
+ spec.viewSpec.layoutTitle || null)) : (React.createElement(Button, { onClick: onItemAdd, disabled: spec.viewSpec.disabled, qa: `${name}-add-item` },
80
80
  React.createElement(Icon, { data: Plus, size: 14 }),
81
81
  spec.viewSpec.itemLabel || null))));
82
82
  };
@@ -1,2 +1,2 @@
1
1
  import { NumberInputProps, StringInputProps } from '../../../../core';
2
- export declare const Text: <T extends NumberInputProps | StringInputProps>({ input, spec }: T) => JSX.Element;
2
+ export declare const Text: <T extends NumberInputProps | StringInputProps>({ name, input, spec }: T) => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TextInput } from '@gravity-ui/uikit';
3
3
  import _ from 'lodash';
4
- export const Text = ({ input, spec }) => {
4
+ export const Text = ({ name, input, spec }) => {
5
5
  const { value, onBlur, onChange, onFocus } = input;
6
6
  const handleChange = React.useCallback((value) => {
7
7
  onChange(value);
@@ -12,5 +12,5 @@ export const Text = ({ input, spec }) => {
12
12
  }
13
13
  return 'text';
14
14
  }, [spec.viewSpec.type]);
15
- return (React.createElement(TextInput, { type: type, value: _.isNil(value) ? '' : `${value}`, hasClear: true, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, autoComplete: type === 'password' ? 'new-password' : undefined }));
15
+ return (React.createElement(TextInput, { type: type, value: _.isNil(value) ? '' : `${value}`, hasClear: true, onBlur: onBlur, onFocus: onFocus, onUpdate: handleChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, autoComplete: type === 'password' ? 'new-password' : undefined, qa: name }));
16
16
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TextInput as TextInputBase } from '@gravity-ui/uikit';
3
- export const TextArea = ({ input, spec }) => {
3
+ export const TextArea = ({ name, input, spec }) => {
4
4
  const { value, onBlur, onChange, onFocus } = input;
5
- return (React.createElement(TextInputBase, { value: value, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, multiline: true, placeholder: spec.viewSpec.placeholder }));
5
+ return (React.createElement(TextInputBase, { value: value, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, multiline: true, placeholder: spec.viewSpec.placeholder, qa: name }));
6
6
  };
@@ -2,14 +2,27 @@ import React from 'react';
2
2
  import _ from 'lodash';
3
3
  import { Controller, isStringSpec, } from '../../../../core';
4
4
  const TEXT_LINK_PROPERTY_NAME = 'text';
5
- export const TextLink = ({ spec, input, name }) => {
5
+ export const TextLink = (props) => {
6
6
  var _a;
7
+ const { spec, input, name, Layout } = props;
7
8
  const parentOnChange = React.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => _.set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
8
9
  const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
9
- const specProperties = Object.assign({}, spec.properties);
10
- if (!specProperties[TEXT_LINK_PROPERTY_NAME] ||
11
- !isStringSpec(specProperties[TEXT_LINK_PROPERTY_NAME])) {
10
+ const childSpec = React.useMemo(() => {
11
+ var _a;
12
+ if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME]) &&
13
+ isStringSpec(spec.properties[TEXT_LINK_PROPERTY_NAME])) {
14
+ const childSpec = _.cloneDeep(spec.properties[TEXT_LINK_PROPERTY_NAME]);
15
+ childSpec.viewSpec.layout = 'transparent';
16
+ return childSpec;
17
+ }
18
+ return undefined;
19
+ }, [spec.properties]);
20
+ if (!childSpec) {
12
21
  return null;
13
22
  }
14
- return (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME], spec: specProperties[TEXT_LINK_PROPERTY_NAME], name: `${name}.${TEXT_LINK_PROPERTY_NAME}`, key: `${name}.${TEXT_LINK_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
23
+ const content = (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME], spec: childSpec, name: `${name}.${TEXT_LINK_PROPERTY_NAME}`, key: `${name}.${TEXT_LINK_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
24
+ if (Layout) {
25
+ return React.createElement(Layout, Object.assign({}, props), content);
26
+ }
27
+ return React.createElement(React.Fragment, null, content);
15
28
  };
@@ -14,9 +14,9 @@ export const Accordeon = ({ name, spec, input, meta, children, }) => {
14
14
  if (spec.required || !input.value) {
15
15
  return null;
16
16
  }
17
- return React.createElement(RemoveButton, { onDrop: onDrop });
18
- }, [spec.required, input.value, onDrop]);
17
+ return React.createElement(RemoveButton, { name: name, onDrop: onDrop });
18
+ }, [spec.required, input.value, onDrop, name]);
19
19
  useErrorChecker({ name, meta, open, setOpen });
20
- return (React.createElement(SimpleVerticalAccordeon, { title: spec.viewSpec.layoutTitle || '', note: spec.viewSpec.layoutDescription || '', open: open, onOpenChange: setOpen, headerActionsTemplate: removeButton, hideInsteadOfDestroy: true, withBranchView: true },
20
+ return (React.createElement(SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', note: spec.viewSpec.layoutDescription || '', open: open, onOpenChange: setOpen, headerActionsTemplate: removeButton, hideInsteadOfDestroy: true, withBranchView: true },
21
21
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
22
22
  };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface RemoveButtonProps {
3
+ name: string;
3
4
  onDrop: () => void;
4
5
  }
5
6
  export declare const RemoveButton: React.FC<RemoveButtonProps>;
@@ -2,9 +2,9 @@ import React from 'react';
2
2
  import { Ellipsis } from '@gravity-ui/icons';
3
3
  import { Button, DropdownMenu, Icon } from '@gravity-ui/uikit';
4
4
  import i18n from '../../../i18n';
5
- export const RemoveButton = ({ onDrop }) => {
5
+ export const RemoveButton = ({ name, onDrop }) => {
6
6
  const items = React.useMemo(() => [{ text: i18n('label_delete'), action: onDrop, theme: 'danger' }], [onDrop]);
7
- const switcher = React.useMemo(() => (React.createElement(Button, { view: "flat" },
7
+ const switcher = React.useMemo(() => (React.createElement(Button, { view: "flat", qa: `${name}-drop-item` },
8
8
  React.createElement(Icon, { data: Ellipsis, size: 16 }))), []);
9
9
  return React.createElement(DropdownMenu, { switcher: switcher, items: items });
10
10
  };
@@ -18,9 +18,9 @@ export const AccordeonCardLayout = ({ name, spec, input, meta, children, }) => {
18
18
  if (spec.required || !input.value) {
19
19
  return null;
20
20
  }
21
- return React.createElement(RemoveButton, { onDrop: onDrop });
22
- }, [spec.required, input.value, onDrop]);
21
+ return React.createElement(RemoveButton, { onDrop: onDrop, name: name });
22
+ }, [spec.required, input.value, onDrop, name]);
23
23
  useErrorChecker({ name, meta, open, setOpen });
24
- return (React.createElement(AccordeonCard, { header: spec.viewSpec.layoutTitle || '', description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, headerActionsTemplate: removeButton, className: b() },
24
+ return (React.createElement(AccordeonCard, { name: name, header: spec.viewSpec.layoutTitle || '', description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, headerActionsTemplate: removeButton, className: b() },
25
25
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
26
26
  };
@@ -14,9 +14,9 @@ export const CardAccordeon = ({ name, spec, input, meta, children, }) => {
14
14
  if (spec.required || !input.value) {
15
15
  return null;
16
16
  }
17
- return React.createElement(RemoveButton, { onDrop: onDrop });
18
- }, [spec.required, input.value, onDrop]);
17
+ return React.createElement(RemoveButton, { onDrop: onDrop, name: name });
18
+ }, [spec.required, input.value, onDrop, name]);
19
19
  useErrorChecker({ name, meta, open, setOpen });
20
- return (React.createElement(Card, { title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, open: open, onToggle: onToggle },
20
+ return (React.createElement(Card, { name: name, title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, open: open, onToggle: onToggle },
21
21
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
22
22
  };
@@ -6,8 +6,8 @@ export const CardSection = ({ name, spec, input, meta, children, }) => {
6
6
  if (spec.required || !input.value) {
7
7
  return null;
8
8
  }
9
- return React.createElement(RemoveButton, { onDrop: input.onDrop });
10
- }, [spec.required, input.value, input.onDrop]);
11
- return (React.createElement(Card, { title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, alwaysOpen: true },
9
+ return React.createElement(RemoveButton, { onDrop: input.onDrop, name: name });
10
+ }, [spec.required, input.value, input.onDrop, name]);
11
+ return (React.createElement(Card, { name: name, title: spec.viewSpec.layoutTitle, description: spec.viewSpec.layoutDescription, actions: removeButton, alwaysOpen: true },
12
12
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
13
13
  };
@@ -18,7 +18,7 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
18
18
  React.createElement("div", { className: b('right') },
19
19
  React.createElement("div", { className: b('right-inner') },
20
20
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: isArraySpec(spec) || isObjectSpec(spec) }, children),
21
- arrayItem ? (React.createElement(Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop },
21
+ arrayItem ? (React.createElement(Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop, qa: `${name}-remove-item` },
22
22
  React.createElement(Icon, { data: Xmark, size: 16 }))) : null),
23
23
  verboseDescription && spec.viewSpec.layoutDescription ? (React.createElement("div", { className: b('description'), dangerouslySetInnerHTML: { __html: spec.viewSpec.layoutDescription } })) : null)));
24
24
  };
@@ -15,7 +15,7 @@ export const Row2 = ({ name, spec, input, meta, children, }) => {
15
15
  React.createElement("div", { className: b('right') },
16
16
  React.createElement("div", { className: b('right-inner') },
17
17
  React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: isArraySpec(spec) || isObjectSpec(spec) }, children),
18
- isArrayItem(name) ? (React.createElement(Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop },
18
+ isArrayItem(name) ? (React.createElement(Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop, qa: `${name}-remove-item` },
19
19
  React.createElement(Icon, { data: Xmark, size: 16 }))) : null),
20
20
  spec.viewSpec.layoutDescription ? (React.createElement("div", { className: b('description'), dangerouslySetInnerHTML: { __html: spec.viewSpec.layoutDescription } })) : null)));
21
21
  };
@@ -14,7 +14,7 @@ const SectionCardBase = (_a) => {
14
14
  if (meta) {
15
15
  content = (React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: arrOrObjFlag }, content));
16
16
  }
17
- return (React.createElement(AccordeonCard, { className: b(), header: spec.viewSpec.layoutTitle, description: ignoreDescription ? undefined : spec.viewSpec.layoutDescription, titleSize: titleSize, alwaysOpen: true }, content));
17
+ return (React.createElement(AccordeonCard, { className: b(), name: name, header: spec.viewSpec.layoutTitle, description: ignoreDescription ? undefined : spec.viewSpec.layoutDescription, titleSize: titleSize, alwaysOpen: true }, content));
18
18
  };
19
19
  export const SectionCard = (props) => React.createElement(SectionCardBase, Object.assign({}, props, { titleSize: "m" }));
20
20
  export const SectionCard2 = (props) => React.createElement(SectionCardBase, Object.assign({}, props, { titleSize: "s" }));
@@ -11,11 +11,11 @@ export const Transparent = ({ name, spec, input, meta, children, }) => {
11
11
  const arrOrObjFlag = React.useMemo(() => isArraySpec(spec) || isObjectSpec(spec), [spec]);
12
12
  const removeButton = React.useMemo(() => {
13
13
  if (arrayItem) {
14
- return (React.createElement(Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop },
14
+ return (React.createElement(Button, { view: "flat", className: b('remove-button'), onClick: input.onDrop, qa: `${name}-remove-item` },
15
15
  React.createElement(Icon, { data: Xmark, size: 16 })));
16
16
  }
17
17
  return null;
18
- }, [input.onDrop, arrayItem]);
18
+ }, [input.onDrop, arrayItem, name]);
19
19
  return (React.createElement("div", { className: b({
20
20
  'array-item': arrayItem && !arrOrObjFlag,
21
21
  'without-max-width': arrOrObjFlag,
@@ -32,7 +32,7 @@
32
32
  font-size: var(--yc-text-body3-font-size);
33
33
  }
34
34
  .df-simple-vertical-accordeon__tooltip {
35
- margin-right: 8px;
35
+ margin: 0px 5px;
36
36
  }
37
37
  .df-simple-vertical-accordeon__tooltip .yc-help-popover {
38
38
  display: flex;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import './SimpleVerticalAccordeon.css';
3
3
  interface SimpleVerticalAccordeonProps {
4
4
  children: React.ReactNode;
5
+ name: string;
5
6
  title: string;
6
7
  titleSize?: 's' | 'm' | 'l';
7
8
  note?: string;
@@ -44,7 +44,7 @@ export class SimpleVerticalAccordeon extends React.Component {
44
44
  this.checkVisibility();
45
45
  }
46
46
  render() {
47
- const { titleSize, children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, } = this.props;
47
+ const { titleSize, children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
48
48
  const { open, hidden, isFirstRender } = this.state;
49
49
  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)));
50
50
  if (viewLayout && !isFirstRender && hidden) {
@@ -52,7 +52,7 @@ export class SimpleVerticalAccordeon extends React.Component {
52
52
  }
53
53
  return (Boolean(React.Children.count(children)) && (React.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
54
54
  React.createElement("div", { className: b('header') },
55
- React.createElement(Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick },
55
+ React.createElement(Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick, qa: `${name}-accordeon-toggler` },
56
56
  React.createElement("b", { className: b('title', { size: titleSize }) }, this.getTitle()),
57
57
  React.createElement(Icon, { data: ChevronDown, className: b('chevron', { open }), size: 16 })),
58
58
  this.getTooltip(),
@@ -1,2 +1,2 @@
1
1
  import { ArrayViewLayoutProps, ObjectViewLayoutProps } from '../../../../core';
2
- export declare const ViewAccordeon: <T extends ArrayViewLayoutProps | ObjectViewLayoutProps>({ value, spec, children, }: T) => JSX.Element | null;
2
+ export declare const ViewAccordeon: <T extends ArrayViewLayoutProps | ObjectViewLayoutProps>({ name, value, spec, children, }: T) => JSX.Element | null;
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { isNotEmptyValue } from '../../../utils';
3
3
  import { SimpleVerticalAccordeon } from '../../SimpleVerticalAccordeon';
4
- export const ViewAccordeon = ({ value, spec, children, }) => {
4
+ export const ViewAccordeon = ({ name, value, spec, children, }) => {
5
5
  const [open, setOpen] = React.useState(true);
6
6
  if (!isNotEmptyValue(value, spec)) {
7
7
  return null;
8
8
  }
9
- return (React.createElement(SimpleVerticalAccordeon, { title: spec.viewSpec.layoutTitle || '', open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true }, children));
9
+ return (React.createElement(SimpleVerticalAccordeon, { name: name, title: spec.viewSpec.layoutTitle || '', open: open, onOpenChange: setOpen, hideInsteadOfDestroy: true, withBranchView: true, viewLayout: true }, children));
10
10
  };
@@ -1,2 +1,2 @@
1
1
  import { ArrayViewLayoutProps, ObjectViewLayoutProps } from '../../../../core';
2
- export declare const ViewAccordeonCard: <T extends ArrayViewLayoutProps | ObjectViewLayoutProps>({ value, spec, children, }: T) => JSX.Element | null;
2
+ export declare const ViewAccordeonCard: <T extends ArrayViewLayoutProps | ObjectViewLayoutProps>({ name, value, spec, children, }: T) => JSX.Element | null;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { AccordeonCard } from '../../';
3
3
  import { isNotEmptyValue } from '../../../utils';
4
- export const ViewAccordeonCard = ({ value, spec, children, }) => {
4
+ export const ViewAccordeonCard = ({ name, value, spec, children, }) => {
5
5
  const [open, setOpen] = React.useState(true);
6
6
  const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);
7
7
  if (!isNotEmptyValue(value, spec)) {
8
8
  return null;
9
9
  }
10
- return (React.createElement(AccordeonCard, { header: spec.viewSpec.layoutTitle || '', open: open, onToggle: onToggle, className: "df-accordeon-card-layout" }, children));
10
+ return (React.createElement(AccordeonCard, { name: name, header: spec.viewSpec.layoutTitle || '', open: open, onToggle: onToggle, className: "df-accordeon-card-layout" }, children));
11
11
  };
@@ -1,2 +1,2 @@
1
1
  import { ArrayViewLayoutProps, ObjectViewLayoutProps } from '../../../core';
2
- export declare const ViewCardAccordeon: <T extends ArrayViewLayoutProps | ObjectViewLayoutProps>({ value, spec, children, }: T) => JSX.Element | null;
2
+ export declare const ViewCardAccordeon: <T extends ArrayViewLayoutProps | ObjectViewLayoutProps>({ name, value, spec, children, }: T) => JSX.Element | null;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { Card } from '../';
3
3
  import { isNotEmptyValue } from '../../utils';
4
- export const ViewCardAccordeon = ({ value, spec, children, }) => {
4
+ export const ViewCardAccordeon = ({ name, value, spec, children, }) => {
5
5
  const [open, setOpen] = React.useState(true);
6
6
  const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);
7
7
  if (!isNotEmptyValue(value, spec)) {
8
8
  return null;
9
9
  }
10
- return (React.createElement(Card, { title: spec.viewSpec.layoutTitle, open: open, onToggle: onToggle, checkEmptyBody: true }, children));
10
+ return (React.createElement(Card, { name: name, title: spec.viewSpec.layoutTitle, open: open, onToggle: onToggle, checkEmptyBody: true }, children));
11
11
  };
@@ -1,2 +1,2 @@
1
1
  import { FormValue, Spec, ViewLayoutProps } from '../../../core';
2
- export declare const ViewCardSection: <T extends FormValue, S extends Spec>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
2
+ export declare const ViewCardSection: <T extends FormValue, S extends Spec>({ name, value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Card } from '../../components';
3
3
  import { isNotEmptyValue } from '../../utils';
4
- export const ViewCardSection = ({ value, spec, children, }) => {
4
+ export const ViewCardSection = ({ name, value, spec, children, }) => {
5
5
  if (!isNotEmptyValue(value, spec)) {
6
6
  return null;
7
7
  }
8
- return (React.createElement(Card, { title: spec.viewSpec.layoutTitle, alwaysOpen: true, checkEmptyBody: true }, children));
8
+ return (React.createElement(Card, { name: name, title: spec.viewSpec.layoutTitle, alwaysOpen: true, checkEmptyBody: true }, children));
9
9
  };
@@ -19,5 +19,5 @@ export const CardOneOfView = (props) => {
19
19
  if (!value || !Object.keys(value).length) {
20
20
  return null;
21
21
  }
22
- return (React.createElement(Card, { title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
22
+ return (React.createElement(Card, { name: name, title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
23
23
  };
@@ -1,10 +1,25 @@
1
+ import { __rest } from "tslib";
1
2
  import React from 'react';
3
+ import _ from 'lodash';
2
4
  import { ViewController } from '../../../../core';
3
5
  const OBJECT_VALUE_PROPERTY_NAME = 'value';
4
- export const ObjectValueInputView = ({ spec, name }) => {
5
- const specProperties = Object.assign({}, spec.properties);
6
- if (!specProperties[OBJECT_VALUE_PROPERTY_NAME]) {
6
+ export const ObjectValueInputView = (_a) => {
7
+ var { spec, name, Layout } = _a, restProps = __rest(_a, ["spec", "name", "Layout"]);
8
+ const childSpec = React.useMemo(() => {
9
+ var _a;
10
+ if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME]) {
11
+ const childSpec = _.cloneDeep(spec.properties[OBJECT_VALUE_PROPERTY_NAME]);
12
+ childSpec.viewSpec.layout = '';
13
+ return childSpec;
14
+ }
15
+ return undefined;
16
+ }, [spec.properties]);
17
+ if (!childSpec) {
7
18
  return null;
8
19
  }
9
- return (React.createElement(ViewController, { spec: specProperties[OBJECT_VALUE_PROPERTY_NAME], name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}` }));
20
+ const content = (React.createElement(ViewController, { spec: childSpec, name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}` }));
21
+ if (Layout) {
22
+ return (React.createElement(Layout, Object.assign({ spec: spec, name: name }, restProps), content));
23
+ }
24
+ return React.createElement(React.Fragment, null, content);
10
25
  };
@@ -24,5 +24,5 @@ export const OneOfCardView = (props) => {
24
24
  if (!value || !Object.keys(value).length) {
25
25
  return null;
26
26
  }
27
- return (React.createElement(AccordeonCard, { className: "df-accordeon-card-layout", header: wrappedValue, open: open, onToggle: onToggle, ignoreHeaderToggle: true }, specProperties[valueKey] ? (React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
27
+ return (React.createElement(AccordeonCard, { className: "df-accordeon-card-layout", name: name, header: wrappedValue, open: open, onToggle: onToggle, ignoreHeaderToggle: true }, specProperties[valueKey] ? (React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
28
28
  };
@@ -1,12 +1,27 @@
1
+ import { __rest } from "tslib";
1
2
  import React from 'react';
2
- import { ViewController } from '../../../../core';
3
+ import _ from 'lodash';
4
+ import { ViewController, isStringSpec } from '../../../../core';
3
5
  const TEXT_LINK_PROPERTY_NAME = 'text';
4
- export const TextLinkView = ({ value, spec, name }) => {
5
- const specProperties = spec.properties;
6
- const preparedSpec = React.useMemo(() => {
6
+ export const TextLinkView = (_a) => {
7
+ var { value, spec, name, Layout } = _a, restProps = __rest(_a, ["value", "spec", "name", "Layout"]);
8
+ const childSpec = React.useMemo(() => {
7
9
  var _a;
8
- return specProperties && specProperties[TEXT_LINK_PROPERTY_NAME]
9
- ? Object.assign(Object.assign({}, specProperties[TEXT_LINK_PROPERTY_NAME]), { viewSpec: Object.assign(Object.assign({}, (_a = specProperties[TEXT_LINK_PROPERTY_NAME]) === null || _a === void 0 ? void 0 : _a.viewSpec), { link: value === null || value === void 0 ? void 0 : value.link }) }) : undefined;
10
- }, [specProperties, value === null || value === void 0 ? void 0 : value.link]);
11
- return preparedSpec ? (React.createElement(ViewController, { spec: preparedSpec, name: `${name}.${TEXT_LINK_PROPERTY_NAME}` })) : null;
10
+ if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME]) &&
11
+ isStringSpec(spec.properties[TEXT_LINK_PROPERTY_NAME])) {
12
+ const childSpec = _.cloneDeep(spec.properties[TEXT_LINK_PROPERTY_NAME]);
13
+ childSpec.viewSpec.layout = '';
14
+ childSpec.viewSpec.link = value === null || value === void 0 ? void 0 : value.link;
15
+ return childSpec;
16
+ }
17
+ return undefined;
18
+ }, [spec.properties, value === null || value === void 0 ? void 0 : value.link]);
19
+ if (!childSpec || !(value === null || value === void 0 ? void 0 : value.text)) {
20
+ return null;
21
+ }
22
+ const content = React.createElement(ViewController, { spec: childSpec, name: `${name}.${TEXT_LINK_PROPERTY_NAME}` });
23
+ if (Layout) {
24
+ return (React.createElement(Layout, Object.assign({ spec: spec, name: name, value: value }, restProps), content));
25
+ }
26
+ return React.createElement(React.Fragment, null, content);
12
27
  };
@@ -3,7 +3,7 @@ import { RadioButton, Select } from '@gravity-ui/uikit';
3
3
  import _ from 'lodash';
4
4
  const MAX_TAB_TITLE_LENGTH = 20;
5
5
  export const useOneOf = ({ props, onTogglerChange }) => {
6
- const { input, spec, Layout } = props;
6
+ const { name, input, spec, Layout } = props;
7
7
  const specProperties = React.useMemo(() => (_.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
8
8
  const [oneOfValue, setOneOfValue] = React.useState(() => {
9
9
  let valueKeys;
@@ -37,10 +37,10 @@ export const useOneOf = ({ props, onTogglerChange }) => {
37
37
  const togglerInput = React.useMemo(() => {
38
38
  if (options.length > 3 ||
39
39
  _.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH)) {
40
- return (React.createElement(Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: spec.viewSpec.disabled, filterable: options.length > 7 }));
40
+ return (React.createElement(Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: spec.viewSpec.disabled, filterable: options.length > 7, qa: name }));
41
41
  }
42
- return (React.createElement(RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: spec.viewSpec.disabled }, options.map((option) => (React.createElement(RadioButton.Option, { key: option.value, value: option.value }, option.title)))));
43
- }, [options, oneOfValue, onOneOfChange]);
42
+ return (React.createElement(RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: spec.viewSpec.disabled, qa: name }, options.map((option) => (React.createElement(RadioButton.Option, { key: option.value, value: option.value }, option.title)))));
43
+ }, [options, oneOfValue, onOneOfChange, name]);
44
44
  const toggler = React.useMemo(() => {
45
45
  if (Layout) {
46
46
  return React.createElement(Layout, Object.assign({}, props), togglerInput);