tdesign-vue
Version:
215 lines (211 loc) • 8.87 kB
JavaScript
/**
* tdesign v1.11.2
* (c) 2025 tdesign
* @license MIT
*/
import { h as helper } from '../_chunks/dep-653f218a.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import { usePrefixClass } from '../config-provider/useConfig.js';
import useCommonClassName from '../hooks/useCommonClassName.js';
import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js';
import { Loading } from '../loading/index.js';
import props from './props.js';
import '../config-provider/context.js';
import 'lodash-es';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-84fc5ae7.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-eb45b5e0.js';
import 'dayjs';
import '@babel/runtime/helpers/readOnlyError';
import 'vue';
import '../loading/directive.js';
import '../loading/plugin.js';
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 '../config-provider/config-receiver.js';
import '../utils/mixins.js';
import '../utils/dom.js';
import 'raf';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../config.js';
import '../utils/withInstall.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 _Card = defineComponent({
name: "TCard",
props: _objectSpread({}, props),
components: {
TLoading: Loading
},
setup: function setup(props2, _ref) {
var slots = _ref.slots;
var _useCommonClassName = useCommonClassName(),
sizeClassNames = _useCommonClassName.sizeClassNames;
var COMPONENT_NAME = usePrefixClass("card");
var baseCls = computed(function () {
var defaultClass = [COMPONENT_NAME.value];
if (props2.size === "small") defaultClass.push("".concat(sizeClassNames[props2.size]));
if (props2.bordered) defaultClass.push("".concat(COMPONENT_NAME.value, "--bordered"));
if (props2.shadow) defaultClass.push("".concat(COMPONENT_NAME.value, "--shadow"));
if (props2.hoverShadow) defaultClass.push("".concat(COMPONENT_NAME.value, "--shadow-hover"));
return defaultClass;
});
var headerCls = computed(function () {
var defaultClass = ["".concat(COMPONENT_NAME.value, "__header")];
return props2.headerBordered ? defaultClass.concat("".concat(COMPONENT_NAME.value, "__title--bordered")) : ["".concat(COMPONENT_NAME.value, "__header")];
});
var headerWrapperCls = usePrefixClass("card__header-wrapper");
var headerAvatarCls = usePrefixClass("card__avatar");
var headerTitleCls = usePrefixClass("card__title");
var headerSubTitleCls = usePrefixClass("card__subtitle");
var headerDescriptionCls = usePrefixClass("card__description");
var actionsCls = usePrefixClass("card__actions");
var bodyCls = usePrefixClass("card__body");
var coverCls = usePrefixClass("card__cover");
var footerCls = usePrefixClass("card__footer");
var footerWrapperCls = usePrefixClass("card__footer-wrapper");
var isPoster2 = computed(function () {
return props2.theme === "poster2";
});
var showTitle = computed(function () {
return props2.title || slots.title;
});
var showHeader = computed(function () {
return props2.header || slots.header;
});
var showSubtitle = computed(function () {
return props2.subtitle || slots.subtitle;
});
var showAvatar = computed(function () {
return props2.avatar || slots.avatar;
});
var showDescription = computed(function () {
return props2.description || slots.description;
});
var showStatus = computed(function () {
return props2.status || slots.status;
});
var showActions = computed(function () {
return props2.actions || slots.actions;
});
var showFooter = computed(function () {
return props2.footer || slots.footer;
});
var showCover = computed(function () {
return props2.cover || slots.cover;
});
var showLoading = computed(function () {
return props2.loading || slots.loading;
});
var showContent = computed(function () {
return props2.content || slots.content || props2["default"] || slots["default"];
});
var isHeaderRender = computed(function () {
return showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value;
});
var isFooterRender = computed(function () {
return showFooter.value || showActions.value && isPoster2.value;
});
return {
isHeaderRender: isHeaderRender,
isFooterRender: isFooterRender,
isPoster2: isPoster2,
showLoading: showLoading,
showHeader: showHeader,
showTitle: showTitle,
showSubtitle: showSubtitle,
showDescription: showDescription,
showAvatar: showAvatar,
showActions: showActions,
showStatus: showStatus,
showContent: showContent,
showCover: showCover,
showFooter: showFooter,
baseCls: baseCls,
bodyCls: bodyCls,
footerCls: footerCls,
footerWrapperCls: footerWrapperCls,
coverCls: coverCls,
actionsCls: actionsCls,
headerCls: headerCls,
headerWrapperCls: headerWrapperCls,
headerAvatarCls: headerAvatarCls,
headerTitleCls: headerTitleCls,
headerSubTitleCls: headerSubTitleCls,
headerDescriptionCls: headerDescriptionCls,
COMPONENT_NAME: COMPONENT_NAME
};
},
methods: {
renderLoading: function renderLoading() {},
renderCover: function renderCover() {
var h = this.$createElement;
var textCover = typeof this.cover === "string";
return h("div", {
"class": this.coverCls
}, [textCover ? h("img", {
"attrs": {
"src": this.cover
}
}) : renderTNodeJSX(this, "cover")]);
},
renderHeader: function renderHeader() {
var h = this.$createElement;
if (this.showHeader) return h("div", {
"class": this.headerCls
}, [renderTNodeJSX(this, "header")]);
return h("div", {
"class": this.headerCls
}, [h("div", {
"class": this.headerWrapperCls
}, [this.showAvatar && h("div", {
"class": this.headerAvatarCls
}, [renderTNodeJSX(this, "avatar")]), h("div", [this.showTitle && h("div", {
"class": this.headerTitleCls
}, [renderTNodeJSX(this, "title")]), this.showSubtitle && h("div", {
"class": this.headerSubTitleCls
}, [renderTNodeJSX(this, "subtitle")]), this.showDescription && h("p", {
"class": this.headerDescriptionCls
}, [renderTNodeJSX(this, "description")])])]), this.showActions && !this.isPoster2 && h("div", {
"class": this.actionsCls
}, [renderTNodeJSX(this, "actions")]), this.showStatus && h("div", {
"class": this.actionsCls
}, [renderTNodeJSX(this, "status")])]);
}
},
render: function render() {
var h = arguments[0];
var content = h("div", {
"class": this.baseCls
}, [this.isHeaderRender ? this.renderHeader() : null, this.showCover ? this.renderCover() : null, this.showContent && h("div", {
"class": this.bodyCls
}, [renderContent(this, "default", "content")]), this.isFooterRender && h("div", {
"class": this.footerCls
}, [h("div", {
"class": this.footerWrapperCls
}, [renderTNodeJSX(this, "footer")]), this.showActions && this.isPoster2 && h("div", {
"class": this.actionsCls
}, [renderTNodeJSX(this, "actions")])])]);
if (this.loading) {
return renderTNodeJSX(this, "loading", {
defaultNode: h("t-loading", helper([{}, {
"props": this.loadingProps
}]), [content])
});
}
return content;
}
});
export { _Card as default };
//# sourceMappingURL=card.js.map