/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var iconsVue = require('@ldesign/icons-vue');
var components_loading_index = require('../loading/index.js');
var components_button_props = require('./props.js');
var utils_renderNode = require('../../utils/render-node.js');
var utils_ripple = require('../../utils/ripple.js');
var components_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('vue');
require('../../chunks/defineProperty-28395935.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/slicedToArray');
require('../../config.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../../utils/with-install.js');
require('lodash');
require('../loading/plugin.js');
require('@babel/runtime/helpers/typeof');
require('lodash/camelCase');
require('lodash/kebabCase');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');

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 = components_configProvider_configReceiver.getKeepAnimationMixins();
var classPrefixMixins = components_configProvider_configReceiver.getClassPrefixMixins("button");
var LButton = utils_mixins["default"](keepAnimationMixins, classPrefixMixins).extend({
  name: "LButton",
  components: {
    LLoading: components_loading_index.Loading,
    LIcon: iconsVue.Icon
  },
  props: _objectSpread({}, components_button_props["default"]),
  directives: {
    ripple: utils_ripple["default"]
  },
  render: function render(h) {
    var _ref,
        _this = this;

    var NAME = this.componentName,
        STATUS = this.commonStatusClassName,
        SIZE = this.commonSizeClassName;
    var buttonContent = utils_renderNode.renderContent(this, "default", "content");
    var iconNode = typeof this.icon === "string" && this.icon ? h("l-icon", {
      "attrs": {
        "name": this.icon
      }
    }) : utils_renderNode.renderLNodeJSX(this, "icon");
    var icon = this.loading ? h("l-loading", {
      "attrs": {
        "inheritColor": true
      }
    }) : iconNode;
    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), SIZE[this.size], "".concat(NAME, "--variant-").concat(this.variant), "".concat(NAME, "--theme-").concat(theme), (_ref = {}, _defineProperty__default["default"](_ref, STATUS.disabled, this.disabled), _defineProperty__default["default"](_ref, 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, 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;
    }

    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"] = LButton;
//# sourceMappingURL=button.js.map
