UNPKG

1.43 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2
3var __rest = this && this.__rest || function (s, e) {
4 var t = {};
5
6 for (var p in s) {
7 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
8 }
9
10 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
12 }
13 return t;
14};
15
16import * as React from 'react';
17import Radio from './radio';
18import { ConfigContext } from '../config-provider';
19import RadioGroupContext from './context';
20
21var RadioButton = function RadioButton(props, ref) {
22 var radioGroupContext = React.useContext(RadioGroupContext);
23
24 var _React$useContext = React.useContext(ConfigContext),
25 getPrefixCls = _React$useContext.getPrefixCls;
26
27 var customizePrefixCls = props.prefixCls,
28 radioProps = __rest(props, ["prefixCls"]);
29
30 var prefixCls = getPrefixCls('radio-button', customizePrefixCls);
31
32 if (radioGroupContext) {
33 radioProps.checked = props.value === radioGroupContext.value;
34 radioProps.disabled = props.disabled || radioGroupContext.disabled;
35 }
36
37 return /*#__PURE__*/React.createElement(Radio, _extends({
38 prefixCls: prefixCls
39 }, radioProps, {
40 type: "radio",
41 ref: ref
42 }));
43};
44
45export default /*#__PURE__*/React.forwardRef(RadioButton);
\No newline at end of file