tdesign-mobile-vue
Version:
tdesign-mobile-vue
143 lines (139 loc) • 5.35 kB
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
import { _ as _defineProperty } from '../_chunks/dep-219bb5a7.mjs';
import { defineComponent, reactive, h, createApp } from 'vue';
import { m as merge_1 } from '../_chunks/dep-ac139980.mjs';
import _Loading from './loading.mjs';
import { getAttach, addClass, removeClass } from '../shared/dom.mjs';
import { usePrefixClass } from '../hooks/useClass.mjs';
import '../_chunks/dep-620d73f7.mjs';
import '../_chunks/dep-8bf3054e.mjs';
import '../_chunks/dep-d2161895.mjs';
import '../_chunks/dep-89951f45.mjs';
import '../_chunks/dep-08bc7a4c.mjs';
import '../_chunks/dep-91d696ea.mjs';
import '../_chunks/dep-3d249f65.mjs';
import '../_chunks/dep-e6c129ab.mjs';
import '../_chunks/dep-6bc862af.mjs';
import '../_chunks/dep-4931819d.mjs';
import '../_chunks/dep-10f4d030.mjs';
import '../_chunks/dep-8ee6f5cd.mjs';
import '../_chunks/dep-e57d46f3.mjs';
import '../_chunks/dep-9b2de386.mjs';
import '../_chunks/dep-4f44985d.mjs';
import '../_chunks/dep-b84be35c.mjs';
import '../_chunks/dep-019e292f.mjs';
import '../_chunks/dep-32364550.mjs';
import '../_chunks/dep-933f3a85.mjs';
import '../_chunks/dep-154c1925.mjs';
import '../_chunks/dep-ba131d9c.mjs';
import '../_chunks/dep-007f294e.mjs';
import '../_common/js/global-config/mobile/default-config.mjs';
import '../_common/js/global-config/mobile/locale/zh_CN.mjs';
import '../_chunks/dep-161f0c44.mjs';
import '../_chunks/dep-5fd0eaa4.mjs';
import '../_chunks/dep-3c59bf72.mjs';
import './icon/gradient.mjs';
import '../_common/js/loading/circle-adapter.mjs';
import '../_common/js/utils/set-style.mjs';
import '../_common/js/utils/helper.mjs';
import '../_chunks/dep-f0f403be.mjs';
import '../_chunks/dep-8d37dbf8.mjs';
import '../_chunks/dep-8ece47c6.mjs';
import '../_chunks/dep-cd74809c.mjs';
import '../_chunks/dep-6303c50c.mjs';
import '../_chunks/dep-74a5dff9.mjs';
import '../_chunks/dep-1bbfa76e.mjs';
import '../_chunks/dep-52fdc8e1.mjs';
import '../config.mjs';
import './icon/spinner.mjs';
import './props.mjs';
import '../hooks/tnode.mjs';
import '../_chunks/dep-60cadef8.mjs';
import '../_chunks/dep-8140c29b.mjs';
import '../_chunks/dep-0d52e58f.mjs';
import '../_chunks/dep-a836a38c.mjs';
import '../_chunks/dep-0ea7bbde.mjs';
import '../_chunks/dep-b437ef0b.mjs';
import '../_chunks/dep-6917b9bc.mjs';
import '../hooks/render-tnode.mjs';
import '../_chunks/dep-40507aac.mjs';
import '../_chunks/dep-2bce42ea.mjs';
import '../_chunks/dep-b9b8ead5.mjs';
import '../_chunks/dep-6c53a3e4.mjs';
import '../config-provider/type.mjs';
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 fullScreenLoadingInstance = null;
function mergeDefaultProps(props) {
var options = merge_1({
fullscreen: false,
attach: "body",
loading: true
}, props);
return options;
}
function createLoading(props) {
var mergedProps = mergeDefaultProps(props);
if (mergedProps.fullscreen && fullScreenLoadingInstance) {
return fullScreenLoadingInstance;
}
var component = defineComponent({
setup: function setup() {
var loadingOptions = reactive(mergedProps);
return {
loadingOptions: loadingOptions
};
},
render: function render() {
return h(_Loading, _objectSpread({}, this.loadingOptions));
}
});
var attach = getAttach(mergedProps.fullscreen ? "body" : mergedProps.attach);
var app = createApp(component);
app.mount(document.createElement("div"));
var parentRelativeClass = usePrefixClass("loading__parent--relative").value;
var lockClass = usePrefixClass("loading--lock").value;
if (mergedProps.fullscreen) {
addClass(document.body, lockClass);
}
if (attach) {
addClass(attach, parentRelativeClass);
} else {
console.error("attach is not exist");
}
var loadingInstance = {
hide: function hide() {
removeClass(attach, parentRelativeClass);
removeClass(document.body, lockClass);
app.unmount();
}
};
return loadingInstance;
}
function produceLoading(props) {
if (props === true) {
fullScreenLoadingInstance = createLoading({
fullscreen: true,
loading: true,
attach: "body"
});
return fullScreenLoadingInstance;
}
if (props === false) {
var _fullScreenLoadingIns;
(_fullScreenLoadingIns = fullScreenLoadingInstance) === null || _fullScreenLoadingIns === void 0 || _fullScreenLoadingIns.hide();
fullScreenLoadingInstance = null;
return;
}
return createLoading(props);
}
var LoadingPlugin = produceLoading;
LoadingPlugin.install = function (app) {
app.config.globalProperties.$loading = produceLoading;
};
export { LoadingPlugin, LoadingPlugin as default };
//# sourceMappingURL=plugin.mjs.map