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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var config = require('../config.js');
var utils_classnames = require('../utils/classnames.js');
var loading_index = require('../loading/index.js');
var button_props = require('./props.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var utils_ripple = require('../utils/ripple.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../utils/set-style.js');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('@babel/runtime/helpers/typeof');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../loading/plugin.js');

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, "-button");
var TButton = Vue__default["default"].extend({
  name: "TButton",
  props: button_props["default"],
  directives: {
    ripple: utils_ripple["default"]
  },
  render: function render() {
    var _ref;

    var h = arguments[0];
    var buttonContent = utils_renderTnode.renderContent(this, "default", "content");
    var icon = this.loading ? h(loading_index.Loading, {
      "attrs": {
        "inheritColor": true
      }
    }) : utils_renderTnode.renderTNodeJSX(this, "icon");
    var disabled = this.disabled || this.loading;
    var theme = this.theme;

    if (!this.theme) {
      if (this.variant === "base") {
        theme = "primary";
      } else {
        theme = "default";
      }
    }

    var buttonClass = ["".concat(name), utils_classnames["default"].SIZE[this.size], "".concat(name, "--variant-").concat(this.variant), "".concat(name, "--theme-").concat(theme), (_ref = {}, _defineProperty__default["default"](_ref, utils_classnames["default"].STATUS.disabled, disabled), _defineProperty__default["default"](_ref, utils_classnames["default"].STATUS.loading, this.loading), _defineProperty__default["default"](_ref, "".concat(name, "--shape-").concat(this.shape), this.shape !== "rectangle"), _defineProperty__default["default"](_ref, "".concat(name, "--ghost"), this.ghost), _defineProperty__default["default"](_ref, utils_classnames["default"].SIZE.block, this.block), _ref)];
    buttonContent = buttonContent ? h("span", {
      "class": "".concat(name, "__text")
    }, [buttonContent]) : "";

    if (icon) {
      buttonContent = [icon, buttonContent];
    }

    var on = _objectSpread({}, this.$listeners);

    if (typeof this.onClick === "function") {
      on.click = this.onClick;
    }

    return h("button", {
      "directives": [{
        name: "ripple",
        value: true
      }],
      "class": buttonClass,
      "attrs": {
        "type": this.type,
        "disabled": disabled
      },
      "on": _objectSpread({}, on)
    }, [buttonContent]);
  }
});

exports["default"] = TButton;
//# sourceMappingURL=button.js.map
