1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 |
|
3 | var __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 |
|
16 | import * as React from 'react';
|
17 | import Radio from './radio';
|
18 | import { ConfigContext } from '../config-provider';
|
19 | import RadioGroupContext from './context';
|
20 |
|
21 | var 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 React.createElement(Radio, _extends({
|
38 | prefixCls: prefixCls
|
39 | }, radioProps, {
|
40 | type: "radio",
|
41 | ref: ref
|
42 | }));
|
43 | };
|
44 |
|
45 | export default React.forwardRef(RadioButton); |
\ | No newline at end of file |