import React, { useState, useEffect } from 'react';
import classnames from 'classnames';
import RadioGroup from './radio-group';
var defaultProps = {
    prefixCls: 'ty-radio',
    defaultChecked: false,
};
var Radio = function (props) {
    var _a;
    var name = props.name, value = props.value, disabled = props.disabled, onChange = props.onChange, prefixCls = props.prefixCls, className = props.className, style = props.style, children = props.children;
    var _b = useState(('checked' in props) ? props.checked : props.defaultChecked), checked = _b[0], setChecked = _b[1];
    var cls = classnames(prefixCls, className, (_a = {},
        _a[prefixCls + "_checked"] = checked,
        _a[prefixCls + "_disabled"] = disabled,
        _a));
    var _onChange = function (e) {
        if (!disabled) {
            !('checked' in props) && setChecked(e.currentTarget.checked);
            onChange && onChange(e.currentTarget.checked, e);
        }
    };
    useEffect(function () {
        ('checked' in props) && setChecked(props.checked);
    });
    return (React.createElement("label", { className: cls, style: style },
        React.createElement("input", { name: name, disabled: disabled, value: value, className: prefixCls + "__native", type: "radio", checked: checked, onChange: _onChange }),
        React.createElement("span", { className: prefixCls + "__inner" }),
        React.createElement("span", null, children)));
};
Radio.defaultProps = defaultProps;
Radio.Group = RadioGroup;
export default Radio;
//# sourceMappingURL=index.js.map