/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var loading_index = require('../loading/index.js');
var hooks_useRipple = require('../hooks/useRipple.js');
var form_hooks = require('../form/hooks.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var hooks_tnode = require('../hooks/tnode.js');
var button_props = require('./props.js');
require('../utils/withInstall.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../utils/dom.js');
require('../_chunks/dep-f4db2590.js');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isArray');
require('../utils/easing.js');
require('../loading/loading.js');
require('@babel/runtime/helpers/slicedToArray');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('dayjs');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
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 TButton = vue.defineComponent({
  name: "TButton",
  props: button_props["default"],
  setup: function setup(props2, _ref) {
    var attrs = _ref.attrs,
      slots = _ref.slots;
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var renderContent = hooks_tnode.useContent();
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("button");
    var _useCommonClassName = hooks_useConfig.useCommonClassName(),
      STATUS = _useCommonClassName.STATUS,
      SIZE = _useCommonClassName.SIZE;
    var disabled = form_hooks.useFormDisabled();
    var btnRef = vue.ref();
    hooks_useRipple["default"](btnRef);
    var isDisabled = vue.computed(function () {
      return props2.disabled || props2.loading || disabled.value;
    });
    var mergeTheme = vue.computed(function () {
      var theme = props2.theme,
        variant = props2.variant;
      if (theme) return theme;
      if (variant === "base") return "primary";
      return "default";
    });
    var buttonClass = vue.computed(function () {
      var _ref2;
      return ["".concat(COMPONENT_NAME.value), "".concat(COMPONENT_NAME.value, "--variant-").concat(props2.variant), "".concat(COMPONENT_NAME.value, "--theme-").concat(mergeTheme.value), (_ref2 = {}, _defineProperty__default["default"](_ref2, SIZE.value[props2.size], props2.size !== "medium"), _defineProperty__default["default"](_ref2, STATUS.value.disabled, props2.disabled || disabled.value), _defineProperty__default["default"](_ref2, STATUS.value.loading, props2.loading), _defineProperty__default["default"](_ref2, "".concat(COMPONENT_NAME.value, "--shape-").concat(props2.shape), props2.shape !== "rectangle"), _defineProperty__default["default"](_ref2, "".concat(COMPONENT_NAME.value, "--ghost"), props2.ghost), _defineProperty__default["default"](_ref2, SIZE.value.block, props2.block), _ref2)];
    });
    return function () {
      var buttonContent = renderContent("default", "content");
      var icon = props2.loading ? vue.createVNode(loading_index.Loading, {
        "inheritColor": true
      }, null) : renderTNodeJSX("icon");
      var iconOnly = icon && !buttonContent;
      var suffix = props2.suffix || slots.suffix ? vue.createVNode("span", {
        "class": "".concat(COMPONENT_NAME.value, "__suffix")
      }, [renderTNodeJSX("suffix")]) : null;
      buttonContent = buttonContent ? vue.createVNode("span", {
        "class": "".concat(COMPONENT_NAME.value, "__text")
      }, [buttonContent]) : "";
      if (icon) buttonContent = [icon, buttonContent];
      if (suffix) buttonContent = [buttonContent].concat(suffix);
      var renderTag = function renderTag() {
        if (!props2.tag && props2.href) return "a";
        return props2.tag || "button";
      };
      var buttonAttrs = {
        "class": [].concat(_toConsumableArray__default["default"](buttonClass.value), [_defineProperty__default["default"]({}, "".concat(COMPONENT_NAME.value, "--icon-only"), iconOnly)]),
        type: props2.type,
        disabled: isDisabled.value,
        href: props2.href
      };
      return vue.h(renderTag(), _objectSpread(_objectSpread(_objectSpread({
        ref: btnRef
      }, attrs), buttonAttrs), {}, {
        onClick: props2.onClick
      }), [buttonContent]);
    };
  }
});

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