tdesign-vue
Version:
99 lines (95 loc) • 3.83 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import _Loading from './loading.js';
import { prefix } from '../config.js';
import { getAttach, removeClass } from '../utils/dom.js';
import './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 'lodash-es';
import '../config-provider/config-receiver.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 '../utils/mixins.js';
import '../utils/render-tnode.js';
import '@babel/runtime/helpers/readOnlyError';
import '@vue/composition-api';
import '../utils/transfer-dom.js';
import './props.js';
import 'raf';
import '../utils/easing.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 lockClass = "".concat(prefix, "-loading--lock");
var fullScreenLoadingInstance = null;
var normalLoadingInstance = null;
function createLoading(options) {
var props = _objectSpread({}, options);
var loading = new _Loading({
propsData: _objectSpread({}, props)
}).$mount();
var attach = getAttach(props.attach);
if (attach) {
attach.appendChild(loading.$el);
} else {
console.error("attach is not exist");
}
var loadingInstance = {
hide: function hide() {
var _loading$$el$parentNo;
loading.loading = false;
(_loading$$el$parentNo = loading.$el.parentNode) === null || _loading$$el$parentNo === void 0 || _loading$$el$parentNo.removeChild(loading.$el);
}
};
return loadingInstance;
}
function produceLoading(props) {
var destroyLoadingInstance = function destroyLoadingInstance() {
removeClass(document.body, lockClass);
fullScreenLoadingInstance.hide();
fullScreenLoadingInstance = null;
};
var destroyNormalLoadingInstance = function destroyNormalLoadingInstance() {
normalLoadingInstance.hide();
normalLoadingInstance = null;
};
if (props === true) {
if (fullScreenLoadingInstance) destroyLoadingInstance();
fullScreenLoadingInstance = createLoading({
fullscreen: true,
loading: true,
attach: "body"
});
return fullScreenLoadingInstance;
}
if (props === false) {
fullScreenLoadingInstance && destroyLoadingInstance();
normalLoadingInstance && destroyNormalLoadingInstance();
return;
}
normalLoadingInstance = createLoading(props);
return normalLoadingInstance;
}
var LoadingPlugin = produceLoading;
LoadingPlugin.install = function () {
Vue.prototype.$loading = produceLoading;
};
export { LoadingPlugin, LoadingPlugin as default };
//# sourceMappingURL=plugin.js.map