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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { Icon } from '@ldesign/icons-vue';
import { Loading } from '../loading/index.js';
import props from './props.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 '../loading/loading.js';
import '../loading/icon/gradient.js';
import 'vue';
import '../../_chunks/dep-33b15d9d.js';
import '../../_chunks/dep-85e8b23b.js';
import '../../_chunks/dep-fc383775.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';
import '../../config.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../../utils/with-install.js';
import 'lodash';
import '../loading/plugin.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../_chunks/dep-a0f2090c.js';

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(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 = getKeepAnimationMixins();
var classPrefixMixins = getClassPrefixMixins("button");
var LButton = mixins(keepAnimationMixins, classPrefixMixins).extend({
  name: "LButton",
  components: {
    LLoading: Loading,
    LIcon: Icon
  },
  props: _objectSpread({}, props),
  directives: {
    ripple: Ripple
  },
  render: function render(h) {
    var _ref,
        _this = this;

    var NAME = this.componentName,
        STATUS = this.commonStatusClassName,
        SIZE = this.commonSizeClassName;
    var buttonContent = renderContent(this, "default", "content");
    var iconNode = typeof this.icon === "string" && this.icon ? h("l-icon", {
      "attrs": {
        "name": this.icon
      }
    }) : 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(_ref, STATUS.disabled, this.disabled), _defineProperty(_ref, STATUS.loading, this.loading), _defineProperty(_ref, "".concat(NAME, "--shape-").concat(this.shape), this.shape !== "rectangle"), _defineProperty(_ref, "".concat(NAME, "--ghost"), this.ghost), _defineProperty(_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]);
  }
});

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