/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var iconsVue = require('@ldesign/icons-vue');
var components_loading_index = require('../loading/index.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');
var components_button_props = require('./props.js');
require('../../utils/with-install.js');
require('vue');
require('lodash');
require('../../config.js');
require('../loading/loading.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');
require('../loading/plugin.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');

const keepAnimationMixins = components_configProvider_configReceiver.getKeepAnimationMixins();
const 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: {
    ...components_button_props["default"]
  },
  directives: {
    ripple: utils_ripple["default"]
  },
  render(h) {
    const {
      componentName: NAME,
      commonStatusClassName: STATUS,
      commonSizeClassName: SIZE
    } = this;
    let buttonContent = utils_renderNode.renderContent(this, "default", "content");
    const iconNode = typeof this.icon === "string" && this.icon ? h("l-icon", {
      "attrs": {
        "name": this.icon
      }
    }) : utils_renderNode.renderLNodeJSX(this, "icon");
    const icon = this.loading ? h("l-loading", {
      "attrs": {
        "inheritColor": true
      }
    }) : iconNode;
    const disabled = this.disabled || this.loading;
    let {
      theme
    } = this;
    if (!this.theme) {
      if (this.variant === "base") theme = "primary";else theme = "default";
    }
    const buttonClass = [`${NAME}`, SIZE[this.size], `${NAME}--variant-${this.variant}`, `${NAME}--theme-${theme}`, {
      [STATUS.disabled]: this.disabled,
      [STATUS.loading]: this.loading,
      [`${NAME}--shape-${this.shape}`]: this.shape !== "rectangle",
      [`${NAME}--ghost`]: this.ghost,
      [SIZE.block]: this.block
    }];
    buttonContent = buttonContent ? h("span", {
      "class": `${NAME}__text`
    }, [buttonContent]) : "";
    if (icon) buttonContent = [icon, buttonContent];
    const on = {
      ...this.$listeners
    };
    if (typeof this.onClick === "function") on.click = this.onClick;
    const buttonAttrs = {
      type: this.type,
      disabled,
      href: this.href
    };
    const renderTag = () => {
      if (!this.tag && this.href) return "a";
      return this.tag || "button";
    };
    return h(renderTag(), {
      class: buttonClass,
      attrs: buttonAttrs,
      on,
      directives: [{
        name: "ripple",
        value: this.keepAnimation.ripple
      }]
    }, [buttonContent]);
  }
});

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