@@ -16,6 +16,7 @@ import * as React from 'react';
1616import { useTranslation } from 'react-i18next' ;
1717import { useTheme } from '../../../utils/theme-hook' ;
1818import { JSON_SCHEMA_NUMBER_TYPES } from './const' ;
19+ import { DescriptionField } from './fields' ;
1920import { AtomicFieldTemplate } from './templates' ;
2021
2122export const TextWidget : React . FC < WidgetProps > = props => {
@@ -161,6 +162,8 @@ export const JSONWidget: React.FC<WidgetProps> = props => {
161162export const ArrayCheckboxesWidget : React . FC < WidgetProps > = props => {
162163 const { schema, value, id, onBlur, onChange, onFocus } = props ;
163164
165+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166+ const enums = ( schema . items as any ) . enum || [ ] ;
164167 const errFunc = ( ) => console . error ( 'Function not implemented.' ) ;
165168
166169 return (
@@ -169,36 +172,38 @@ export const ArrayCheckboxesWidget: React.FC<WidgetProps> = props => {
169172 < AtomicFieldTemplate
170173 onKeyChange = { ( ) => errFunc }
171174 onDropPropertyClick = { ( ) => errFunc }
175+ description = {
176+ < DescriptionField schema = { schema } description = { ( schema . items as any ) ?. description || props . description } />
177+ }
172178 { ...{
173179 ...props ,
174180 // eslint-disable-next-line @typescript-eslint/no-explicit-any
175181 style : props . style as React . StyleHTMLAttributes < any > | undefined ,
176- // eslint-disable-next-line @typescript-eslint/no-explicit-any
177- description : ( schema . items as any ) ?. description || props . description ,
178182 readonly : props . readonly === true ,
179183 disabled : props . disabled === true
180184 } }
181185 >
182- < Flex direction = { { default : 'row' } } onBlur = { ( ) => onBlur ( id , value ) } onFocus = { ( ) => onFocus ( id , value ) } >
183- {
184- // eslint-disable-next-line @typescript-eslint/no-explicit-any
185- ( schema . items as any ) . enum . map ( ( option : string , index : number ) => (
186- < FlexItem key = { `${ id } -${ index } ` } >
187- < Checkbox
188- id = { `${ id } -${ index } ` }
189- label = { option }
190- isChecked = { _ . isNil ( value ) ? false : value . includes ( option ) }
191- onClick = { ( ) =>
192- onChange (
193- value . includes ( option ) ? value . filter ( ( v : string ) => v !== option ) : [ ...value , option ] ,
194- undefined ,
195- id
196- )
197- }
198- />
199- </ FlexItem >
200- ) )
201- }
186+ < Flex
187+ direction = { { default : enums . length < 4 ? 'row' : 'column' } }
188+ onBlur = { ( ) => onBlur ( id , value ) }
189+ onFocus = { ( ) => onFocus ( id , value ) }
190+ >
191+ { enums . map ( ( option : string , index : number ) => (
192+ < FlexItem key = { `${ id } -${ index } ` } >
193+ < Checkbox
194+ id = { `${ id } -${ index } ` }
195+ label = { option }
196+ isChecked = { _ . isNil ( value ) ? false : value . includes ( option ) }
197+ onClick = { ( ) =>
198+ onChange (
199+ value . includes ( option ) ? value . filter ( ( v : string ) => v !== option ) : [ ...value , option ] ,
200+ undefined ,
201+ id
202+ )
203+ }
204+ />
205+ </ FlexItem >
206+ ) ) }
202207 </ Flex >
203208 </ AtomicFieldTemplate >
204209 ) ;
0 commit comments