/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-42d5c87e.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import { prefix } from '../config.js';
import ClASSNAMES from '../utils/classnames.js';
import { omit } from '../utils/helper.js';
import { renderContent } from '../utils/render-tnode.js';
import props from './props.js';
import { emitEvent } from '../utils/event.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '@babel/runtime/helpers/typeof';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var name = "".concat(prefix, "-radio");
var radioBtnName = "".concat(prefix, "-radio-button");
var _Radio = Vue.extend({
  name: "TRadio",
  inheritAttrs: false,
  props: _objectSpread({}, props),
  inject: {
    radioGroup: {
      "default": void 0
    },
    radioButton: {
      "default": void 0
    }
  },
  render: function render() {
    var _ref;

    var h = arguments[0];
    var radioGroup = this.radioGroup,
        radioButton = this.radioButton;
    var inputProps = {
      checked: this.checked,
      disabled: this.disabled,
      value: this.value,
      name: this.name
    };

    if (radioGroup) {
      inputProps.checked = this.value === radioGroup.value;
      inputProps.disabled = this.disabled === void 0 ? radioGroup.disabled : this.disabled;
      inputProps.name = radioGroup.name;
    }

    var prefixCls = radioButton ? radioBtnName : name;
    var inputClass = ["".concat(prefixCls), (_ref = {}, _defineProperty(_ref, ClASSNAMES.STATUS.checked, inputProps.checked), _defineProperty(_ref, ClASSNAMES.STATUS.disabled, inputProps.disabled), _ref)];
    return h("label", {
      "class": inputClass
    }, [h("input", helper([{
      "attrs": {
        "type": "radio"
      },
      "class": "".concat(prefixCls, "__former")
    }, {
      "on": _objectSpread({}, omit(this.$listeners, ["change"]))
    }, {
      "domProps": _objectSpread({}, inputProps),
      "on": {
        "change": this.handleChange
      }
    }])), h("span", {
      "class": "".concat(prefixCls, "__input")
    }), h("span", {
      "class": "".concat(prefixCls, "__label")
    }, [renderContent(this, "default", "label")])]);
  },
  methods: {
    handleChange: function handleChange(e) {
      if (this.radioGroup) {
        this.radioGroup.$emit("checked-change", this.value, {
          e: e
        });
      } else {
        var target = e.target;
        emitEvent(this, "change", target.checked, {
          e: e
        });
      }
    }
  }
});

export { _Radio as default, radioBtnName };
//# sourceMappingURL=radio.js.map
