import { RadioV2ContentProps, RadioV2Props } from './radioV2.types' import { SelectorV2Size } from '../selectorV2.types' import { StyledRadioV2Root } from './StyledRadioV2' import { RadioV2TokensType } from './radioV2.tokens' import { useResponsiveTokens } from '../../../hooks/useResponsiveTokens' import React, { forwardRef } from 'react' import { SelectorsLabelTokensType, SelectorsSubLabelTokensType, } from '../../SelectorsContent/SelectorsContent.types' import SelectorsLabel from '../../SelectorsContent/SelectorsLabel' import Block from '../../Primitives/Block/Block' import SelectorsSubLabel from '../../SelectorsContent/SelectorsSubLabel' import { addAccessibleAriaAttributes } from '../../../utils/accessibility/icon-helpers' import { filterBlockedProps } from '../../../utils/prop-helpers' const RadioV2 = forwardRef( ( { id: idProp, label, checked, size = SelectorV2Size.MD, subLabel, slot, maxLength, disabled = false, required = false, error = false, onCheckedChange, ...rest }, ref ) => { const radioTokens = useResponsiveTokens('RADIOV2') const generatedId = React.useId() const uniqueId = idProp ?? generatedId const subtextId = subLabel ? `${uniqueId}-subLabel` : undefined const labelId = label ? `${uniqueId}-label` : undefined const customAriaDescribedBy = (rest as { 'aria-describedby'?: string })[ 'aria-describedby' ] const ariaDescribedBy = subtextId && customAriaDescribedBy ? `${customAriaDescribedBy} ${subtextId}` : subtextId || customAriaDescribedBy const filteredRest = filterBlockedProps(rest) return ( ) } ) RadioV2.displayName = 'RadioV2' export default RadioV2 export const RadioV2Content = ({ uniqueId, disabled, error, required, size, label, subLabel, slot, tokens, labelMaxLength, subLabelMaxLength, subLabelId, }: RadioV2ContentProps) => { const labelId = `${uniqueId}-label` return ( {slot && ( {addAccessibleAriaAttributes(slot.slot)} )} ) }