@gravity-ui/dynamic-forms 3.4.1 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/lib/core/components/Form/Controller/utils.js +7 -8
- package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.css +13 -11
- package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +12 -5
- package/build/cjs/lib/kit/components/Card/Card.css +0 -6
- package/build/cjs/lib/kit/components/Card/Card.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.css +0 -4
- package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +0 -5
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +23 -14
- package/build/cjs/lib/kit/components/Inputs/Select/Select.js +23 -14
- package/build/cjs/lib/kit/components/Inputs/Text/Text.js +2 -11
- package/build/cjs/lib/kit/components/Inputs/TextArea/TextArea.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Accordeon/Accordeon.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.css +3 -0
- package/build/cjs/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.js +29 -0
- package/build/cjs/lib/kit/components/Layouts/AccordeonCard/index.js +4 -0
- package/build/cjs/lib/kit/components/Layouts/CardAccordeon.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/CardSection.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Row/Row.js +2 -2
- package/build/cjs/lib/kit/components/Layouts/Section/Section.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/index.js +1 -0
- package/build/cjs/lib/kit/components/LongValue/LongValue.css +0 -6
- package/build/cjs/lib/kit/components/LongValue/LongValue.js +12 -1
- package/build/cjs/lib/kit/components/{Layouts/Accordeon → RemoveButton}/RemoveButton.js +1 -1
- package/build/cjs/lib/kit/components/RemoveButton/index.js +4 -0
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +0 -15
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +14 -3
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +16 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeonCard/index.js +4 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +0 -6
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +2 -1
- package/build/cjs/lib/kit/components/ViewLayouts/index.js +1 -0
- package/build/cjs/lib/kit/components/Views/NumberWithScaleView/NumberWithScaleView.js +1 -3
- package/build/cjs/lib/kit/components/Views/TextAreaView/TextAreaView.css +0 -8
- package/build/cjs/lib/kit/components/Views/TextAreaView/TextAreaView.js +1 -1
- package/build/cjs/lib/kit/constants/config.js +4 -0
- package/build/esm/lib/core/components/Form/Controller/utils.js +7 -8
- package/build/esm/lib/core/components/Form/hooks/useGenerateRandomValue.d.ts +1 -1
- package/build/esm/lib/core/components/Form/types/array.d.ts +6 -6
- package/build/esm/lib/core/components/Form/types/boolean.d.ts +6 -6
- package/build/esm/lib/core/components/Form/types/input.d.ts +2 -0
- package/build/esm/lib/core/components/Form/types/layout.d.ts +1 -0
- package/build/esm/lib/core/components/Form/types/number.d.ts +6 -6
- package/build/esm/lib/core/components/Form/types/object.d.ts +6 -6
- package/build/esm/lib/core/components/Form/types/string.d.ts +6 -6
- package/build/esm/lib/core/helpers.d.ts +5 -5
- package/build/esm/lib/core/types/specs.d.ts +15 -5
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.css +13 -11
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.d.ts +1 -0
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +13 -6
- package/build/esm/lib/kit/components/Card/Card.css +0 -6
- package/build/esm/lib/kit/components/Card/Card.js +2 -2
- package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +1 -1
- package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.css +0 -4
- package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.js +2 -2
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +0 -5
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.js +2 -2
- package/build/esm/lib/kit/components/Inputs/MultiSelect/MultiSelect.d.ts +5 -1
- package/build/esm/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +23 -14
- package/build/esm/lib/kit/components/Inputs/Select/Select.d.ts +5 -1
- package/build/esm/lib/kit/components/Inputs/Select/Select.js +23 -14
- package/build/esm/lib/kit/components/Inputs/Text/Text.d.ts +4 -1
- package/build/esm/lib/kit/components/Inputs/Text/Text.js +2 -11
- package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.d.ts +4 -1
- package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.d.ts +1 -1
- package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.js +1 -1
- package/build/esm/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.css +3 -0
- package/build/esm/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.d.ts +3 -0
- package/build/esm/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.js +25 -0
- package/build/esm/lib/kit/components/Layouts/AccordeonCard/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Layouts/AccordeonCard/index.js +1 -0
- package/build/esm/lib/kit/components/Layouts/CardAccordeon.js +1 -1
- package/build/esm/lib/kit/components/Layouts/CardSection.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Row/Row.js +3 -3
- package/build/esm/lib/kit/components/Layouts/Section/Section.js +2 -2
- package/build/esm/lib/kit/components/Layouts/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Layouts/index.js +1 -0
- package/build/esm/lib/kit/components/LongValue/LongValue.css +0 -6
- package/build/esm/lib/kit/components/LongValue/LongValue.js +12 -1
- package/build/esm/lib/kit/components/{Layouts/Accordeon → RemoveButton}/RemoveButton.js +1 -1
- package/build/esm/lib/kit/components/RemoveButton/index.d.ts +1 -0
- package/build/esm/lib/kit/components/RemoveButton/index.js +1 -0
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +0 -15
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.d.ts +1 -0
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +15 -4
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.d.ts +2 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +11 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/index.d.ts +1 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/index.js +1 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +0 -6
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +2 -1
- package/build/esm/lib/kit/components/ViewLayouts/index.d.ts +1 -0
- package/build/esm/lib/kit/components/ViewLayouts/index.js +1 -0
- package/build/esm/lib/kit/components/Views/NumberWithScaleView/NumberWithScaleView.js +2 -4
- package/build/esm/lib/kit/components/Views/TextAreaView/TextAreaView.css +0 -8
- package/build/esm/lib/kit/components/Views/TextAreaView/TextAreaView.js +2 -2
- package/build/esm/lib/kit/constants/config.js +5 -1
- package/package.json +1 -1
- /package/build/esm/lib/kit/components/{Layouts/Accordeon → RemoveButton}/RemoveButton.d.ts +0 -0
|
@@ -4,25 +4,34 @@ import { transformArrIn, transformArrOut } from '../../../../core';
|
|
|
4
4
|
import { block } from '../../../utils';
|
|
5
5
|
import './MultiSelect.css';
|
|
6
6
|
const b = block('multi-select');
|
|
7
|
-
export const MultiSelect = ({ name, input, spec }) => {
|
|
7
|
+
export const MultiSelect = ({ name, input, spec, inputProps }) => {
|
|
8
8
|
var _a, _b, _c, _d;
|
|
9
9
|
const { value, onBlur, onChange, onFocus } = input;
|
|
10
10
|
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]);
|
|
11
|
+
const { withCustomOptions, options: externalOptions } = inputProps || {};
|
|
11
12
|
const options = React.useMemo(() => {
|
|
12
13
|
var _a;
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
return withCustomOptions
|
|
15
|
+
? externalOptions || []
|
|
16
|
+
: (_a = spec.enum) === null || _a === void 0 ? void 0 : _a.map((id) => {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
return ({
|
|
19
|
+
id,
|
|
20
|
+
value: id,
|
|
21
|
+
text: ((_a = spec.description) === null || _a === void 0 ? void 0 : _a[id]) || id,
|
|
22
|
+
content: ((_c = (_b = spec.viewSpec.selectParams) === null || _b === void 0 ? void 0 : _b.meta) === null || _c === void 0 ? void 0 : _c[id]) ? (React.createElement("div", { key: id },
|
|
23
|
+
React.createElement(Text, null, ((_d = spec.description) === null || _d === void 0 ? void 0 : _d[id]) || id),
|
|
24
|
+
React.createElement(Text, { color: "secondary", className: b('meta-text') }, spec.viewSpec.selectParams.meta[id]))) : (((_e = spec.description) === null || _e === void 0 ? void 0 : _e[id]) || id),
|
|
25
|
+
key: id,
|
|
26
|
+
});
|
|
23
27
|
});
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
}, [
|
|
29
|
+
spec.enum,
|
|
30
|
+
spec.description,
|
|
31
|
+
(_b = spec.viewSpec.selectParams) === null || _b === void 0 ? void 0 : _b.meta,
|
|
32
|
+
externalOptions,
|
|
33
|
+
withCustomOptions,
|
|
34
|
+
]);
|
|
26
35
|
const renderOption = React.useCallback((option) => {
|
|
27
36
|
return React.createElement(React.Fragment, { key: option.value }, option.content || option.value);
|
|
28
37
|
}, []);
|
|
@@ -43,5 +52,5 @@ export const MultiSelect = ({ name, input, spec }) => {
|
|
|
43
52
|
}, [onFocus, onBlur]);
|
|
44
53
|
const _value = React.useMemo(() => transformArrOut(value), [value]);
|
|
45
54
|
const handleChange = React.useCallback((value) => onChange(transformArrIn(value)), [onChange]);
|
|
46
|
-
return (React.createElement(Select, { width: "max", className: b(), value: _value, options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder,
|
|
55
|
+
return (React.createElement(Select, Object.assign({ width: "max", className: b(), filterable: filterable, renderOption: renderOption, getOptionHeight: getOptionHeight }, inputProps, { value: _value, options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterPlaceholder: (_d = spec.viewSpec.selectParams) === null || _d === void 0 ? void 0 : _d.filterPlaceholder, multiple: true, qa: name })));
|
|
47
56
|
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { SelectProps as SelectBaseProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { StringInput } from '../../../../core';
|
|
2
3
|
import './Select.css';
|
|
3
|
-
export
|
|
4
|
+
export interface SelectProps extends Omit<SelectBaseProps, 'onUpdate' | 'value' | 'onOpenChange' | 'disabled' | 'placeholder' | 'filterPlaceholder' | 'multiple' | 'qa'> {
|
|
5
|
+
withCustomOptions?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const Select: StringInput<SelectProps>;
|
|
@@ -3,25 +3,34 @@ import { Select as SelectBase, Text } 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 = ({ name, input, spec }) => {
|
|
6
|
+
export const Select = ({ name, input, spec, inputProps }) => {
|
|
7
7
|
var _a, _b, _c, _d;
|
|
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]);
|
|
10
|
+
const { withCustomOptions, options: externalOptions } = inputProps || {};
|
|
10
11
|
const options = React.useMemo(() => {
|
|
11
12
|
var _a;
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
return withCustomOptions
|
|
14
|
+
? externalOptions || []
|
|
15
|
+
: (_a = spec.enum) === null || _a === void 0 ? void 0 : _a.map((id) => {
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
return ({
|
|
18
|
+
id,
|
|
19
|
+
value: id,
|
|
20
|
+
text: ((_a = spec.description) === null || _a === void 0 ? void 0 : _a[id]) || id,
|
|
21
|
+
content: ((_c = (_b = spec.viewSpec.selectParams) === null || _b === void 0 ? void 0 : _b.meta) === null || _c === void 0 ? void 0 : _c[id]) ? (React.createElement("div", { key: id },
|
|
22
|
+
React.createElement(Text, null, ((_d = spec.description) === null || _d === void 0 ? void 0 : _d[id]) || id),
|
|
23
|
+
React.createElement(Text, { color: "secondary", className: b('meta-text') }, spec.viewSpec.selectParams.meta[id]))) : (((_e = spec.description) === null || _e === void 0 ? void 0 : _e[id]) || id),
|
|
24
|
+
key: id,
|
|
25
|
+
});
|
|
22
26
|
});
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
}, [
|
|
28
|
+
spec.enum,
|
|
29
|
+
spec.description,
|
|
30
|
+
(_b = spec.viewSpec.selectParams) === null || _b === void 0 ? void 0 : _b.meta,
|
|
31
|
+
externalOptions,
|
|
32
|
+
withCustomOptions,
|
|
33
|
+
]);
|
|
25
34
|
const renderOption = React.useCallback((option) => {
|
|
26
35
|
return React.createElement(React.Fragment, { key: option.value }, option.content || option.value);
|
|
27
36
|
}, []);
|
|
@@ -41,5 +50,5 @@ export const Select = ({ name, input, spec }) => {
|
|
|
41
50
|
onBlur();
|
|
42
51
|
}
|
|
43
52
|
}, [onFocus, onBlur]);
|
|
44
|
-
return (React.createElement(SelectBase, { className: b(), width: "max", value: [value], options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder,
|
|
53
|
+
return (React.createElement(SelectBase, Object.assign({ className: b(), width: "max", filterable: filterable, getOptionHeight: getOptionHeight, renderOption: renderOption }, inputProps, { value: [value], options: options, onUpdate: handleChange, onOpenChange: handleToggle, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, filterPlaceholder: (_d = spec.viewSpec.selectParams) === null || _d === void 0 ? void 0 : _d.filterPlaceholder, qa: name })));
|
|
45
54
|
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { TextInputProps as TextInputBaseProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { NumberInputProps, StringInputProps } from '../../../../core';
|
|
2
|
-
export
|
|
3
|
+
export interface TextProps extends Omit<TextInputBaseProps, 'value' | 'onBlur' | 'onFocus' | 'onUpdate' | 'disabled' | 'placeholder' | 'qa'> {
|
|
4
|
+
}
|
|
5
|
+
export declare const Text: <T extends NumberInputProps<TextProps> | StringInputProps<TextProps>>({ name, input: { value, onBlur, onChange, onFocus }, spec, inputProps, }: T) => JSX.Element;
|
|
@@ -2,17 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { PasswordInput } from '@gravity-ui/components';
|
|
3
3
|
import { TextInput } from '@gravity-ui/uikit';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
export const Text = ({ name, input: { value, onBlur, onChange, onFocus }, spec, }) => {
|
|
6
|
-
const props = {
|
|
7
|
-
value: _.isNil(value) ? '' : `${value}`,
|
|
8
|
-
hasClear: true,
|
|
9
|
-
onBlur: onBlur,
|
|
10
|
-
onFocus: onFocus,
|
|
11
|
-
onUpdate: onChange,
|
|
12
|
-
disabled: spec.viewSpec.disabled,
|
|
13
|
-
placeholder: spec.viewSpec.placeholder,
|
|
14
|
-
qa: name,
|
|
15
|
-
};
|
|
5
|
+
export const Text = ({ name, input: { value, onBlur, onChange, onFocus }, spec, inputProps, }) => {
|
|
6
|
+
const props = Object.assign(Object.assign({ hasClear: true }, inputProps), { value: _.isNil(value) ? '' : `${value}`, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name });
|
|
16
7
|
if (spec.viewSpec.type === 'password') {
|
|
17
8
|
return (React.createElement(PasswordInput, Object.assign({}, props, { autoComplete: "new-password", showCopyButton: true, showRevealButton: true })));
|
|
18
9
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { TextAreaProps as TextAreaBaseProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { StringInput } from '../../../../core';
|
|
2
|
-
export
|
|
3
|
+
export interface TextAreaProps extends Omit<TextAreaBaseProps, 'value' | 'onBlur' | 'onFocus' | 'onUpdate' | 'disabled' | 'placeholder' | 'qa'> {
|
|
4
|
+
}
|
|
5
|
+
export declare const TextArea: StringInput<TextAreaProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextArea as TextAreaBase } from '@gravity-ui/uikit';
|
|
3
|
-
export const TextArea = ({ name, input, spec }) => {
|
|
3
|
+
export const TextArea = ({ name, input, spec, inputProps }) => {
|
|
4
4
|
const { value, onBlur, onChange, onFocus } = input;
|
|
5
|
-
return (React.createElement(TextAreaBase, { value: value || '', onBlur: onBlur, onFocus: onFocus, onUpdate: onChange,
|
|
5
|
+
return (React.createElement(TextAreaBase, Object.assign({ maxRows: 20, minRows: 8, hasClear: true }, inputProps, { value: value || '', onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name })));
|
|
6
6
|
};
|
|
@@ -25,7 +25,7 @@ export const TextContent = (_a) => {
|
|
|
25
25
|
iconLib ? (React.createElement(Text, { color: (_b = spec.viewSpec.textContentParams) === null || _b === void 0 ? void 0 : _b.iconColor, className: b('icon') }, iconLib)) : null,
|
|
26
26
|
content,
|
|
27
27
|
input.value ? (React.createElement(React.Fragment, null,
|
|
28
|
-
React.createElement(
|
|
28
|
+
React.createElement(Text, { className: b('separator') }, ":"),
|
|
29
29
|
React.createElement(Text, { color: "secondary" }, input.value))) : null));
|
|
30
30
|
}
|
|
31
31
|
if (Layout) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ArrayLayoutProps, ObjectLayoutProps } from '../../../../core';
|
|
2
|
-
export declare const Accordeon: <T extends ArrayLayoutProps | ObjectLayoutProps
|
|
2
|
+
export declare const Accordeon: <T extends ArrayLayoutProps<{}> | ObjectLayoutProps<{}>>({ name, spec, input, meta, children, }: T) => JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ErrorWrapper } from '../../../components';
|
|
3
3
|
import { useErrorChecker } from '../../../hooks';
|
|
4
|
+
import { RemoveButton } from '../../RemoveButton';
|
|
4
5
|
import { SimpleVerticalAccordeon } from '../../SimpleVerticalAccordeon';
|
|
5
|
-
import { RemoveButton } from './RemoveButton';
|
|
6
6
|
export const Accordeon = ({ name, spec, input, meta, children, }) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const [open, setOpen] = React.useState(Boolean((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useErrorChecker } from '../../../hooks';
|
|
3
|
+
import { block } from '../../../utils';
|
|
4
|
+
import { AccordeonCard } from '../../AccordeonCard';
|
|
5
|
+
import { ErrorWrapper } from '../../ErrorWrapper';
|
|
6
|
+
import { RemoveButton } from '../../RemoveButton';
|
|
7
|
+
import './AccordeonCardForm.css';
|
|
8
|
+
const b = block('accordeon-card-form');
|
|
9
|
+
export const AccordeonCardForm = ({ name, spec, input, children, meta, }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const [open, setOpen] = React.useState(Boolean((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen));
|
|
12
|
+
const onDrop = React.useCallback(() => {
|
|
13
|
+
setOpen(false);
|
|
14
|
+
input.onDrop();
|
|
15
|
+
}, [input.onDrop, setOpen]);
|
|
16
|
+
const removeButton = React.useMemo(() => {
|
|
17
|
+
if (spec.required || !input.value) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return React.createElement(RemoveButton, { name: name, onDrop: onDrop });
|
|
21
|
+
}, [spec.required, input.value, onDrop, name]);
|
|
22
|
+
useErrorChecker({ name, meta, open, setOpen });
|
|
23
|
+
return (React.createElement(AccordeonCard, { classNameBody: b('accordeon-card-body'), name: name, header: spec.viewSpec.layoutTitle || '', description: spec.viewSpec.layoutDescription || '', open: open, onToggle: setOpen, headerActionsTemplate: removeButton },
|
|
24
|
+
React.createElement(ErrorWrapper, { name: name, meta: meta, withoutChildErrorStyles: true }, children)));
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AccordeonCardForm';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AccordeonCardForm';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Card, ErrorWrapper } from '../../components';
|
|
3
3
|
import { useErrorChecker } from '../../hooks';
|
|
4
|
-
import { RemoveButton } from '
|
|
4
|
+
import { RemoveButton } from '../RemoveButton';
|
|
5
5
|
export const CardAccordeon = ({ name, spec, input, meta, children, }) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const [open, setOpen] = React.useState(Boolean((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Card, ErrorWrapper } from '../../components';
|
|
3
|
-
import { RemoveButton } from '
|
|
3
|
+
import { RemoveButton } from '../RemoveButton';
|
|
4
4
|
export const CardSection = ({ name, spec, input, meta, children, }) => {
|
|
5
5
|
const removeButton = React.useMemo(() => {
|
|
6
6
|
if (spec.required || !input.value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HelpPopover } from '@gravity-ui/components';
|
|
3
3
|
import { TrashBin } from '@gravity-ui/icons';
|
|
4
|
-
import { Button, Icon } from '@gravity-ui/uikit';
|
|
4
|
+
import { Button, Icon, Text } from '@gravity-ui/uikit';
|
|
5
5
|
import { isArrayItem, isArraySpec, isObjectSpec, withGenerateButton, } from '../../../../core';
|
|
6
6
|
import { ErrorWrapper, GenerateRandomValueButton } from '../../../components';
|
|
7
7
|
import { block } from '../../../utils';
|
|
@@ -13,9 +13,9 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
|
|
|
13
13
|
return (React.createElement("div", { className: b() },
|
|
14
14
|
React.createElement("div", { className: b('left') },
|
|
15
15
|
React.createElement("div", { className: b('left-inner') },
|
|
16
|
-
React.createElement(
|
|
16
|
+
React.createElement(Text, { className: b('title', { required: spec.required }) }, spec.viewSpec.layoutTitle),
|
|
17
17
|
!verboseDescription && spec.viewSpec.layoutDescription ? (React.createElement("span", { className: b('note') },
|
|
18
|
-
React.createElement(
|
|
18
|
+
React.createElement(Text, { className: b('note-inner') },
|
|
19
19
|
React.createElement(HelpPopover, { htmlContent: spec.viewSpec.layoutDescription, placement: ['bottom', 'top'] })))) : null)),
|
|
20
20
|
React.createElement("div", { className: b('right') },
|
|
21
21
|
React.createElement("div", { className: b('right-inner') },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { HelpPopover } from '@gravity-ui/components';
|
|
4
|
-
import { Popover } from '@gravity-ui/uikit';
|
|
4
|
+
import { Popover, Text } from '@gravity-ui/uikit';
|
|
5
5
|
import { GroupIndent } from '../../';
|
|
6
6
|
import { COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH, ErrorWrapper } from '../../../';
|
|
7
7
|
import { isArraySpec, isObjectSpec, } from '../../../../core';
|
|
@@ -29,7 +29,7 @@ const SectionBase = (_a) => {
|
|
|
29
29
|
} }));
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
description = (React.createElement(
|
|
32
|
+
description = (React.createElement(Text, { className: b('note') },
|
|
33
33
|
React.createElement(HelpPopover, { htmlContent: spec.viewSpec.layoutDescription, placement: ['bottom', 'top'] })));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Text } from '@gravity-ui/uikit';
|
|
2
3
|
import { block } from '../../utils';
|
|
3
4
|
import './LongValue.css';
|
|
4
5
|
const b = block('long-value');
|
|
@@ -8,6 +9,15 @@ export const LongValue = ({ value, className }) => {
|
|
|
8
9
|
const [open, setOpen] = React.useState(false);
|
|
9
10
|
const [long, setLong] = React.useState(false);
|
|
10
11
|
const handleClick = React.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
12
|
+
const currentTextProperies = React.useMemo(() => {
|
|
13
|
+
let wordBreak;
|
|
14
|
+
let whiteSpace;
|
|
15
|
+
if (open) {
|
|
16
|
+
wordBreak = 'break-all';
|
|
17
|
+
whiteSpace = 'break-spaces';
|
|
18
|
+
}
|
|
19
|
+
return { wordBreak, whiteSpace };
|
|
20
|
+
}, [open]);
|
|
11
21
|
React.useEffect(() => {
|
|
12
22
|
if (ref.current) {
|
|
13
23
|
if (value !== prevValue.current) {
|
|
@@ -29,5 +39,6 @@ export const LongValue = ({ value, className }) => {
|
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
});
|
|
32
|
-
return (React.createElement("div", { ref: ref,
|
|
42
|
+
return (React.createElement("div", { ref: ref, onClick: long ? handleClick : undefined },
|
|
43
|
+
React.createElement(Text, Object.assign({ className: b({ long }, className), ellipsis: true }, currentTextProperies), value)));
|
|
33
44
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Ellipsis } from '@gravity-ui/icons';
|
|
3
3
|
import { Button, DropdownMenu, Icon } from '@gravity-ui/uikit';
|
|
4
|
-
import i18n from '
|
|
4
|
+
import i18n from '../../i18n';
|
|
5
5
|
export const RemoveButton = ({ name, onDrop }) => {
|
|
6
6
|
const items = React.useMemo(() => [{ text: i18n('label_delete'), action: onDrop, theme: 'danger' }], [onDrop]);
|
|
7
7
|
const switcher = React.useMemo(() => (React.createElement(Button, { view: "flat", qa: `${name}-drop-item` },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RemoveButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RemoveButton';
|
|
@@ -17,21 +17,6 @@
|
|
|
17
17
|
margin-left: -13px;
|
|
18
18
|
max-width: 533px;
|
|
19
19
|
}
|
|
20
|
-
.df-simple-vertical-accordeon__title {
|
|
21
|
-
font-weight: 500;
|
|
22
|
-
}
|
|
23
|
-
.df-simple-vertical-accordeon__title_size_s {
|
|
24
|
-
margin-bottom: 0;
|
|
25
|
-
font-size: var(--g-text-body-1-font-size);
|
|
26
|
-
}
|
|
27
|
-
.df-simple-vertical-accordeon__title_size_m {
|
|
28
|
-
margin-bottom: 1px;
|
|
29
|
-
font-size: var(--g-text-body2-font-size);
|
|
30
|
-
}
|
|
31
|
-
.df-simple-vertical-accordeon__title_size_l {
|
|
32
|
-
margin-bottom: 2px;
|
|
33
|
-
font-size: var(--g-text-body3-font-size);
|
|
34
|
-
}
|
|
35
20
|
.df-simple-vertical-accordeon__tooltip {
|
|
36
21
|
margin: 0px 5px;
|
|
37
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HelpPopover } from '@gravity-ui/components';
|
|
3
3
|
import { ChevronDown } from '@gravity-ui/icons';
|
|
4
|
-
import { Button, Icon, Popover } from '@gravity-ui/uikit';
|
|
4
|
+
import { Button, Icon, Popover, Text } from '@gravity-ui/uikit';
|
|
5
5
|
import { COMMON_POPOVER_PLACEMENT } from '../../constants/common';
|
|
6
6
|
import { block } from '../../utils';
|
|
7
7
|
import './SimpleVerticalAccordeon.css';
|
|
@@ -49,7 +49,7 @@ export class SimpleVerticalAccordeon extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
render() {
|
|
51
51
|
var _a;
|
|
52
|
-
const {
|
|
52
|
+
const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
|
|
53
53
|
const { open, hidden, isFirstRender } = this.state;
|
|
54
54
|
const content = hideInsteadOfDestroy ? (React.createElement("div", { ref: this.componentRef, className: b('body', { hidden: !open }) }, children)) : (open && (React.createElement("div", { ref: this.componentRef, className: b('body', contentClassName) }, children)));
|
|
55
55
|
if (viewLayout && !isFirstRender && hidden) {
|
|
@@ -57,11 +57,12 @@ export class SimpleVerticalAccordeon extends React.Component {
|
|
|
57
57
|
}
|
|
58
58
|
const title = this.getTitle();
|
|
59
59
|
const titlePopoverDisabled = (((_a = this.titleRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0) <= TITLE_TEXT_MAX_WIDTH;
|
|
60
|
+
const currentTitleVariant = this.getCurrentTitleVariant();
|
|
60
61
|
return (Boolean(React.Children.count(children)) && (React.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
|
|
61
62
|
React.createElement("div", { className: b('header') },
|
|
62
63
|
React.createElement(Popover, { content: title, disabled: titlePopoverDisabled, placement: COMMON_POPOVER_PLACEMENT },
|
|
63
64
|
React.createElement(Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick, qa: `${name}-accordeon-toggler`, width: "auto" },
|
|
64
|
-
React.createElement(
|
|
65
|
+
React.createElement(Text, { variant: currentTitleVariant }, title),
|
|
65
66
|
React.createElement(Icon, { data: ChevronDown, className: b('chevron', { open }), size: 16 }))),
|
|
66
67
|
this.getTooltip(),
|
|
67
68
|
headerActionsTemplate ? headerActionsTemplate : null),
|
|
@@ -74,9 +75,19 @@ export class SimpleVerticalAccordeon extends React.Component {
|
|
|
74
75
|
}
|
|
75
76
|
return this.state.open ? openTitle : title;
|
|
76
77
|
}
|
|
78
|
+
getCurrentTitleVariant() {
|
|
79
|
+
const { titleSize } = this.props;
|
|
80
|
+
if (titleSize === 'm') {
|
|
81
|
+
return 'body-2';
|
|
82
|
+
}
|
|
83
|
+
if (titleSize === 'l') {
|
|
84
|
+
return 'body-3';
|
|
85
|
+
}
|
|
86
|
+
return 'body-1';
|
|
87
|
+
}
|
|
77
88
|
getTooltip() {
|
|
78
89
|
const { note } = this.props;
|
|
79
|
-
return note ? (React.createElement(
|
|
90
|
+
return note ? (React.createElement(Text, { className: b('tooltip') },
|
|
80
91
|
React.createElement(HelpPopover, { htmlContent: note, placement: ['bottom', 'top'] }))) : null;
|
|
81
92
|
}
|
|
82
93
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { isNotEmptyValue } from '../../../utils';
|
|
4
|
+
import { AccordeonCard } from '../../AccordeonCard';
|
|
5
|
+
export const ViewAccordeonCard = ({ value, name, spec, children, }) => {
|
|
6
|
+
const [open, setOpen] = React.useState(_.isBoolean(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true);
|
|
7
|
+
if (!isNotEmptyValue(value, spec)) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (React.createElement(AccordeonCard, { name: name, header: spec.viewSpec.layoutTitle || '', open: open, onToggle: setOpen }, children));
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ViewAccordeonCard';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ViewAccordeonCard';
|
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
align-items: baseline;
|
|
15
15
|
overflow: hidden;
|
|
16
16
|
}
|
|
17
|
-
.df-view-row__title {
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
text-overflow: ellipsis;
|
|
21
|
-
color: var(--g-color-text-secondary);
|
|
22
|
-
}
|
|
23
17
|
.df-view-row__dots {
|
|
24
18
|
min-width: 40px;
|
|
25
19
|
flex-grow: 1;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Text } from '@gravity-ui/uikit';
|
|
2
3
|
import { CopyButton } from '../../../../kit';
|
|
3
4
|
import { block, isNotEmptyValue } from '../../../utils';
|
|
4
5
|
import './ViewRow.css';
|
|
@@ -9,7 +10,7 @@ export const ViewRow = ({ value, spec, children, }) => {
|
|
|
9
10
|
}
|
|
10
11
|
return (React.createElement("div", { className: b() },
|
|
11
12
|
React.createElement("div", { className: b('left') },
|
|
12
|
-
React.createElement(
|
|
13
|
+
React.createElement(Text, { whiteSpace: "nowrap", color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
|
|
13
14
|
React.createElement("div", { className: b('dots') })),
|
|
14
15
|
React.createElement("div", { className: b('right') }, children),
|
|
15
16
|
React.createElement(CopyButton, { spec: spec, value: value })));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Popover } from '@gravity-ui/uikit';
|
|
2
|
+
import { Popover, Text } from '@gravity-ui/uikit';
|
|
3
3
|
import { block, isCorrectSizeParams } from '../../../utils';
|
|
4
4
|
import { useInitial } from '../../Inputs/NumberWithScale/useInitial';
|
|
5
5
|
import './NumberWithScaleView.css';
|
|
@@ -9,8 +9,6 @@ const NumberWithScaleViewBase = ({ spec, value }) => {
|
|
|
9
9
|
const { scale } = spec.viewSpec.sizeParams;
|
|
10
10
|
return (React.createElement("div", { className: b() },
|
|
11
11
|
React.createElement(Popover, { placement: ['bottom', 'top'], content: initialValue, className: b('tooltip-container'), contentClassName: b('tooltip'), disabled: initialValue.length < 26 }, initialValue),
|
|
12
|
-
React.createElement(
|
|
13
|
-
" ",
|
|
14
|
-
scale[initialType].title)));
|
|
12
|
+
React.createElement(Text, { className: b('size') }, scale[initialType].title)));
|
|
15
13
|
};
|
|
16
14
|
export const NumberWithScaleView = (props) => isCorrectSizeParams(props.spec) && props.value ? React.createElement(NumberWithScaleViewBase, Object.assign({}, props)) : null;
|
|
@@ -4,14 +4,6 @@
|
|
|
4
4
|
.df-text-area-view_active {
|
|
5
5
|
cursor: pointer;
|
|
6
6
|
}
|
|
7
|
-
.df-text-area-view__text-view {
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
text-overflow: ellipsis;
|
|
10
|
-
}
|
|
11
|
-
.df-text-area-view__text-view_open {
|
|
12
|
-
white-space: pre-wrap;
|
|
13
|
-
overflow-wrap: break-word;
|
|
14
|
-
}
|
|
15
7
|
.df-text-area-view__chevron {
|
|
16
8
|
margin: 3px;
|
|
17
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChevronDown } from '@gravity-ui/icons';
|
|
3
|
-
import { Icon } from '@gravity-ui/uikit';
|
|
3
|
+
import { Icon, Text } from '@gravity-ui/uikit';
|
|
4
4
|
import { block } from '../../../utils';
|
|
5
5
|
import './TextAreaView.css';
|
|
6
6
|
const b = block('text-area-view');
|
|
@@ -11,7 +11,7 @@ export const TextAreaView = ({ value = '' }) => {
|
|
|
11
11
|
setIsOpen(!isOpen);
|
|
12
12
|
}, [isOpen]);
|
|
13
13
|
return (React.createElement("div", { className: b({ active: isValueLong }), onClick: isValueLong ? handleClick : undefined },
|
|
14
|
-
React.createElement(
|
|
14
|
+
React.createElement(Text, { ellipsis: true, whiteSpace: isOpen ? 'break-spaces' : undefined }, value),
|
|
15
15
|
isValueLong ? (React.createElement("div", null,
|
|
16
16
|
React.createElement(Icon, { data: ChevronDown, className: b('chevron', { open: isOpen }), size: 16 }))) : null));
|
|
17
17
|
};
|