import { defineComponent, inject, computed } from 'vue';
const radio = defineComponent({
    name: 'Radio',
    props: {
        value: [String, Number, Boolean],
        checked: {
            type: Boolean,
            defalut: false,
            validator(value) {
                return typeof value == 'boolean';
            },
        },
        disabled: Boolean,
    },
    emits: [],
    setup(props, { slots }) {
        const radioGroupContext = inject('radioGroupContext', undefined);
        const checkState = computed(() => {
            var _a;
            return props.checked || 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 class={['u-radio', { 'u-radio-disabled': props.disabled }]} onClick={() => {
                    if (props.disabled) {
                        return;
                    }
                    radioGroupContext === null || radioGroupContext === void 0 ? void 0 : radioGroupContext.onRadioChange(props === null || props === void 0 ? void 0 : props.value);
                }}>
        <input class={['u-radio-input']} value={props.value}></input>
        <div class={['u-radio-dot', { 'u-radio-dot-checked': checkState.value }]}></div>
        <div class={['u-radio-label']}>{(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)}</div>
      </div>);
        };
    },
});
export default radio;
