11import React , { useState } from 'react'
2- import { EuiFieldText , EuiButtonGroup , EuiButtonGroupProps } from '@elastic/eui'
2+ import { EuiFieldText } from '@elastic/eui'
33import { SwitchInput } from 'uiSrc/components/base/inputs'
44import { FormFieldset } from 'uiSrc/components/base/forms/fieldset'
55import { AxisScale , GraphMode , ChartConfigFormProps } from './interfaces'
@@ -9,7 +9,10 @@ import {
99 TITLE_MAX_LENGTH ,
1010} from './constants'
1111import { RiAccordion } from 'uiSrc/components/base/display/accordion/RiAccordion'
12- import { ButtonGroup } from 'uiSrc/components/base/forms/button-group/ButtonGroup'
12+ import {
13+ ButtonGroup ,
14+ ButtonGroupProps ,
15+ } from 'uiSrc/components/base/forms/button-group/ButtonGroup'
1316
1417const NewEnumSelect = ( {
1518 select,
@@ -178,6 +181,8 @@ const YAxisConfigForm = ({ value, onChange, label }: any) => (
178181 </ div >
179182)
180183
184+ const capitalize = ( str : string ) => str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 )
185+
181186interface EnumSelectProps {
182187 enumType : any
183188 inputLabel : string
@@ -187,13 +192,18 @@ const EnumSelect = ({
187192 enumType,
188193 inputLabel,
189194 ...props
190- } : EnumSelectProps & EuiButtonGroupProps ) => (
191- < EuiButtonGroup
192- legend = "form-button"
193- buttonSize = "compressed"
194- options = { Object . values ( enumType ) . map ( ( v : string ) => ( { id : v , label : v } ) ) }
195- onChange = { ( id ) => props . onChange ( { target : { value : id } } as any ) }
196- idSelected = { props . value . toString ( ) }
197- isFullWidth
198- />
195+ } : EnumSelectProps & ButtonGroupProps ) => (
196+ < ButtonGroup >
197+ { Object . values ( enumType ) . map ( ( v ) => (
198+ < ButtonGroup . Button
199+ isSelected = { props . value === v }
200+ key = { String ( v ) }
201+ onClick = { ( ) =>
202+ props . onChange ?.( { target : { value : String ( v ) } } as any )
203+ }
204+ >
205+ { capitalize ( String ( v ) ) }
206+ </ ButtonGroup . Button >
207+ ) ) }
208+ </ ButtonGroup >
199209)
0 commit comments