Skip to content

Commit 78d6bb3

Browse files
authored
Merge branch 'main' into dynamic-docs
2 parents fd91f73 + ad76cf0 commit 78d6bb3

29 files changed

+428
-3
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## [4.15.0](https://github.com/gravity-ui/dynamic-forms/compare/v4.14.3...v4.15.0) (2024-12-12)
4+
5+
6+
### Features
7+
8+
* add column view ([#257](https://github.com/gravity-ui/dynamic-forms/issues/257)) ([0138f29](https://github.com/gravity-ui/dynamic-forms/commit/0138f29f1352d4e1fb5b62efa5e40c446a09412a))
9+
10+
11+
### Bug Fixes
12+
13+
* Fix meta types ([#255](https://github.com/gravity-ui/dynamic-forms/issues/255)) ([e7a710c](https://github.com/gravity-ui/dynamic-forms/commit/e7a710ce90c48440c35624dd2c5b093adb9f39d5))
14+
15+
## [4.14.3](https://github.com/gravity-ui/dynamic-forms/compare/v4.14.2...v4.14.3) (2024-11-29)
16+
17+
18+
### Bug Fixes
19+
20+
* fix remove button for array item object ([#251](https://github.com/gravity-ui/dynamic-forms/issues/251)) ([f156e5b](https://github.com/gravity-ui/dynamic-forms/commit/f156e5b8ecd230da2de3de52422a3ec182c653bf))
21+
322
## [4.14.2](https://github.com/gravity-ui/dynamic-forms/compare/v4.14.1...v4.14.2) (2024-11-12)
423

524

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gravity-ui/dynamic-forms",
3-
"version": "4.14.2",
3+
"version": "4.15.0",
44
"description": "",
55
"license": "MIT",
66
"main": "build/cjs/index.js",

src/lib/core/components/Form/types/field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ export interface FieldRenderProps<Value extends FieldValue> {
3333
valid: boolean;
3434
visited: boolean;
3535
submitFailed: boolean;
36+
childErrors: Record<string, ValidateError>;
3637
};
3738
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@import '../../../styles/variables.scss';
2+
3+
.#{$ns}column {
4+
margin-bottom: 15px;
5+
6+
&:last-child {
7+
margin-bottom: 0;
8+
}
9+
10+
&__first-row {
11+
min-height: 28px;
12+
display: flex;
13+
margin-bottom: auto;
14+
flex-direction: column;
15+
flex-shrink: 0;
16+
17+
&-inner {
18+
display: inline;
19+
margin-top: auto;
20+
margin-bottom: auto;
21+
}
22+
23+
&::after {
24+
content: '';
25+
width: 100%;
26+
flex-shrink: 1;
27+
}
28+
}
29+
30+
&__title {
31+
word-break: break-word;
32+
margin-right: 3px;
33+
34+
&_required {
35+
&::after {
36+
content: '*';
37+
color: var(--g-color-text-danger);
38+
}
39+
}
40+
}
41+
42+
&__note {
43+
position: relative;
44+
45+
&-inner {
46+
position: absolute;
47+
margin-top: 1px;
48+
49+
.g-help-popover {
50+
display: flex;
51+
52+
& > span {
53+
display: flex;
54+
}
55+
}
56+
}
57+
}
58+
59+
&__second-row {
60+
display: flex;
61+
flex-direction: column;
62+
flex-grow: 1;
63+
64+
&-inner {
65+
display: flex;
66+
justify-content: space-around;
67+
}
68+
}
69+
70+
&__remove-button {
71+
margin-left: 5px;
72+
}
73+
74+
&__required-mark {
75+
color: var(--g-color-text-danger);
76+
}
77+
78+
&__error-wrapper {
79+
min-width: 100%;
80+
}
81+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import React from 'react';
2+
3+
import {HelpPopover} from '@gravity-ui/components';
4+
import {TrashBin} from '@gravity-ui/icons';
5+
import {Button, Icon, Text} from '@gravity-ui/uikit';
6+
7+
import {
8+
FieldValue,
9+
LayoutProps,
10+
Spec,
11+
StringSpec,
12+
isArrayItem,
13+
isArraySpec,
14+
isObjectSpec,
15+
withGenerateButton,
16+
} from '../../../../core';
17+
import {ErrorWrapper, GenerateRandomValueButton} from '../../../components';
18+
import {block} from '../../../utils';
19+
20+
import './Column.scss';
21+
22+
const b = block('column');
23+
24+
interface ColumnProps {}
25+
26+
const ColumnBase = <T extends FieldValue, S extends Spec>({
27+
name,
28+
spec,
29+
input,
30+
meta,
31+
children,
32+
}: LayoutProps<T, undefined, undefined, S> & ColumnProps) => {
33+
const arrayItem = React.useMemo(() => isArrayItem(name), [name]);
34+
const generateButton = React.useMemo(() => withGenerateButton(spec), [spec]);
35+
36+
return (
37+
<div className={b()}>
38+
<div className={b('first-row')}>
39+
<div className={b('first-row-inner')}>
40+
<Text className={b('title', {required: spec.required})}>
41+
{spec.viewSpec.layoutTitle}
42+
</Text>
43+
{spec.viewSpec.layoutDescription ? (
44+
<span className={b('note')}>
45+
<Text className={b('note-inner')}>
46+
<HelpPopover
47+
htmlContent={spec.viewSpec.layoutDescription}
48+
placement={['bottom', 'top']}
49+
/>
50+
</Text>
51+
</span>
52+
) : null}
53+
</div>
54+
</div>
55+
<div className={b('second-row')}>
56+
<div className={b('second-row-inner')}>
57+
<ErrorWrapper
58+
name={name}
59+
meta={meta}
60+
withoutChildErrorStyles={
61+
// TODO: remove condition spec.viewSpec.type !== 'select'
62+
(isArraySpec(spec) && spec.viewSpec.type !== 'select') ||
63+
isObjectSpec(spec)
64+
}
65+
className={b('error-wrapper')}
66+
>
67+
{children}
68+
</ErrorWrapper>
69+
{generateButton ? (
70+
<GenerateRandomValueButton
71+
spec={spec as StringSpec}
72+
onChange={input.onChange as (value: string) => void}
73+
/>
74+
) : null}
75+
{arrayItem ? (
76+
<Button
77+
view="flat-secondary"
78+
className={b('remove-button')}
79+
onClick={input.onDrop}
80+
qa={`${name}-remove-item`}
81+
>
82+
<Icon data={TrashBin} size={16} />
83+
</Button>
84+
) : null}
85+
</div>
86+
</div>
87+
</div>
88+
);
89+
};
90+
91+
export const Column = <T extends FieldValue, S extends Spec>(
92+
props: LayoutProps<T, undefined, undefined, S>,
93+
) => <ColumnBase {...props} />;
Loading
18.6 KB
Loading
Loading
Loading

0 commit comments

Comments
 (0)