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

'use strict';

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

var helper = require('../_chunks/dep-44e6bdf6.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var config = require('../config.js');
var utils_classnames = require('../utils/classnames.js');
var utils_helper = require('../utils/helper.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var radio_props = require('./props.js');
var utils_event = require('../utils/event.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('@babel/runtime/helpers/typeof');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

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__default["default"](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(config.prefix, "-radio");
var radioBtnName = "".concat(config.prefix, "-radio-button");
var _Radio = Vue__default["default"].extend({
  name: "TRadio",
  inheritAttrs: false,
  props: _objectSpread({}, radio_props["default"]),
  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__default["default"](_ref, utils_classnames["default"].STATUS.checked, inputProps.checked), _defineProperty__default["default"](_ref, utils_classnames["default"].STATUS.disabled, inputProps.disabled), _ref)];
    return h("label", {
      "class": inputClass
    }, [h("input", helper.helper([{
      "attrs": {
        "type": "radio"
      },
      "class": "".concat(prefixCls, "__former")
    }, {
      "on": _objectSpread({}, utils_helper.omit(this.$listeners, ["change"]))
    }, {
      "domProps": _objectSpread({}, inputProps),
      "on": {
        "change": this.handleChange
      }
    }])), h("span", {
      "class": "".concat(prefixCls, "__input")
    }), h("span", {
      "class": "".concat(prefixCls, "__label")
    }, [utils_renderTnode.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;
        utils_event.emitEvent(this, "change", target.checked, {
          e: e
        });
      }
    }
  }
});

exports["default"] = _Radio;
exports.radioBtnName = radioBtnName;
//# sourceMappingURL=radio.js.map
