@wordpress/components
Version:
UI components for WordPress.
42 lines (36 loc) • 942 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@wordpress/element";
// @ts-nocheck
/**
* External dependencies
*/
import { Radio as ReakitRadio } from 'reakit/Radio';
/**
* WordPress dependencies
*/
import { useContext, forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import Button from '../../button';
import RadioContext from '../radio-context';
function Radio(_ref, ref) {
let {
children,
value,
...props
} = _ref;
const radioContext = useContext(RadioContext);
const checked = radioContext.state === value;
return createElement(ReakitRadio, _extends({
ref: ref,
as: Button,
variant: checked ? 'primary' : 'secondary',
value: value
}, radioContext, props), children || value);
}
/**
* @deprecated Use `RadioControl` or `ToggleGroupControl` instead.
*/
export default forwardRef(Radio);
//# sourceMappingURL=index.js.map