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

import { Icon } from '@ldesign/icons-vue';
import { Loading } from '../loading/index.js';
import { renderContent, renderLNodeJSX } from '../../utils/render-node.js';
import Ripple from '../../utils/ripple.js';
import { getKeepAnimationMixins, getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../../utils/mixins.js';
import props from './props.js';
import '../../utils/with-install.js';
import 'vue';
import 'lodash';
import '../../config.js';
import '../loading/loading.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../_chunks/dep-70c789e5.js';
import '../../_chunks/dep-5210251b.js';
import '../../utils/easing.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../_chunks/dep-eb467ddf.js';
import '../../_chunks/dep-cf772670.js';
import '../../_chunks/dep-47d77fc8.js';
import '../loading/plugin.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../_chunks/dep-def4c2ce.js';

const keepAnimationMixins = getKeepAnimationMixins();
const classPrefixMixins = getClassPrefixMixins("button");
var LButton = mixins(keepAnimationMixins, classPrefixMixins).extend({
  name: "LButton",
  components: {
    LLoading: Loading,
    LIcon: Icon
  },
  props: {
    ...props
  },
  directives: {
    ripple: Ripple
  },
  render(h) {
    const {
      componentName: NAME,
      commonStatusClassName: STATUS,
      commonSizeClassName: SIZE
    } = this;
    let buttonContent = renderContent(this, "default", "content");
    const iconNode = typeof this.icon === "string" && this.icon ? h("l-icon", {
      "attrs": {
        "name": this.icon
      }
    }) : 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]);
  }
});

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