UNPKG

@opensig/opendesign

Version:

41 lines (40 loc) 1.04 kB
"use strict"; const vue = require("vue"); const OLoading_vue_vue_type_script_setup_true_lang = require("./OLoading.vue.js"); const initLoading = (opt, el) => { const vnode = vue.h(OLoading_vue_vue_type_script_setup_true_lang, Object.assign(opt || {}, { wrapper: el })); if (el) { vue.render(vnode, el); } return vnode.component; }; const useLoading = (opt, wrap = "body") => { let instance = null; if (vue.isRef(wrap)) { vue.watch( () => wrap.value, (el) => { instance = initLoading(opt, el); }, { immediate: true } ); } else if (wrap.nodeType === 1) { instance = initLoading(opt, wrap); } else if (typeof wrap === "string") { vue.onMounted(() => { const el = document.querySelector(wrap); if (el) { instance = initLoading(opt, el); } }); } return { toggle(show) { var _a; (_a = instance == null ? void 0 : instance.exposed) == null ? void 0 : _a.toggle(show); } }; }; module.exports = useLoading;