UNPKG

@opensig/opendesign

Version:

61 lines (60 loc) 2.05 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const OLoading_vue_vue_type_script_setup_true_lang = require("./OLoading.vue.js"); const is = require("../_utils/is.js"); let globalLoadingOptions = {}; const setVLoadingOption = (option) => { globalLoadingOptions = option; }; const WATCH_HANDLE = Symbol("watch-handle"); const VNODE = Symbol("vnode"); const renderLoading = (el, value, modifiers, shouldWatch) => { var _a; const selfOption = {}; if (is.isObject(value)) { Object.assign(selfOption, value); selfOption.wrapper = value.wrapper ?? null; if (shouldWatch) { (_a = el[WATCH_HANDLE]) == null ? void 0 : _a.call(el); el[WATCH_HANDLE] = void 0; if (vue.isReactive(value)) { el[WATCH_HANDLE] = vue.watch(value, (newValue) => { renderLoading(el, newValue, modifiers, false); }); } } } else { selfOption.visible = value; selfOption.wrapper = modifiers.body ? "body" : null; selfOption.mask = !modifiers.nomask; } const vnode = vue.h(OLoading_vue_vue_type_script_setup_true_lang, Object.assign({}, globalLoadingOptions, selfOption)); el[VNODE] = vnode; vue.render(vnode, el); }; const vLoading = { mounted(el, binding) { renderLoading(el, binding.value, binding.modifiers, true); }, updated(el, binding) { var _a, _b, _c; if (binding.value === binding.oldValue) return; if (is.isObject(binding.value)) { renderLoading(el, binding.value, binding.modifiers, true); } else { (_c = (_b = (_a = el[VNODE]) == null ? void 0 : _a.component) == null ? void 0 : _b.exposed) == null ? void 0 : _c.toggle(Boolean(binding.value)); } }, beforeUnmount(el) { var _a; (_a = el[WATCH_HANDLE]) == null ? void 0 : _a.call(el); vue.render(null, el); el[VNODE] = void 0; el[WATCH_HANDLE] = void 0; } }; exports.VNODE = VNODE; exports.WATCH_HANDLE = WATCH_HANDLE; exports.setVLoadingOption = setVLoadingOption; exports.vLoading = vLoading;