@gravity-ui/dynamic-forms 1.8.1 → 1.9.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 (73) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/cjs/lib/core/components/Form/DynamicField.js +2 -2
  3. package/build/cjs/lib/core/components/Form/constants.js +1 -2
  4. package/build/cjs/lib/core/components/Form/hooks/useField.js +18 -14
  5. package/build/cjs/lib/core/components/Form/hooks/useIntegrationFF.js +19 -4
  6. package/build/cjs/lib/core/components/Form/utils/common.js +1 -3
  7. package/build/cjs/lib/kit/components/CopyButton/CopyButton.css +4 -0
  8. package/build/cjs/lib/kit/components/CopyButton/CopyButton.js +20 -0
  9. package/build/cjs/lib/kit/components/CopyButton/index.js +4 -0
  10. package/build/cjs/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +3 -6
  11. package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +1 -2
  12. package/build/cjs/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -3
  13. package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +1 -2
  14. package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.js +2 -3
  15. package/build/cjs/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +1 -2
  16. package/build/cjs/lib/kit/components/Inputs/Secret/Secret.js +1 -2
  17. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -6
  18. package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +1 -2
  19. package/build/cjs/lib/kit/components/Layouts/Transparent/Transparent.css +3 -0
  20. package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +3 -0
  21. package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +3 -1
  22. package/build/cjs/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.css +9 -3
  23. package/build/cjs/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.js +7 -1
  24. package/build/cjs/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.css +4 -0
  25. package/build/cjs/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.js +4 -1
  26. package/build/cjs/lib/kit/components/index.js +1 -0
  27. package/build/cjs/lib/kit/constants/config.js +5 -0
  28. package/build/cjs/lib/kit/hooks/useOneOf/index.js +4 -0
  29. package/build/cjs/lib/kit/hooks/useOneOf/useOneOf.css +4 -0
  30. package/build/cjs/lib/kit/hooks/{useOneOf.js → useOneOf/useOneOf.js} +15 -7
  31. package/build/cjs/lib/kit/styles/mixins.css +0 -0
  32. package/build/esm/lib/core/components/Form/DynamicField.d.ts +1 -0
  33. package/build/esm/lib/core/components/Form/DynamicField.js +2 -2
  34. package/build/esm/lib/core/components/Form/constants.d.ts +0 -1
  35. package/build/esm/lib/core/components/Form/constants.js +0 -1
  36. package/build/esm/lib/core/components/Form/hooks/useField.d.ts +1 -1
  37. package/build/esm/lib/core/components/Form/hooks/useField.js +19 -15
  38. package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.d.ts +1 -1
  39. package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.js +19 -4
  40. package/build/esm/lib/core/components/Form/types/field.d.ts +1 -0
  41. package/build/esm/lib/core/components/Form/utils/common.js +2 -4
  42. package/build/esm/lib/core/types/specs.d.ts +2 -0
  43. package/build/esm/lib/kit/components/CopyButton/CopyButton.css +4 -0
  44. package/build/esm/lib/kit/components/CopyButton/CopyButton.d.ts +12 -0
  45. package/build/esm/lib/kit/components/CopyButton/CopyButton.js +16 -0
  46. package/build/esm/lib/kit/components/CopyButton/index.d.ts +1 -0
  47. package/build/esm/lib/kit/components/CopyButton/index.js +1 -0
  48. package/build/esm/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +4 -7
  49. package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +1 -2
  50. package/build/esm/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -3
  51. package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +1 -2
  52. package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.js +2 -3
  53. package/build/esm/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +1 -2
  54. package/build/esm/lib/kit/components/Inputs/Secret/Secret.js +1 -2
  55. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +4 -7
  56. package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +1 -2
  57. package/build/esm/lib/kit/components/Layouts/Transparent/Transparent.css +3 -0
  58. package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +3 -0
  59. package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +3 -1
  60. package/build/esm/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.css +9 -3
  61. package/build/esm/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.js +7 -1
  62. package/build/esm/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.css +4 -0
  63. package/build/esm/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.js +4 -1
  64. package/build/esm/lib/kit/components/index.d.ts +1 -0
  65. package/build/esm/lib/kit/components/index.js +1 -0
  66. package/build/esm/lib/kit/constants/config.js +5 -0
  67. package/build/esm/lib/kit/hooks/useOneOf/index.d.ts +1 -0
  68. package/build/esm/lib/kit/hooks/useOneOf/index.js +1 -0
  69. package/build/esm/lib/kit/hooks/useOneOf/useOneOf.css +4 -0
  70. package/build/esm/lib/kit/hooks/{useOneOf.d.ts → useOneOf/useOneOf.d.ts} +3 -2
  71. package/build/esm/lib/kit/hooks/{useOneOf.js → useOneOf/useOneOf.js} +16 -7
  72. package/build/esm/lib/kit/styles/mixins.css +0 -0
  73. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.1](https://github.com/gravity-ui/dynamic-forms/compare/v1.9.0...v1.9.1) (2023-06-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * fixed styles for transperant and toggler oneof ([#60](https://github.com/gravity-ui/dynamic-forms/issues/60)) ([64ca12a](https://github.com/gravity-ui/dynamic-forms/commit/64ca12ad87ffd50fdda24901cd8f2e70e8c03868))
9
+
10
+ ## [1.9.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.8.1...v1.9.0) (2023-06-07)
11
+
12
+
13
+ ### Features
14
+
15
+ * add ability to disable final-form insertion delay ([#56](https://github.com/gravity-ui/dynamic-forms/issues/56)) ([4df2b00](https://github.com/gravity-ui/dynamic-forms/commit/4df2b00c5b07bdacbbd399acdb5cf01af5521dbc))
16
+ * add copy button for view layouts ([#59](https://github.com/gravity-ui/dynamic-forms/issues/59)) ([c31fcbf](https://github.com/gravity-ui/dynamic-forms/commit/c31fcbfe0da0ba369cd16595b2cb9190ac4498f0))
17
+ * add store and entity unmount callbacks ([#55](https://github.com/gravity-ui/dynamic-forms/issues/55)) ([8f7c4c6](https://github.com/gravity-ui/dynamic-forms/commit/8f7c4c6a624941e10c624dc3098e4e601639d25e))
18
+
3
19
  ## [1.8.1](https://github.com/gravity-ui/dynamic-forms/compare/v1.8.0...v1.8.1) (2023-05-30)
4
20
 
5
21
 
@@ -9,11 +9,11 @@ const helpers_1 = require("../../helpers");
9
9
  const Controller_1 = require("./Controller");
10
10
  const hooks_1 = require("./hooks");
11
11
  const utils_1 = require("./utils");
12
- const DynamicField = ({ name, spec, config, Monaco, search, __mirror, }) => {
12
+ const DynamicField = ({ name, spec, config, Monaco, search, withoutInsertFFDebounce, __mirror, }) => {
13
13
  const DynamicFormsCtx = (0, hooks_1.useCreateContext)();
14
14
  const SearchContext = (0, hooks_1.useCreateSearchContext)();
15
15
  const { tools, store } = (0, hooks_1.useStore)(name);
16
- const watcher = (0, hooks_1.useIntegrationFF)(store);
16
+ const watcher = (0, hooks_1.useIntegrationFF)(store, withoutInsertFFDebounce);
17
17
  const { store: searchStore, setField, removeField, isHiddenField } = (0, hooks_1.useSearchStore)();
18
18
  const context = react_1.default.useMemo(() => ({
19
19
  config,
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OBJECT_ARRAY_CNT = exports.OBJECT_ARRAY_FLAG = exports.REMOVED_ITEM = void 0;
4
- exports.REMOVED_ITEM = '____removed-item';
3
+ exports.OBJECT_ARRAY_CNT = exports.OBJECT_ARRAY_FLAG = void 0;
5
4
  exports.OBJECT_ARRAY_FLAG = '____arr-obj';
6
5
  exports.OBJECT_ARRAY_CNT = '____arr-obj-cnt';
@@ -7,14 +7,9 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const helpers_1 = require("../../../helpers");
8
8
  const constants_1 = require("../constants");
9
9
  const utils_1 = require("../utils");
10
- const useField = ({ name, spec, initialValue, value: externalValue, validate: propsValidate, tools, parentOnChange, parentOnUnmount, }) => {
10
+ const useField = ({ name, spec, initialValue, value: externalValue, validate: propsValidate, tools, parentOnChange, parentOnUnmount: externalParentOnUnmount, }) => {
11
11
  const firstRenderRef = react_1.default.useRef(true);
12
- const validate = react_1.default.useCallback((value) => {
13
- if (value === constants_1.REMOVED_ITEM) {
14
- return;
15
- }
16
- return propsValidate === null || propsValidate === void 0 ? void 0 : propsValidate((0, utils_1.transformArrOut)(value));
17
- }, [propsValidate]);
12
+ const validate = react_1.default.useCallback((value) => propsValidate === null || propsValidate === void 0 ? void 0 : propsValidate((0, utils_1.transformArrOut)(value)), [propsValidate]);
18
13
  const [state, setState] = react_1.default.useState(() => {
19
14
  let value = lodash_1.default.cloneDeep(externalValue);
20
15
  if (lodash_1.default.isNil(value)) {
@@ -55,7 +50,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
55
50
  const _value = lodash_1.default.isFunction(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
56
51
  const error = validate === null || validate === void 0 ? void 0 : validate(_value);
57
52
  let value = (0, utils_1.transformArrIn)(_value);
58
- if ((0, helpers_1.isNumberSpec)(spec) && value && value !== constants_1.REMOVED_ITEM && !error) {
53
+ if ((0, helpers_1.isNumberSpec)(spec) && value && !error) {
59
54
  value = Number(value);
60
55
  }
61
56
  let newChildErrors = Object.assign({}, state.childErrors);
@@ -71,20 +66,29 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
71
66
  };
72
67
  const onDrop = () => {
73
68
  if ((0, utils_1.isArrayItem)(name)) {
74
- onChange(constants_1.REMOVED_ITEM);
69
+ (externalParentOnUnmount ? externalParentOnUnmount : tools.onUnmount)(name);
75
70
  }
76
71
  else {
77
72
  onChange(undefined);
78
73
  }
79
74
  };
80
75
  return { onChange, onDrop };
81
- }, [initialValue, setState, name, validate, spec]);
76
+ }, [initialValue, setState, name, validate, spec, externalParentOnUnmount, tools.onUnmount]);
82
77
  const onBlur = react_1.default.useCallback(() => {
83
78
  setState((state) => (Object.assign(Object.assign({}, state), { active: false, touched: true })));
84
79
  }, [setState]);
85
80
  const onFocus = react_1.default.useCallback(() => {
86
81
  setState((state) => (Object.assign(Object.assign({}, state), { active: true, visited: true })));
87
82
  }, [setState]);
83
+ const parentOnUnmount = react_1.default.useCallback((childName) => {
84
+ if ((0, helpers_1.isArraySpec)(spec) || (0, helpers_1.isObjectSpec)(spec)) {
85
+ onChange((currentValue) => currentValue
86
+ ? lodash_1.default.omit(currentValue, childName.split(`${name}.`)[1])
87
+ : currentValue, {
88
+ [childName]: false,
89
+ });
90
+ }
91
+ }, [onChange, name, spec]);
88
92
  const renderProps = react_1.default.useMemo(() => {
89
93
  const onItemAdd = (_value) => {
90
94
  const stateValue = (state.value || {
@@ -96,9 +100,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
96
100
  setState((state) => (Object.assign(Object.assign({}, state), { dirty: !lodash_1.default.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value, visited: true })));
97
101
  };
98
102
  const onItemRemove = (idx) => {
99
- const value = Object.assign(Object.assign({}, state.value), { [`<${idx}>`]: constants_1.REMOVED_ITEM });
100
- const error = validate === null || validate === void 0 ? void 0 : validate(value);
101
- setState((state) => (Object.assign(Object.assign({}, state), { dirty: !lodash_1.default.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value, visited: true })));
103
+ parentOnUnmount(`${name}.<${idx}>`);
102
104
  };
103
105
  return {
104
106
  input: {
@@ -108,6 +110,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
108
110
  onBlur,
109
111
  onFocus,
110
112
  onDrop,
113
+ parentOnUnmount,
111
114
  },
112
115
  arrayInput: {
113
116
  name,
@@ -129,6 +132,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
129
132
  onBlur,
130
133
  onFocus,
131
134
  onDrop,
135
+ parentOnUnmount,
132
136
  ]);
133
137
  react_1.default.useEffect(() => {
134
138
  if (!firstRenderRef.current || !lodash_1.default.isEqual(externalValue, state.value) || state.error) {
@@ -138,7 +142,7 @@ const useField = ({ name, spec, initialValue, value: externalValue, validate: pr
138
142
  react_1.default.useEffect(() => {
139
143
  firstRenderRef.current = false;
140
144
  return () => {
141
- (parentOnUnmount ? parentOnUnmount : tools.onUnmount)(name);
145
+ (externalParentOnUnmount ? externalParentOnUnmount : tools.onUnmount)(name);
142
146
  };
143
147
  }, []);
144
148
  return renderProps;
@@ -7,7 +7,7 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
8
8
  const react_final_form_1 = require("react-final-form");
9
9
  const utils_1 = require("../utils");
10
- const useIntegrationFF = (store) => {
10
+ const useIntegrationFF = (store, withoutDebounce) => {
11
11
  const form = (0, react_final_form_1.useForm)();
12
12
  const watcher = react_1.default.useMemo(() => {
13
13
  const props = {
@@ -35,12 +35,27 @@ const useIntegrationFF = (store) => {
35
35
  };
36
36
  return react_1.default.createElement(react_final_form_1.Field, Object.assign({}, props));
37
37
  }, [store.name, store.errors]);
38
- const change = react_1.default.useCallback((0, debounce_1.default)((value) => {
39
- form.change(store.name, lodash_1.default.get((0, utils_1.transformArrOut)(value), store.name));
40
- }, 100), [form.change, store.name]);
38
+ const change = react_1.default.useMemo(() => {
39
+ const cb = (value) => {
40
+ if (store.name) {
41
+ form.change(store.name, lodash_1.default.get((0, utils_1.transformArrOut)(value), store.name));
42
+ }
43
+ };
44
+ if (withoutDebounce) {
45
+ return cb;
46
+ }
47
+ return (0, debounce_1.default)(cb, 100);
48
+ }, [form.change, store.name, withoutDebounce]);
41
49
  react_1.default.useEffect(() => {
42
50
  change(store.values);
43
51
  }, [store.values]);
52
+ react_1.default.useEffect(() => {
53
+ return () => {
54
+ if (store.name) {
55
+ form.change(store.name, undefined);
56
+ }
57
+ };
58
+ }, []);
44
59
  return watcher;
45
60
  };
46
61
  exports.useIntegrationFF = useIntegrationFF;
@@ -32,9 +32,7 @@ const transformArrOut = (value) => {
32
32
  if (lodash_1.default.isObject(value) && !lodash_1.default.isArray(value)) {
33
33
  if (value[constants_2.OBJECT_ARRAY_FLAG]) {
34
34
  const _value = Object.keys(value)
35
- .filter((key) => key !== constants_2.OBJECT_ARRAY_FLAG &&
36
- key !== constants_2.OBJECT_ARRAY_CNT &&
37
- value[key] !== constants_2.REMOVED_ITEM)
35
+ .filter((key) => key !== constants_2.OBJECT_ARRAY_FLAG && key !== constants_2.OBJECT_ARRAY_CNT)
38
36
  .map((key) => key.split('<').join('').split('>').join(''))
39
37
  .sort((a, b) => Number(a) - Number(b))
40
38
  .map((key) => (0, exports.transformArrOut)(value[`<${key}>`]));
@@ -0,0 +1,4 @@
1
+ .df-copy-button {
2
+ display: none;
3
+ margin: 2px 0 0 5px;
4
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CopyButton = 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 core_1 = require("../../../core");
8
+ const utils_1 = require("../../utils");
9
+ const b = (0, utils_1.block)('copy-button');
10
+ /**
11
+ *
12
+ * Use the with-copy-button scss mixin for visible on hover
13
+ */
14
+ const CopyButton = ({ spec, value }) => {
15
+ if (((0, core_1.isStringSpec)(spec) || (0, core_1.isNumberSpec)(spec)) && spec.viewSpec.copy) {
16
+ return react_1.default.createElement(uikit_1.ClipboardButton, { className: b(), text: `${value}`, size: 14 });
17
+ }
18
+ return null;
19
+ };
20
+ exports.CopyButton = CopyButton;
@@ -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("./CopyButton"), exports);
@@ -9,9 +9,7 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
9
9
  const core_1 = require("../../../../core");
10
10
  const ArrayBase = ({ spec, name, arrayInput, input }) => {
11
11
  const keys = react_1.default.useMemo(() => Object.keys(arrayInput.value || {})
12
- .filter((k) => k !== core_1.OBJECT_ARRAY_FLAG &&
13
- k !== core_1.OBJECT_ARRAY_CNT &&
14
- arrayInput.value[k] !== core_1.REMOVED_ITEM)
12
+ .filter((k) => k !== core_1.OBJECT_ARRAY_FLAG && k !== core_1.OBJECT_ARRAY_CNT)
15
13
  .map((k) => k.split('<').join('').split('>').join(''))
16
14
  .sort((a, b) => Number(a) - Number(b)), [arrayInput.value]);
17
15
  const itemSpecCorrect = react_1.default.useMemo(() => (0, core_1.isCorrectSpec)(spec.items), [spec.items]);
@@ -39,15 +37,14 @@ const ArrayBase = ({ spec, name, arrayInput, input }) => {
39
37
  return itemSpec;
40
38
  }, [spec.items, itemSpecCorrect]);
41
39
  const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${input.name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
42
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
43
40
  const items = react_1.default.useMemo(() => keys.map((key, idx) => {
44
41
  var _a;
45
42
  const itemSpec = getItemSpec(idx);
46
43
  if (!itemSpec) {
47
44
  return null;
48
45
  }
49
- return (react_1.default.createElement(core_1.Controller, { value: (_a = input.value) === null || _a === void 0 ? void 0 : _a[`<${key}>`], parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, spec: itemSpec, name: `${name}.<${key}>`, key: `${name}.<${key}>` }));
50
- }), [keys.join(''), name, getItemSpec, parentOnChange, parentOnUnmount, input.value]);
46
+ return (react_1.default.createElement(core_1.Controller, { value: (_a = input.value) === null || _a === void 0 ? void 0 : _a[`<${key}>`], parentOnChange: parentOnChange, parentOnUnmount: input.parentOnUnmount, spec: itemSpec, name: `${name}.<${key}>`, key: `${name}.<${key}>` }));
47
+ }), [keys.join(''), name, getItemSpec, parentOnChange, input.parentOnUnmount, input.value]);
51
48
  if (!itemSpecCorrect) {
52
49
  return null;
53
50
  }
@@ -30,8 +30,7 @@ const CardOneOf = (props) => {
30
30
  const value = lodash_1.default.set({}, childName.split(`${input.name}.`).join(''), childValue);
31
31
  input.onChange(value, childErrors);
32
32
  }, [input.onChange, input.name]);
33
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
34
33
  (0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
35
- return (react_1.default.createElement(__1.Card, { name: name, title: toggler, description: spec.viewSpec.layoutDescription, actions: actions, open: open, onToggle: onToggle, disableHeaderToggle: true }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { value: (_a = input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
34
+ return (react_1.default.createElement(__1.Card, { name: name, title: toggler, description: spec.viewSpec.layoutDescription, actions: actions, open: open, onToggle: onToggle, disableHeaderToggle: true }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { value: (_a = input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: input.parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
36
35
  };
37
36
  exports.CardOneOf = CardOneOf;
@@ -16,7 +16,6 @@ const ObjectBase = (_a) => {
16
16
  spec.viewSpec.layoutTitle || null));
17
17
  }, [spec.defaultValue, spec.viewSpec.layoutTitle, restProps.input.onChange]);
18
18
  const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => restProps.input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${restProps.input.name}.`).join(''), childValue), childErrors), [restProps.input.onChange, restProps.input.name]);
19
- const parentOnUnmount = react_1.default.useCallback((childName) => restProps.input.onChange((currentValue) => currentValue, { [childName]: false }), [restProps.input.onChange]);
20
19
  const content = react_1.default.useMemo(() => {
21
20
  if (!lodash_1.default.isObjectLike(spec.properties) || !Object.keys(spec.properties || {}).length) {
22
21
  return null;
@@ -27,7 +26,7 @@ const ObjectBase = (_a) => {
27
26
  const specProperties = Object.assign({}, spec.properties);
28
27
  return (react_1.default.createElement(react_1.default.Fragment, null, (spec.viewSpec.order || Object.keys(specProperties)).map((property) => {
29
28
  var _a;
30
- return specProperties[property] ? (react_1.default.createElement(core_1.Controller, { value: (_a = restProps.input.value) === null || _a === void 0 ? void 0 : _a[property], spec: specProperties[property], name: `${name ? name + '.' : ''}${property}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount, key: `${name ? name + '.' : ''}${property}` })) : null;
29
+ return specProperties[property] ? (react_1.default.createElement(core_1.Controller, { value: (_a = restProps.input.value) === null || _a === void 0 ? void 0 : _a[property], spec: specProperties[property], name: `${name ? name + '.' : ''}${property}`, parentOnChange: parentOnChange, parentOnUnmount: restProps.input.parentOnUnmount, key: `${name ? name + '.' : ''}${property}` })) : null;
31
30
  })));
32
31
  }, [
33
32
  spec.properties,
@@ -36,7 +35,7 @@ const ObjectBase = (_a) => {
36
35
  restProps.input.value,
37
36
  addBtn,
38
37
  parentOnChange,
39
- parentOnUnmount,
38
+ restProps.input.parentOnUnmount,
40
39
  ]);
41
40
  if (!Layout || !content) {
42
41
  return content;
@@ -10,7 +10,6 @@ const ObjectValueInput = (props) => {
10
10
  var _a;
11
11
  const { spec, input, name, Layout } = props;
12
12
  const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
13
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
14
13
  const childSpec = react_1.default.useMemo(() => {
15
14
  var _a;
16
15
  if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME]) {
@@ -23,7 +22,7 @@ const ObjectValueInput = (props) => {
23
22
  if (!childSpec) {
24
23
  return null;
25
24
  }
26
- const content = (react_1.default.createElement(core_1.Controller, { value: (_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 }));
25
+ const content = (react_1.default.createElement(core_1.Controller, { value: (_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: input.parentOnUnmount }));
27
26
  if (Layout) {
28
27
  return react_1.default.createElement(Layout, Object.assign({}, props), content);
29
28
  }
@@ -16,14 +16,13 @@ const OneOfComponent = (props) => {
16
16
  const value = lodash_1.default.set({}, childName.split(`${props.input.name}.`).join(''), childValue);
17
17
  props.input.onChange(value, childErrors);
18
18
  }, [props.input.onChange, props.input.name]);
19
- const parentOnUnmount = react_1.default.useCallback((childName) => props.input.onChange((currentValue) => currentValue, { [childName]: false }), [props.input.onChange]);
20
19
  return (react_1.default.createElement("div", { className: b({
21
20
  base: !props.withoutIndent,
22
21
  flat: props.withoutIndent,
23
22
  }) },
24
- react_1.default.createElement("div", null, toggler),
23
+ toggler,
25
24
  specProperties[oneOfValue] ? (react_1.default.createElement(__1.GroupIndent, null,
26
- react_1.default.createElement(core_1.Controller, { value: (_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));
25
+ react_1.default.createElement(core_1.Controller, { value: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${props.name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: props.input.parentOnUnmount, key: `${props.name}.${oneOfValue}` }))) : null));
27
26
  };
28
27
  exports.OneOf = OneOfComponent;
29
28
  const OneOfFlat = (props) => (react_1.default.createElement(OneOfComponent, Object.assign({}, props, { withoutIndent: true })));
@@ -37,8 +37,7 @@ const OneOfCard = (props) => {
37
37
  const value = lodash_1.default.set({}, childName.split(`${input.name}.`).join(''), childValue);
38
38
  input.onChange(value, childErrors);
39
39
  }, [input.onChange, input.name]);
40
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
41
40
  (0, hooks_1.useErrorChecker)({ name, meta, open, setOpen });
42
- return (react_1.default.createElement(__1.AccordeonCard, { className: b(), name: name, header: toggler, description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, ignoreHeaderToggle: true, headerActionsTemplate: headerActionsTemplate }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { value: (_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));
41
+ return (react_1.default.createElement(__1.AccordeonCard, { className: b(), name: name, header: toggler, description: spec.viewSpec.layoutDescription || '', open: open, onToggle: onToggle, ignoreHeaderToggle: true, headerActionsTemplate: headerActionsTemplate }, specProperties[oneOfValue] ? (react_1.default.createElement(core_1.Controller, { value: (_a = props.input.value) === null || _a === void 0 ? void 0 : _a[oneOfValue], spec: specProperties[oneOfValue], name: `${name}.${oneOfValue}`, parentOnChange: parentOnChange, parentOnUnmount: input.parentOnUnmount, key: `${name}.${oneOfValue}` })) : null));
43
42
  };
44
43
  exports.OneOfCard = OneOfCard;
@@ -19,11 +19,10 @@ const Secret = (props) => {
19
19
  return undefined;
20
20
  }, [spec.properties]);
21
21
  const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${input.name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
22
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
23
22
  if (!childSpec) {
24
23
  return null;
25
24
  }
26
- const content = (react_1.default.createElement(core_1.Controller, { value: (_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}` }));
25
+ const content = (react_1.default.createElement(core_1.Controller, { value: (_a = input.value) === null || _a === void 0 ? void 0 : _a[SECRET_PROPERTY_NAME], spec: childSpec, name: `${name}.${SECRET_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: input.parentOnUnmount, key: `${name}.${SECRET_PROPERTY_NAME}` }));
27
26
  if (Layout) {
28
27
  return react_1.default.createElement(Layout, Object.assign({}, props), content);
29
28
  }
@@ -13,9 +13,7 @@ const b = (0, utils_1.block)('table-array');
13
13
  const TableArrayInput = ({ spec, name, arrayInput, input }) => {
14
14
  const { isHiddenField } = (0, hooks_1.useSearchContext)();
15
15
  const keys = react_1.default.useMemo(() => Object.keys(arrayInput.value || {})
16
- .filter((k) => k !== core_1.OBJECT_ARRAY_FLAG &&
17
- k !== core_1.OBJECT_ARRAY_CNT &&
18
- arrayInput.value[k] !== core_1.REMOVED_ITEM)
16
+ .filter((k) => k !== core_1.OBJECT_ARRAY_FLAG && k !== core_1.OBJECT_ARRAY_CNT)
19
17
  .map((k) => k.split('<').join('').split('>').join(''))
20
18
  .sort((a, b) => Number(a) - Number(b))
21
19
  .map((key) => ({
@@ -28,7 +26,6 @@ const TableArrayInput = ({ spec, name, arrayInput, input }) => {
28
26
  arrayInput.onItemRemove(key);
29
27
  }, [arrayInput.onItemRemove]);
30
28
  const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${input.name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
31
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
32
29
  const columns = react_1.default.useMemo(() => {
33
30
  const { items, viewSpec: { table }, } = spec;
34
31
  if (!(table === null || table === void 0 ? void 0 : table.length) || !(0, core_1.isObjectSpec)(items)) {
@@ -62,11 +59,11 @@ const TableArrayInput = ({ spec, name, arrayInput, input }) => {
62
59
  arr: (0, core_1.isArraySpec)(preparedEntitySpec),
63
60
  obj: (0, core_1.isObjectSpec)(preparedEntitySpec),
64
61
  }), key: `${name}.<${key}>.${property}` },
65
- react_1.default.createElement(core_1.Controller, { value: (_c = (_b = input.value) === null || _b === void 0 ? void 0 : _b[`<${key}>`]) === null || _c === void 0 ? void 0 : _c[property], spec: preparedEntitySpec, name: `${name}.<${key}>.${property}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount })));
62
+ react_1.default.createElement(core_1.Controller, { value: (_c = (_b = input.value) === null || _b === void 0 ? void 0 : _b[`<${key}>`]) === null || _c === void 0 ? void 0 : _c[property], spec: preparedEntitySpec, name: `${name}.<${key}>.${property}`, parentOnChange: parentOnChange, parentOnUnmount: lodash_1.default.noop })));
66
63
  },
67
64
  }));
68
65
  return [idxColumn, ...columns, removeColumn];
69
- }, [name, spec, onItemRemove, parentOnChange, parentOnUnmount, input.value]);
66
+ }, [name, spec, onItemRemove, parentOnChange, input.parentOnUnmount, input.value]);
70
67
  const getRowClassNames = react_1.default.useCallback(({ key }) => {
71
68
  var _a;
72
69
  const searchResult = (_a = spec.viewSpec.table) === null || _a === void 0 ? void 0 : _a.every(({ property }) => isHiddenField(`${name}.<${key}>.${property}`));
@@ -10,7 +10,6 @@ const TextLink = (props) => {
10
10
  var _a;
11
11
  const { spec, input, name, Layout } = props;
12
12
  const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
13
- const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
14
13
  const childSpec = react_1.default.useMemo(() => {
15
14
  var _a;
16
15
  if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME]) &&
@@ -24,7 +23,7 @@ const TextLink = (props) => {
24
23
  if (!childSpec) {
25
24
  return null;
26
25
  }
27
- const content = (react_1.default.createElement(core_1.Controller, { value: (_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 }));
26
+ const content = (react_1.default.createElement(core_1.Controller, { value: (_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: input.parentOnUnmount }));
28
27
  if (Layout) {
29
28
  return react_1.default.createElement(Layout, Object.assign({}, props), content);
30
29
  }
@@ -11,6 +11,9 @@
11
11
  .df-transparent_without-max-width {
12
12
  max-width: unset;
13
13
  }
14
+ .df-transparent_without-max-width > .df-error-wrapper {
15
+ width: unset;
16
+ }
14
17
  .df-transparent__remove-button {
15
18
  margin-left: 5px;
16
19
  }
@@ -37,4 +37,7 @@
37
37
  }
38
38
  .df-view-row__right > .df-view-transparent:last-child {
39
39
  margin-bottom: 0;
40
+ }
41
+ .df-view-row:hover > .df-copy-button {
42
+ display: block;
40
43
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewRow = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
+ const kit_1 = require("../../../../kit");
6
7
  const utils_1 = require("../../../utils");
7
8
  const b = (0, utils_1.block)('view-row');
8
9
  const ViewRow = ({ value, spec, children, }) => {
@@ -13,6 +14,7 @@ const ViewRow = ({ value, spec, children, }) => {
13
14
  react_1.default.createElement("div", { className: b('left') },
14
15
  react_1.default.createElement("div", { className: b('title'), title: spec.viewSpec.layoutTitle }, spec.viewSpec.layoutTitle),
15
16
  react_1.default.createElement("div", { className: b('dots') })),
16
- react_1.default.createElement("div", { className: b('right') }, children)));
17
+ react_1.default.createElement("div", { className: b('right') }, children),
18
+ react_1.default.createElement(kit_1.CopyButton, { spec: spec, value: value })));
17
19
  };
18
20
  exports.ViewRow = ViewRow;
@@ -1,14 +1,20 @@
1
1
  .df-view-table-cell {
2
2
  display: flex;
3
+ }
4
+ .df-view-table-cell__inner {
5
+ display: flex;
3
6
  flex-direction: column;
4
7
  justify-content: center;
5
8
  }
6
- .df-view-table-cell > .df-view-row:last-child {
9
+ .df-view-table-cell__inner > .df-view-row:last-child {
7
10
  margin-bottom: 0;
8
11
  }
9
- .df-view-table-cell > .df-view-transparent {
12
+ .df-view-table-cell__inner > .df-view-transparent {
10
13
  margin-bottom: 6px;
11
14
  }
12
- .df-view-table-cell > .df-view-transparent:last-child {
15
+ .df-view-table-cell__inner > .df-view-transparent:last-child {
13
16
  margin-bottom: 0;
17
+ }
18
+ .df-view-table-cell:hover > .df-copy-button {
19
+ display: block;
14
20
  }
@@ -3,7 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewTableCell = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
+ const kit_1 = require("../../../../kit");
6
7
  const utils_1 = require("../../../utils");
7
8
  const b = (0, utils_1.block)('view-table-cell');
8
- const ViewTableCell = ({ value, spec, children, }) => (react_1.default.createElement("div", { className: b() }, (0, utils_1.isNotEmptyValue)(value, spec) ? children : '—'));
9
+ const ViewTableCell = ({ value, spec, children, }) => {
10
+ const empty = (0, utils_1.isNotEmptyValue)(value, spec);
11
+ return (react_1.default.createElement("div", { className: b() }, empty ? (react_1.default.createElement(react_1.default.Fragment, null,
12
+ react_1.default.createElement("div", { className: b('inner') }, children),
13
+ react_1.default.createElement(kit_1.CopyButton, { spec: spec, value: value }))) : ('—')));
14
+ };
9
15
  exports.ViewTableCell = ViewTableCell;
@@ -1,6 +1,10 @@
1
1
  .df-view-transparent {
2
+ display: flex;
2
3
  margin-bottom: 20px;
3
4
  }
4
5
  .df-view-transparent:last-child {
5
6
  margin-bottom: 0;
7
+ }
8
+ .df-view-transparent:hover > .df-copy-button {
9
+ display: block;
6
10
  }
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewTransparent = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
+ const kit_1 = require("../../../../kit");
6
7
  const utils_1 = require("../../../utils");
7
8
  const b = (0, utils_1.block)('view-transparent');
8
- const ViewTransparent = ({ value, spec, children, }) => (0, utils_1.isNotEmptyValue)(value, spec) ? react_1.default.createElement("div", { className: b() }, children) : null;
9
+ const ViewTransparent = ({ value, spec, children, }) => (0, utils_1.isNotEmptyValue)(value, spec) ? (react_1.default.createElement("div", { className: b() },
10
+ react_1.default.createElement("div", null, children),
11
+ react_1.default.createElement(kit_1.CopyButton, { spec: spec, value: value }))) : null;
9
12
  exports.ViewTransparent = ViewTransparent;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./AccordeonCard"), exports);
5
5
  tslib_1.__exportStar(require("./Card"), exports);
6
+ tslib_1.__exportStar(require("./CopyButton"), exports);
6
7
  tslib_1.__exportStar(require("./ErrorWrapper"), exports);
7
8
  tslib_1.__exportStar(require("./GroupIndent"), exports);
8
9
  tslib_1.__exportStar(require("./Inputs"), exports);
@@ -212,6 +212,7 @@ exports.dynamicViewConfig = {
212
212
  },
213
213
  layouts: {
214
214
  row: components_1.ViewRow,
215
+ row_verbose: components_1.ViewRow,
215
216
  accordeon: components_1.ViewAccordeon,
216
217
  section: components_1.ViewSection,
217
218
  section2: components_1.ViewSection2,
@@ -230,6 +231,7 @@ exports.dynamicViewConfig = {
230
231
  },
231
232
  layouts: {
232
233
  row: components_1.ViewRow,
234
+ row_verbose: components_1.ViewRow,
233
235
  table_item: components_1.ViewTableCell,
234
236
  },
235
237
  },
@@ -239,6 +241,7 @@ exports.dynamicViewConfig = {
239
241
  },
240
242
  layouts: {
241
243
  row: components_1.ViewRow,
244
+ row_verbose: components_1.ViewRow,
242
245
  table_item: components_1.ViewTableCell,
243
246
  transparent: components_1.ViewTransparent,
244
247
  },
@@ -255,6 +258,7 @@ exports.dynamicViewConfig = {
255
258
  },
256
259
  layouts: {
257
260
  row: components_1.ViewRow,
261
+ row_verbose: components_1.ViewRow,
258
262
  accordeon: components_1.ViewAccordeon,
259
263
  section: components_1.ViewSection,
260
264
  section2: components_1.ViewSection2,
@@ -278,6 +282,7 @@ exports.dynamicViewConfig = {
278
282
  },
279
283
  layouts: {
280
284
  row: components_1.ViewRow,
285
+ row_verbose: components_1.ViewRow,
281
286
  table_item: components_1.ViewTableCell,
282
287
  transparent: components_1.ViewTransparent,
283
288
  section: components_1.ViewSection,
@@ -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("./useOneOf"), exports);
@@ -0,0 +1,4 @@
1
+ .df-use-oneof__toggler_radio > .df-row {
2
+ width: unset;
3
+ max-width: unset;
4
+ }
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const uikit_1 = require("@gravity-ui/uikit");
7
7
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
8
+ const utils_1 = require("../../utils");
9
+ const b = (0, utils_1.block)('use-oneof');
8
10
  const MAX_TAB_TITLE_LENGTH = 20;
9
11
  const useOneOf = ({ props, onTogglerChange }) => {
10
12
  var _a;
@@ -39,22 +41,28 @@ const useOneOf = ({ props, onTogglerChange }) => {
39
41
  content: title,
40
42
  };
41
43
  }), [spec.description, spec.viewSpec.order, specProperties]);
42
- const togglerInput = react_1.default.useMemo(() => {
44
+ const selectToggler = react_1.default.useMemo(() => {
43
45
  var _a, _b;
44
- if (((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) !== 'radio' &&
46
+ return ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) !== 'radio' &&
45
47
  (((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.toggler) === 'select' ||
46
48
  options.length > 3 ||
47
- lodash_1.default.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))) {
49
+ lodash_1.default.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH));
50
+ }, [options, (_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler]);
51
+ const togglerInput = react_1.default.useMemo(() => {
52
+ if (selectToggler) {
48
53
  return (react_1.default.createElement(uikit_1.Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: spec.viewSpec.disabled, filterable: options.length > 7, qa: name }));
49
54
  }
50
55
  return (react_1.default.createElement(uikit_1.RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: spec.viewSpec.disabled, qa: name }, options.map((option) => (react_1.default.createElement(uikit_1.RadioButton.Option, { key: option.value, value: option.value }, option.title)))));
51
- }, [options, oneOfValue, onOneOfChange, name, (_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler]);
56
+ }, [selectToggler, oneOfValue, spec.viewSpec.disabled, name, options, onOneOfChange]);
52
57
  const toggler = react_1.default.useMemo(() => {
53
58
  if (Layout) {
54
- return react_1.default.createElement(Layout, Object.assign({}, props), togglerInput);
59
+ return (react_1.default.createElement("div", { className: b('toggler', {
60
+ radio: !selectToggler,
61
+ }) },
62
+ react_1.default.createElement(Layout, Object.assign({}, props), togglerInput)));
55
63
  }
56
- return togglerInput;
57
- }, [Layout, togglerInput, props]);
64
+ return react_1.default.createElement("div", null, togglerInput);
65
+ }, [Layout, togglerInput, selectToggler, props]);
58
66
  return { oneOfValue, specProperties, toggler, togglerInput };
59
67
  };
60
68
  exports.useOneOf = useOneOf;
File without changes