import { forwardRef, type InputHTMLAttributes, type ForwardedRef } from 'react' import { getFormLabelProps, getRadioProps, splitClassNameProp, } from '@pluralsight/headless-styles' import type { RadioOptions } from '@pluralsight/headless-styles/types' import { useFormControl } from '../context/FormControl.tsx' interface RadioProps extends RadioOptions, Omit, 'id' | 'name' | 'children'> { children?: string } function RadioEl(props: RadioProps, ref: ForwardedRef) { const { children, ...nativeProps } = props const state = useFormControl() const pandoProps = getRadioProps({ ...state, ...nativeProps, classNames: splitClassNameProp(nativeProps.className), }) const { value, ...pandoLabelProps } = getFormLabelProps({ ...state, htmlFor: props.id, value: children ?? '', }) return ( ) } export const Radio = forwardRef(RadioEl)