/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 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/withInstall.js';
import 'vue';
import 'lodash/capitalize';
import '../../config.js';
import '../loading/loading.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../_chunks/dep-eaa95999.js';
import '../../_chunks/dep-102361be.js';
import '../../utils/easing.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../_chunks/dep-aacc31a3.js';
import '../../_chunks/dep-c68dc4b6.js';
import '../../_chunks/dep-1a6bca30.js';
import '../loading/plugin.js';
import 'lodash';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../../_chunks/dep-b4fd1955.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(Icon, {
      "attrs": {
        "name": this.icon
      }
    }) : renderLNodeJSX(this, "icon");
    const suffix = typeof this.suffix === "string" && this.suffix ? h("span", {
      "class": `${this.componentName}__suffix`
    }, [h(Icon, {
      "attrs": {
        "name": this.suffix
      }
    })]) : this.suffix || this.$scopedSlots.suffix ? h("span", {
      "class": `${this.componentName}__suffix`
    }, [renderLNodeJSX(this, "suffix")]) : null;
    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];
    if (suffix) buttonContent = [buttonContent].concat(suffix);
    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
