'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var index = require('../../image/index.js');
require('../../../constants/index.js');
var radio = require('./radio.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var event = require('../../../constants/event.js');

const _sfc_main = vue.defineComponent({
  name: "ElRadioItem",
  components: {
    ElImage: index.ElImage
  },
  props: {
    modelValue: {
      type: [String, Number, Boolean],
      default: ""
    },
    label: {
      type: [String, Number, Boolean],
      default: ""
    },
    name: {
      type: String,
      default: ""
    },
    iconUrl: {
      type: String,
      default: ""
    }
  },
  setup(props, { emit }) {
    const { isGroup, radioGroup, focus, disabled: disabled2 } = radio.useRadio(props, emit);
    const radioRef = vue.ref();
    const value = vue.computed({
      get() {
        return isGroup.value ? radioGroup.modelValue : props.modelValue;
      },
      set(value2) {
        if (isGroup.value) {
          radioGroup.changeEvent(value2);
          radioRef.value.checked = radioGroup.modelValue === props.label;
        } else {
          emit(event.UPDATE_MODEL_EVENT, value2);
        }
      }
    });
    return {
      isDisabled: disabled2,
      focus,
      value,
      radioRef
    };
  }
});
const _hoisted_1 = ["aria-checked", "aria-disabled"];
const _hoisted_2 = ["value", "name"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_ElImage = vue.resolveComponent("ElImage");
  return vue.openBlock(), vue.createElementBlock("label", {
    class: vue.normalizeClass(["el-radio-item", {
      "is-checked": _ctx.value === _ctx.label
    }]),
    role: "radio",
    "aria-checked": _ctx.value === _ctx.label,
    "aria-disabled": _ctx.isDisabled,
    onKeydown: _cache[4] || (_cache[4] = vue.withKeys(vue.withModifiers(($event) => _ctx.value = _ctx.isDisabled ? _ctx.value : _ctx.label, ["stop", "prevent"]), ["space"]))
  }, [
    vue.withDirectives(vue.createElementVNode("input", {
      ref: "radioRef",
      "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
      class: "el-radio-item__original-radio",
      value: _ctx.label,
      type: "radio",
      name: _ctx.name,
      onFocus: _cache[1] || (_cache[1] = ($event) => _ctx.focus = true),
      onBlur: _cache[2] || (_cache[2] = ($event) => _ctx.focus = false)
    }, null, 40, _hoisted_2), [
      [vue.vModelRadio, _ctx.value]
    ]),
    vue.createVNode(_component_ElImage, {
      src: _ctx.iconUrl,
      class: "el-radio-item__pic"
    }, null, 8, ["src"]),
    vue.createElementVNode("span", {
      class: "el-radio-item__label",
      onKeydown: _cache[3] || (_cache[3] = vue.withModifiers(() => {
      }, ["stop"]))
    }, [
      vue.renderSlot(_ctx.$slots, "default", {}, () => [
        vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
      ])
    ], 32)
  ], 42, _hoisted_1);
}
var radioItem = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "/Users/linxinjian/work/element-plus/packages/components/radio/src/radio-item.vue"]]);

exports["default"] = radioItem;
//# sourceMappingURL=radio-item.js.map
