tdesign-vue
Version:
115 lines (111 loc) • 4.83 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { Loading } from '../loading/index.js';
import props from './props.js';
import { renderContent, renderTNodeJSX } from '../utils/render-tnode.js';
import Ripple from '../utils/ripple.js';
import { getKeepAnimationMixins, getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../utils/mixins.js';
import '../loading/directive.js';
import 'lodash-es';
import '../loading/plugin.js';
import 'vue';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/setStyle.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/dom.js';
import 'raf';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../config.js';
import '../config-provider/context.js';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-c44a474d.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-d639fbd7.js';
import 'dayjs';
import '../_chunks/dep-3c66615e.js';
import '../config-provider/type.js';
import '../_common/js/global-config/t.js';
import '@babel/runtime/helpers/readOnlyError';
import '@vue/composition-api';
import '../utils/withInstall.js';
import './style/css.js';
import '../loading/type.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var keepAnimationMixins = getKeepAnimationMixins();
var classPrefixMixins = getClassPrefixMixins("button");
var TButton = mixins(keepAnimationMixins, classPrefixMixins).extend({
name: "TButton",
props: props,
directives: {
ripple: Ripple
},
render: function render(h) {
var _this = this;
var buttonContent = renderContent(this, "default", "content");
var icon = this.loading ? h(Loading, {
"attrs": {
"inheritColor": true
}
}) : renderTNodeJSX(this, "icon");
var disabled = this.disabled || this.loading;
var suffix = this.suffix || this.$scopedSlots.suffix ? h("span", {
"class": "".concat(this.componentName, "__suffix")
}, [renderTNodeJSX(this, "suffix")]) : null;
var theme = this.theme;
if (!this.theme) {
if (this.variant === "base") {
theme = "primary";
} else {
theme = "default";
}
}
var buttonClass = ["".concat(this.componentName), "".concat(this.componentName, "--variant-").concat(this.variant), "".concat(this.componentName, "--theme-").concat(theme), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, this.commonSizeClassName[this.size], this.size !== "medium"), this.commonStatusClassName.disabled, this.disabled), this.commonStatusClassName.loading, this.loading), "".concat(this.componentName, "--shape-").concat(this.shape), this.shape !== "rectangle"), "".concat(this.componentName, "--ghost"), this.ghost), this.commonSizeClassName.block, this.block)];
buttonContent = buttonContent ? h("span", {
"class": "".concat(this.componentName, "__text")
}, [buttonContent]) : "";
if (icon) {
buttonContent = [icon, buttonContent];
}
if (suffix) {
buttonContent = [buttonContent].concat(suffix);
}
var on = _objectSpread({}, this.$listeners);
if (typeof this.onClick === "function") {
on.click = this.onClick;
}
var buttonAttrs = {
type: this.type,
disabled: disabled,
href: this.href || void 0
};
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 { TButton as default };
//# sourceMappingURL=button.js.map