Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
1.18 kB
import React, { memo, useCallback, ChangeEvent } from 'react'
import { ChartPropertyWithControl, Flavor } from '../../../types'
import { ControlContext, RadioControlConfig } from '../types'
import { Control, Radio } from '../ui'
interface RadioControlProps {
id: string
property: ChartPropertyWithControl<RadioControlConfig>
flavors: Flavor[]
currentFlavor: Flavor
value: string
onChange: (value: string) => void
context?: ControlContext
}
export const RadioControl = memo(
({ id, property, flavors, currentFlavor, value, onChange, context }: RadioControlProps) => {
const { choices, columns } = property.control
const handleUpdate = useCallback(
(event: ChangeEvent<HTMLInputElement>) => onChange(event.target.value),
[onChange]
)
return (
<Control
id={id}
property={property}
flavors={flavors}
currentFlavor={currentFlavor}
context={context}
>
<Radio options={choices} columns={columns} value={value} onChange={handleUpdate} />
</Control>
)
}
)