| | |
| | | import type { ReactNode } from 'react' |
| | | import type { ReactElement } from 'react' |
| | | import { useId } from 'react' |
| | | import { useContext } from 'use-context-selector' |
| | | import RadioGroupContext from '../../context' |
| | |
| | | export type IRadioProps = { |
| | | className?: string |
| | | labelClassName?: string |
| | | children?: string | ReactNode |
| | | children?: string | ReactElement |
| | | checked?: boolean |
| | | value?: string | number |
| | | disabled?: boolean |
| | |
| | | value, |
| | | disabled, |
| | | onChange, |
| | | }: IRadioProps): React.JSX.Element { |
| | | }: IRadioProps): JSX.Element { |
| | | const groupContext = useContext(RadioGroupContext) |
| | | const labelId = useId() |
| | | const handleChange = (e: IRadioProps['value']) => { |
| | |
| | | > |
| | | {children && ( |
| | | <label className={ |
| | | cn(labelClassName, 'cursor-pointer text-sm') |
| | | cn(labelClassName, 'text-sm cursor-pointer') |
| | | } |
| | | id={labelId} |
| | | > |