@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.
- package/CHANGELOG.md +16 -0
- package/build/cjs/lib/core/components/Form/DynamicField.js +2 -2
- package/build/cjs/lib/core/components/Form/constants.js +1 -2
- package/build/cjs/lib/core/components/Form/hooks/useField.js +18 -14
- package/build/cjs/lib/core/components/Form/hooks/useIntegrationFF.js +19 -4
- package/build/cjs/lib/core/components/Form/utils/common.js +1 -3
- package/build/cjs/lib/kit/components/CopyButton/CopyButton.css +4 -0
- package/build/cjs/lib/kit/components/CopyButton/CopyButton.js +20 -0
- package/build/cjs/lib/kit/components/CopyButton/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +3 -6
- package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +1 -2
- package/build/cjs/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -3
- package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +1 -2
- package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.js +2 -3
- package/build/cjs/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +1 -2
- package/build/cjs/lib/kit/components/Inputs/Secret/Secret.js +1 -2
- package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +3 -6
- package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +1 -2
- package/build/cjs/lib/kit/components/Layouts/Transparent/Transparent.css +3 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +3 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +3 -1
- package/build/cjs/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.css +9 -3
- package/build/cjs/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.js +7 -1
- package/build/cjs/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.css +4 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.js +4 -1
- package/build/cjs/lib/kit/components/index.js +1 -0
- package/build/cjs/lib/kit/constants/config.js +5 -0
- package/build/cjs/lib/kit/hooks/useOneOf/index.js +4 -0
- package/build/cjs/lib/kit/hooks/useOneOf/useOneOf.css +4 -0
- package/build/cjs/lib/kit/hooks/{useOneOf.js → useOneOf/useOneOf.js} +15 -7
- package/build/cjs/lib/kit/styles/mixins.css +0 -0
- package/build/esm/lib/core/components/Form/DynamicField.d.ts +1 -0
- package/build/esm/lib/core/components/Form/DynamicField.js +2 -2
- package/build/esm/lib/core/components/Form/constants.d.ts +0 -1
- package/build/esm/lib/core/components/Form/constants.js +0 -1
- package/build/esm/lib/core/components/Form/hooks/useField.d.ts +1 -1
- package/build/esm/lib/core/components/Form/hooks/useField.js +19 -15
- package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.d.ts +1 -1
- package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.js +19 -4
- package/build/esm/lib/core/components/Form/types/field.d.ts +1 -0
- package/build/esm/lib/core/components/Form/utils/common.js +2 -4
- package/build/esm/lib/core/types/specs.d.ts +2 -0
- package/build/esm/lib/kit/components/CopyButton/CopyButton.css +4 -0
- package/build/esm/lib/kit/components/CopyButton/CopyButton.d.ts +12 -0
- package/build/esm/lib/kit/components/CopyButton/CopyButton.js +16 -0
- package/build/esm/lib/kit/components/CopyButton/index.d.ts +1 -0
- package/build/esm/lib/kit/components/CopyButton/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +4 -7
- package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +1 -2
- package/build/esm/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +2 -3
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +1 -2
- package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.js +2 -3
- package/build/esm/lib/kit/components/Inputs/OneOfCard/OneOfCard.js +1 -2
- package/build/esm/lib/kit/components/Inputs/Secret/Secret.js +1 -2
- package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +4 -7
- package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +1 -2
- package/build/esm/lib/kit/components/Layouts/Transparent/Transparent.css +3 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +3 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +3 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.css +9 -3
- package/build/esm/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.js +7 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.css +4 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.js +4 -1
- package/build/esm/lib/kit/components/index.d.ts +1 -0
- package/build/esm/lib/kit/components/index.js +1 -0
- package/build/esm/lib/kit/constants/config.js +5 -0
- package/build/esm/lib/kit/hooks/useOneOf/index.d.ts +1 -0
- package/build/esm/lib/kit/hooks/useOneOf/index.js +1 -0
- package/build/esm/lib/kit/hooks/useOneOf/useOneOf.css +4 -0
- package/build/esm/lib/kit/hooks/{useOneOf.d.ts → useOneOf/useOneOf.d.ts} +3 -2
- package/build/esm/lib/kit/hooks/{useOneOf.js → useOneOf/useOneOf.js} +16 -7
- package/build/esm/lib/kit/styles/mixins.css +0 -0
- package/package.json +2 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ObjectIndependentInputProps } from '
|
|
1
|
+
import { ObjectIndependentInputProps } from '../../../core';
|
|
2
|
+
import './useOneOf.css';
|
|
2
3
|
export interface UseOneOfParams {
|
|
3
4
|
props: ObjectIndependentInputProps;
|
|
4
5
|
onTogglerChange?: (value: string) => void;
|
|
5
6
|
}
|
|
6
7
|
export declare const useOneOf: ({ props, onTogglerChange }: UseOneOfParams) => {
|
|
7
8
|
oneOfValue: string;
|
|
8
|
-
specProperties: Record<string, import("
|
|
9
|
+
specProperties: Record<string, import("../../../core").Spec>;
|
|
9
10
|
toggler: JSX.Element;
|
|
10
11
|
togglerInput: JSX.Element;
|
|
11
12
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RadioButton, Select } from '@gravity-ui/uikit';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
+
import { block } from '../../utils';
|
|
5
|
+
import './useOneOf.css';
|
|
6
|
+
const b = block('use-oneof');
|
|
4
7
|
const MAX_TAB_TITLE_LENGTH = 20;
|
|
5
8
|
export const useOneOf = ({ props, onTogglerChange }) => {
|
|
6
9
|
var _a;
|
|
@@ -35,21 +38,27 @@ export const useOneOf = ({ props, onTogglerChange }) => {
|
|
|
35
38
|
content: title,
|
|
36
39
|
};
|
|
37
40
|
}), [spec.description, spec.viewSpec.order, specProperties]);
|
|
38
|
-
const
|
|
41
|
+
const selectToggler = React.useMemo(() => {
|
|
39
42
|
var _a, _b;
|
|
40
|
-
|
|
43
|
+
return ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) !== 'radio' &&
|
|
41
44
|
(((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.toggler) === 'select' ||
|
|
42
45
|
options.length > 3 ||
|
|
43
|
-
_.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))
|
|
46
|
+
_.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH));
|
|
47
|
+
}, [options, (_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler]);
|
|
48
|
+
const togglerInput = React.useMemo(() => {
|
|
49
|
+
if (selectToggler) {
|
|
44
50
|
return (React.createElement(Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: spec.viewSpec.disabled, filterable: options.length > 7, qa: name }));
|
|
45
51
|
}
|
|
46
52
|
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)))));
|
|
47
|
-
}, [
|
|
53
|
+
}, [selectToggler, oneOfValue, spec.viewSpec.disabled, name, options, onOneOfChange]);
|
|
48
54
|
const toggler = React.useMemo(() => {
|
|
49
55
|
if (Layout) {
|
|
50
|
-
return React.createElement(
|
|
56
|
+
return (React.createElement("div", { className: b('toggler', {
|
|
57
|
+
radio: !selectToggler,
|
|
58
|
+
}) },
|
|
59
|
+
React.createElement(Layout, Object.assign({}, props), togglerInput)));
|
|
51
60
|
}
|
|
52
|
-
return togglerInput;
|
|
53
|
-
}, [Layout, togglerInput, props]);
|
|
61
|
+
return React.createElement("div", null, togglerInput);
|
|
62
|
+
}, [Layout, togglerInput, selectToggler, props]);
|
|
54
63
|
return { oneOfValue, specProperties, toggler, togglerInput };
|
|
55
64
|
};
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/dynamic-forms",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "build/cjs/index.js",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@storybook/react": "^6.5.16",
|
|
58
58
|
"@testing-library/jest-dom": "^5.16.5",
|
|
59
59
|
"@testing-library/react": "^14.0.0",
|
|
60
|
+
"@testing-library/user-event": "^14.4.3",
|
|
60
61
|
"@types/jest": "^29.5.0",
|
|
61
62
|
"@types/lodash": "^4.14.180",
|
|
62
63
|
"@types/react": "^18.0.28",
|