Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib/kit/components/Layouts/Row/Row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,19 @@

&__right {
display: flex;
flex-direction: column;
flex-grow: 1;
margin-left: 15px;

&-inner {
display: flex;
}
}

&__description {
margin-top: 10px;
color: var(--yc-color-text-secondary);
word-break: break-word;
}

&__remove-button {
Expand Down
49 changes: 35 additions & 14 deletions src/lib/kit/components/Layouts/Row/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ import './Row.scss';

const b = block('row');

export const Row = <T extends FieldValue, S extends Spec>({
interface RowProps {
verboseDescription?: boolean;
}

const RowBase = <T extends FieldValue, S extends Spec>({
name,
spec,
input,
meta,
verboseDescription,
children,
}: LayoutProps<T, S>) => {
}: LayoutProps<T, S> & RowProps) => {
const arrayItem = React.useMemo(() => isArrayItem(name), [name]);

return (
Expand All @@ -35,7 +40,7 @@ export const Row = <T extends FieldValue, S extends Spec>({
{spec.viewSpec.layoutTitle}
{spec.required && <span className={b('required-mark')}>*</span>}
</div>
{spec.viewSpec.layoutDescription ? (
{!verboseDescription && spec.viewSpec.layoutDescription ? (
<div className={b('note')}>
<HelpPopover
htmlContent={spec.viewSpec.layoutDescription}
Expand All @@ -46,19 +51,35 @@ export const Row = <T extends FieldValue, S extends Spec>({
</div>
</div>
<div className={b('right')}>
<ErrorWrapper
name={name}
meta={meta}
withoutChildErrorStyles={isArraySpec(spec) || isObjectSpec(spec)}
>
{children}
</ErrorWrapper>
{arrayItem ? (
<Button view="flat" className={b('remove-button')} onClick={input.onDrop}>
<Icon data={Xmark} size={16} />
</Button>
<div className={b('right-inner')}>
<ErrorWrapper
name={name}
meta={meta}
withoutChildErrorStyles={isArraySpec(spec) || isObjectSpec(spec)}
>
{children}
</ErrorWrapper>
{arrayItem ? (
<Button view="flat" className={b('remove-button')} onClick={input.onDrop}>
<Icon data={Xmark} size={16} />
</Button>
) : null}
</div>
{verboseDescription && spec.viewSpec.layoutDescription ? (
<div
className={b('description')}
dangerouslySetInnerHTML={{__html: spec.viewSpec.layoutDescription}}
/>
) : null}
</div>
</div>
);
};

export const Row = <T extends FieldValue, S extends Spec>(props: LayoutProps<T, S>) => (
<RowBase {...props} />
);

export const RowVerbose = <T extends FieldValue, S extends Spec>(props: LayoutProps<T, S>) => (
<RowBase verboseDescription {...props} />
);
6 changes: 6 additions & 0 deletions src/lib/kit/constants/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
OneOfView,
Row,
Row2,
RowVerbose,
Secret,
Section,
Section2,
Expand Down Expand Up @@ -76,6 +77,7 @@ export const dynamicConfig: DynamicFormConfig = {
},
layouts: {
row: Row,
row_verbose: RowVerbose,
accordeon: Accordeon,
section: Section,
section2: Section2,
Expand All @@ -96,6 +98,7 @@ export const dynamicConfig: DynamicFormConfig = {
},
layouts: {
row: Row,
row_verbose: RowVerbose,
table_item: TableCell,
},
validators: {
Expand All @@ -108,6 +111,7 @@ export const dynamicConfig: DynamicFormConfig = {
},
layouts: {
row: Row,
row_verbose: RowVerbose,
table_item: TableCell,
transparent: Transparent,
},
Expand All @@ -124,6 +128,7 @@ export const dynamicConfig: DynamicFormConfig = {
},
layouts: {
row: Row,
row_verbose: RowVerbose,
accordeon: Accordeon,
section: Section,
section2: Section2,
Expand All @@ -149,6 +154,7 @@ export const dynamicConfig: DynamicFormConfig = {
},
layouts: {
row: Row,
row_verbose: RowVerbose,
table_item: TableCell,
transparent: Transparent,
section: Section,
Expand Down