/** * External dependencies */ import classnames from 'classnames'; import { useInstanceId } from '@wordpress/compose'; /** * Internal dependencies */ import RadioControlOption from './option'; import type { RadioControlProps } from './types'; import './style.scss'; const RadioControl = ( { className = '', id, selected, onChange = () => void 0, options = [], }: RadioControlProps ): JSX.Element | null => { const instanceId = useInstanceId( RadioControl ); const radioControlId = id || instanceId; if ( ! options.length ) { return null; } return (
{ options.map( ( option ) => ( { onChange( value ); if ( typeof option.onChange === 'function' ) { option.onChange( value ); } } } /> ) ) }
); }; export default RadioControl; export { default as RadioControlOption } from './option'; export { default as RadioControlOptionLayout } from './option-layout';