UNPKG

tdesign-vue

Version:
69 lines (65 loc) 2.03 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ import Vue from 'vue'; import props from '../props.js'; import { removeDom, getAttach } from '../../utils/dom.js'; import 'raf'; import 'lodash-es'; import '../../utils/easing.js'; var Container = Vue.extend({ props: { mode: props.mode, renderModal: Function, renderViewer: Function }, data: function data() { return { content: null, timer: null }; }, methods: { mountContent: function mountContent() { clearTimeout(this.timer); if (this.content) return; var _this = this; var elm = document.createElement("div"); elm.style.cssText = "position: absolute; top: 0px; left: 0px; width: 100%"; this.content = new this.$root.constructor({ render: function render() { return _this.mode === "modeless" ? _this.renderModal() : _this.renderViewer(); }, destroyed: function destroyed() { if (_this.content.$el) { removeDom(_this.content.$el); } _this.content = null; } }); getAttach(document.body).appendChild(elm); this.content.$mount(elm); }, unmountContent: function unmountContent() { var _this2 = this; clearTimeout(this.timer); this.timer = setTimeout(function () { var _this2$content, _this2$content$$destr; (_this2$content = _this2.content) === null || _this2$content === void 0 || (_this2$content$$destr = _this2$content.$destroy) === null || _this2$content$$destr === void 0 || _this2$content$$destr.call(_this2$content); }, 200); } }, render: function render() { var _children$; var h = arguments[0]; var children = this.$slots["default"] || []; if (children.length > 1 || !((_children$ = children[0]) !== null && _children$ !== void 0 && _children$.tag)) { return h("span", [children]); } return children[0]; } }); export { Container as default }; //# sourceMappingURL=Container.js.map