Skip to content

Commit 2efbe6a

Browse files
committed
update enum array renderer
1 parent 631b7f9 commit 2efbe6a

File tree

3 files changed

+37
-36
lines changed

3 files changed

+37
-36
lines changed

packages/antd-renderers/src/complex/EnumArrayRenderer.tsx

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '@jsonforms/core';
1717

1818
import { withJsonFormsMultiEnumProps } from '@jsonforms/react';
19-
import { Form } from 'antd';
19+
import { Flex, Form } from 'antd';
2020
import isEmpty from 'lodash/isEmpty';
2121
import merge from 'lodash/merge';
2222
import React from 'react';
@@ -63,37 +63,37 @@ export const EnumArrayRenderer = ({
6363
label={label}
6464
help={!isValid ? errors : showDescription ? description : null}
6565
>
66-
{options.map((option: any, index: number) => {
67-
const optionPath = Paths.compose(path, `${index}`);
68-
const checkboxValue = data?.includes(option.value)
69-
? option.value
70-
: undefined;
71-
return (
72-
<AntdCheckbox
73-
id={id + '-label-' + option.value}
74-
key={option.value}
75-
label={option.label}
76-
isValid={isEmpty(errors)}
77-
path={optionPath}
78-
handleChange={(_childPath, newValue) =>
79-
newValue
80-
? addItem(path, option.value)
81-
: removeItem(path, option.value)
82-
}
83-
data={checkboxValue}
84-
errors={errors}
85-
schema={schema}
86-
visible={visible}
87-
rootSchema={rootSchema}
88-
uischema={uischema}
89-
enabled={enabled}
90-
inputProps={{
91-
onFocus,
92-
onBlur,
93-
}}
94-
/>
95-
);
96-
})}
66+
<Flex gap={2} vertical={appliedUiSchemaOptions.vertical}>
67+
{options.map((option: any, index: number) => {
68+
const optionPath = Paths.compose(path, `${index}`);
69+
const checkboxValue = data?.includes(option.value) ? true : false;
70+
return (
71+
<AntdCheckbox
72+
id={id + '-input-' + option.value}
73+
key={option.value}
74+
label={option.label}
75+
isValid={isEmpty(errors)}
76+
path={optionPath}
77+
handleChange={(_childPath, newValue) =>
78+
newValue
79+
? addItem(path, option.value)
80+
: removeItem(path, option.value)
81+
}
82+
data={checkboxValue}
83+
errors={errors}
84+
schema={schema}
85+
visible={visible}
86+
rootSchema={rootSchema}
87+
uischema={uischema}
88+
enabled={enabled}
89+
inputProps={{
90+
onFocus,
91+
onBlur,
92+
}}
93+
/>
94+
);
95+
})}
96+
</Flex>
9797
</Form.Item>
9898
);
9999
};

packages/antd-renderers/src/controls/InputControl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ export const InputControl = (props: ControlProps & WithInput) => {
7777
required={required}
7878
hasFeedback={!isValid}
7979
validateStatus={isValid ? 'success' : 'error'}
80-
label={label}
80+
label={input !== AntdCheckbox ? label : ''}
8181
help={help}
8282
style={style}
8383
htmlFor={id + '-input'}
8484
id={id}
8585
>
8686
<InnerComponent
8787
{...props}
88-
label={input === AntdCheckbox ? ' ' : props.label}
88+
label={label}
8989
inputProps={{
9090
onFocus,
9191
onBlur,

packages/primereact-renderers/src/complex/EnumArrayRenderer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const EnumArrayRenderer = (
4949
return (
5050
<InputControl
5151
{...props}
52-
input={() => (
52+
input={(props) => (
5353
<div
5454
className={classNames('flex gap-2', {
5555
'flex-column': appliedUiSchemaOptions.vertical,
@@ -60,7 +60,7 @@ export const EnumArrayRenderer = (
6060
const checkboxValue = data?.includes(option.value) ? true : false;
6161
return (
6262
<PrimeCheckbox
63-
id={id + '-label-' + option.value}
63+
id={id + '-input-' + option.value}
6464
key={option.value}
6565
label={option.label}
6666
isValid={isEmpty(errors)}
@@ -80,6 +80,7 @@ export const EnumArrayRenderer = (
8080
uischema={uischema}
8181
rootSchema={rootSchema}
8282
enabled={enabled}
83+
inputProps={props.inputProps}
8384
/>
8485
);
8586
})}

0 commit comments

Comments
 (0)