25 lines
777 B
TypeScript
Raw Normal View History

import type { ReactNode } from 'react'
2023-05-15 08:51:32 +08:00
import RadioGroupContext from '../../context'
import s from '../../style.module.css'
import cn from '@/utils/classnames'
2023-05-15 08:51:32 +08:00
export type TRadioGroupProps = {
children?: ReactNode | ReactNode[]
2023-05-15 08:51:32 +08:00
value?: string | number
className?: string
onChange?: (value: any) => void
}
export default function Group({ children, value, onChange, className = '' }: TRadioGroupProps): React.JSX.Element {
2023-05-15 08:51:32 +08:00
const onRadioChange = (value: any) => {
onChange?.(value)
}
return (
<div className={cn('flex items-center bg-workflow-block-parma-bg text-text-secondary', s.container, className)}>
2023-05-15 08:51:32 +08:00
<RadioGroupContext.Provider value={{ value, onChange: onRadioChange }}>
{children}
</RadioGroupContext.Provider>
</div>
)
}