UNPKG

xdesign-vue-next

Version:

XDesign Component for vue-next

104 lines (100 loc) 4.08 kB
/** * xdesign v1.0.6 * (c) 2023 xdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, reactive, h, createApp } from 'vue'; import _Loading from './loading.js'; import { removeClass, getAttach, addClass } from '../utils/dom.js'; import { usePrefixClass } from '../hooks/useConfig.js'; import '@babel/runtime/helpers/slicedToArray'; import './icon/gradient.js'; import '../_common/js/loading/circle-adapter.js'; import '../_common/js/utils/set-style.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import 'lodash/isString'; import 'lodash/isNull'; import 'lodash/isUndefined'; import 'lodash/isNumber'; import 'lodash/isArray'; import '../utils/render-tnode.js'; import 'lodash/isEmpty'; import 'lodash/isFunction'; import 'lodash/isObject'; import 'lodash/camelCase'; import 'lodash/kebabCase'; import './props.js'; import '../hooks/useTeleport.js'; import '../_chunks/dep-3a1cce9f.js'; import '../utils/easing.js'; import '../config-provider/useConfig.js'; import 'lodash/cloneDeep'; import '../config-provider/context.js'; import 'lodash/mergeWith'; import 'lodash/merge'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/en_US.js'; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } var fullScreenLoadingInstance = null; function createLoading(props) { var component = defineComponent({ setup: function setup() { var loadingOptions = reactive(props); return { loadingOptions: loadingOptions }; }, render: function render() { return h(_Loading, _objectSpread({}, this.loadingOptions)); } }); var attach = getAttach(props.attach); var loading = createApp(component).mount(document.createElement("div")); var parentRelativeClass = usePrefixClass("loading__parent--relative").value; var prefixClass = usePrefixClass("loading"); if (attach) { addClass(attach, parentRelativeClass); } else { console.error("attach is not exist"); } var loadingInstance = { hide: function hide() { var _attach$querySelector; loading.loading = false; (_attach$querySelector = attach.querySelectorAll(".".concat(prefixClass.value))) === null || _attach$querySelector === void 0 ? void 0 : _attach$querySelector.forEach(function (item) { item.remove(); }); removeClass(attach, parentRelativeClass); } }; return loadingInstance; } function produceLoading(props) { var lockClass = usePrefixClass("loading--lock"); if (props === true) { fullScreenLoadingInstance = createLoading({ fullscreen: true, loading: true, attach: "body" }); return fullScreenLoadingInstance; } removeClass(document.body, lockClass.value); if (props === false) { removeClass(document.body, lockClass.value); fullScreenLoadingInstance.hide(); fullScreenLoadingInstance = null; return; } return createLoading(props); } var LoadingPlugin = produceLoading; LoadingPlugin.install = function (app) { app.config.globalProperties.$loading = produceLoading; }; export { LoadingPlugin as default }; //# sourceMappingURL=plugin.js.map