/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
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');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../utils/mixins.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('../utils/dom.js');
require('vue');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../loading/plugin.js');
require('../config.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('lodash/camelCase');
require('lodash/kebabCase');

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

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

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 keepAnimationMixins = configProvider_configReceiver.getKeepAnimationMixins();
var classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("button");
var TButton = utils_mixins["default"](keepAnimationMixins, classPrefixMixins).extend({
  name: "TButton",
  props: button_props["default"],
  directives: {
    ripple: utils_ripple["default"]
  },
  render: function render(h) {
    var _ref,
        _this = this;

    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(this.componentName), this.commonSizeClassName[this.size], "".concat(this.componentName, "--variant-").concat(this.variant), "".concat(this.componentName, "--theme-").concat(theme), (_ref = {}, _defineProperty__default["default"](_ref, this.commonStatusClassName.disabled, this.disabled), _defineProperty__default["default"](_ref, this.commonStatusClassName.loading, this.loading), _defineProperty__default["default"](_ref, "".concat(this.componentName, "--shape-").concat(this.shape), this.shape !== "rectangle"), _defineProperty__default["default"](_ref, "".concat(this.componentName, "--ghost"), this.ghost), _defineProperty__default["default"](_ref, this.commonSizeClassName.block, this.block), _ref)];
    buttonContent = buttonContent ? h("span", {
      "class": "".concat(this.componentName, "__text")
    }, [buttonContent]) : "";

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

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

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

    var buttonAttrs = {
      type: this.type,
      disabled: disabled,
      href: this.href
    };

    var renderTag = function renderTag() {
      if (!_this.tag && _this.href) return "a";
      return _this.tag || "button";
    };

    return h(renderTag(), {
      "class": buttonClass,
      attrs: buttonAttrs,
      on: on,
      directives: [{
        name: "ripple",
        value: this.keepAnimation.ripple
      }]
    }, [buttonContent]);
  }
});

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