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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import { prefix } from '../config.js';
import ClASSNAMES from '../utils/classnames.js';
import { Loading } from '../loading/index.js';
import props from './props.js';
import { renderContent, renderTNodeJSX } from '../utils/render-tnode.js';
import Ripple from '../utils/ripple.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../utils/set-style.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '@babel/runtime/helpers/typeof';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';

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, "-button");
var TButton = Vue.extend({
  name: "TButton",
  props: props,
  directives: {
    ripple: Ripple
  },
  render: function render() {
    var _ref;

    var h = arguments[0];
    var buttonContent = renderContent(this, "default", "content");
    var icon = this.loading ? h(Loading, {
      "attrs": {
        "inheritColor": true
      }
    }) : 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), ClASSNAMES.SIZE[this.size], "".concat(name, "--variant-").concat(this.variant), "".concat(name, "--theme-").concat(theme), (_ref = {}, _defineProperty(_ref, ClASSNAMES.STATUS.disabled, disabled), _defineProperty(_ref, ClASSNAMES.STATUS.loading, this.loading), _defineProperty(_ref, "".concat(name, "--shape-").concat(this.shape), this.shape !== "rectangle"), _defineProperty(_ref, "".concat(name, "--ghost"), this.ghost), _defineProperty(_ref, ClASSNAMES.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]);
  }
});

export { TButton as default };
//# sourceMappingURL=button.js.map
