import { defineComponent, inject, computed } from 'vue';
const radioButton = defineComponent({
    name: 'RadioButton',
    props: {
        checked: {
            type: Boolean,
            default: false,
        },
        disabled: {
            type: Boolean,
            default: false,
        },
        value: [String, Number, Boolean],
    },
    setup(props, { slots }) {
        const radioGroupContext = inject('radioGroupContext', undefined);
        const checkState = computed(() => {
            var _a;
            return (props === null || props === void 0 ? void 0 : props.checked) || (props === null || props === void 0 ? void 0 : props.value) == ((_a = radioGroupContext === null || radioGroupContext === void 0 ? void 0 : radioGroupContext.props) === null || _a === void 0 ? void 0 : _a.value);
        });
        return () => {
            var _a;
            return (<div onClick={() => {
                    if (props.disabled) {
                        return;
                    }
                    radioGroupContext.onRadioChange(props === null || props === void 0 ? void 0 : props.value);
                }} class={[
                    'u-radio-button',
                    { 'u-radio-button-disabled': props.disabled },
                    { 'u-radio-button-checked': checkState.value },
                ]}>
        {(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)}
      </div>);
        };
    },
});
export default radioButton;
