UNPKG

tdesign-vue

Version:
181 lines (177 loc) 6.94 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import GradientIcon from './icon/gradient.js'; import { addClass, removeClass } from '../utils/dom.js'; import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js'; import TransferDom from '../utils/transfer-dom.js'; import props from './props.js'; import { getClassPrefixMixins } from '../config-provider/config-receiver.js'; import mixins from '../utils/mixins.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 'lodash-es'; import 'vue'; import 'raf'; import '../utils/easing.js'; import '@babel/runtime/helpers/readOnlyError'; import '@babel/runtime/helpers/typeof'; import '@vue/composition-api'; 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 '../_chunks/dep-d639fbd7.js'; import 'dayjs'; import '../_chunks/dep-3c66615e.js'; import '../config-provider/type.js'; import '../_common/js/global-config/t.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 classPrefixMixins = getClassPrefixMixins("loading"); var _Loading = mixins(classPrefixMixins).extend({ name: "TLoading", props: _objectSpread({}, props), directives: { TransferDom: TransferDom }, data: function data() { return { delayShowLoading: false }; }, created: function created() { this.delay && this.countDelay(); }, watch: { loading: { handler: function handler(value) { if (value) { this.countDelay(); this.lockFullscreen && addClass(document.body, "".concat(this.componentName, "--lock")); } else { this.lockFullscreen && removeClass(document.body, "".concat(this.componentName, "--lock")); } }, immediate: true } }, computed: { styles: function styles() { var styles = {}; if (this.zIndex !== void 0) { styles.zIndex = this.zIndex; } if (!["small", "medium", "large"].includes(this.size)) { styles["font-size"] = this.size; } return styles; }, showText: function showText() { return Boolean(this.text || this.$scopedSlots.text); }, baseClasses: function baseClasses() { return ["".concat(this.componentName, "--center"), this.commonSizeClassName[this.size], _defineProperty({}, "".concat(this.componentName, "--inherit-color"), this.inheritColor)]; }, hasContent: function hasContent() { return Boolean(this["default"] || this.$scopedSlots["default"] || this.content || this.$scopedSlots.content); }, withContentClasses: function withContentClasses() { return this.baseClasses.concat([this.componentName, "".concat(this.componentName, "--full"), _defineProperty({}, "".concat(this.componentName, "__overlay"), this.showOverlay)]); }, fullScreenClasses: function fullScreenClasses() { return [this.componentName, "".concat(this.componentName, "__fullscreen"), "".concat(this.componentName, "--center"), "".concat(this.componentName, "__overlay")]; }, attachClasses: function attachClasses() { return this.baseClasses.concat([this.componentName, "".concat(this.componentName, "--full"), _defineProperty({}, "".concat(this.componentName, "__overlay"), this.showOverlay)]); }, normalClasses: function normalClasses() { return this.baseClasses.concat([this.componentName]); }, lockFullscreen: function lockFullscreen() { return this.preventScrollThrough && this.fullscreen; }, delayCounted: function delayCounted() { return Boolean(!this.delay || this.delay && this.delayShowLoading); }, showWrapLoading: function showWrapLoading() { return this.hasContent && this.loading && this.delayCounted; }, showFullScreenLoading: function showFullScreenLoading() { return this.fullscreen && this.loading && this.delayCounted; }, showAttachedLoading: function showAttachedLoading() { return this.attach && this.loading && this.delayCounted; } }, methods: { countDelay: function countDelay() { var _this = this; this.delayShowLoading = false; var timer = setTimeout(function () { _this.delayShowLoading = true; clearTimeout(timer); }, this.delay); } }, render: function render() { var h = arguments[0]; var defaultIndicator = h(GradientIcon, { "attrs": { "size": this.size } }); var indicator = this.loading && renderTNodeJSX(this, "indicator", defaultIndicator); var text = this.showText && h("div", { "class": "".concat(this.classPrefix, "-loading__text") }, [renderTNodeJSX(this, "text")]); if (this.fullscreen) { if (!this.showFullScreenLoading || !this.loading) return null; return h("div", { "class": this.fullScreenClasses, "style": this.styles, "directives": [{ name: "transfer-dom", value: this.attach }] }, [h("div", { "class": this.baseClasses }, [indicator, text])]); } if (this.hasContent) { return h("div", { "class": "".concat(this.componentName, "__parent") }, [renderContent(this, "default", "content"), this.showWrapLoading && h("div", { "class": this.withContentClasses, "style": this.styles }, [indicator, text])]); } if (this.attach) { if (!this.showAttachedLoading || !this.loading) return; return h("div", { "class": this.attachClasses, "style": this.styles, "directives": [{ name: "transfer-dom", value: this.attach }] }, [indicator, text]); } if (this.loading) { return h("div", { "class": this.normalClasses, "style": this.styles }, [indicator, text]); } return null; } }); export { _Loading as default }; //# sourceMappingURL=loading.js.map