UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

114 lines (113 loc) 3.65 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); require("../../../chunk-CoQrYLCe.js"); const require_keys = require("../../../keys-durSVUrO.js"); let vue = require("vue"); //#region src/composables/orchestratorShared/index.ts function buildPromise(_id, store) { let resolveFunc = () => {}; const promise = new Promise((resolve) => { resolveFunc = resolve; }); Object.assign(promise, { id: _id, ref: null, show() { const refWithMethods = this.ref; if (refWithMethods?.show) refWithMethods.show(); else this.set({ modelValue: true }); const self = this; const asyncDispose = async () => { await self.destroy(); }; const showPromise = promise.then((event) => Object.assign(Object.create(event), { [Symbol.asyncDispose]: asyncDispose })); return Object.assign(showPromise, { id: self.id, ref: self.ref, show: () => self.show(), hide: (trigger) => self.hide(trigger), toggle: () => self.toggle(), set: (val) => self.set(val), get: () => self.get(), destroy: () => self.destroy(), [Symbol.asyncDispose]: asyncDispose }); }, hide(trigger) { const refWithMethods = this.ref; if (refWithMethods?.hide) refWithMethods.hide(trigger, true); else return this.set({ modelValue: false }); return promise; }, toggle() { const currentItem = this.get(); const refWithMethods = this.ref; if (refWithMethods?.toggle) refWithMethods.toggle(); else return this.set({ modelValue: !currentItem?.modelValue }); return promise; }, get() { return store.value.find((el) => el._self === _id); }, set(val) { const itemIndex = store.value.findIndex((el) => el._self === _id); const item = store.value[itemIndex]; if (item) { const v = { ...(0, vue.toValue)(item), ...(0, vue.toValue)(val) }; if (item.modelValue !== v.modelValue) item["onUpdate:modelValue"]?.(v.modelValue); const updatedItem = { ...v, modelValue: (0, vue.toValue)(v.modelValue) }; const vRecord = v; if ("title" in vRecord && vRecord.title !== void 0) updatedItem.title = (0, vue.toValue)(vRecord.title); if ("body" in vRecord && vRecord.body !== void 0) updatedItem.body = (0, vue.toValue)(vRecord.body); store.value.splice(itemIndex, 1, updatedItem); } return promise; }, async destroy() { const item = store.value.find((el) => el._self === _id); if (!item) return; item.promise.stop?.(); if (item.modelValue) await new Promise((resolve) => { const prev = item["onHidden"]; item["onHidden"] = (e) => { prev?.(e); resolve(e); }; (0, vue.nextTick)(() => { this.hide("destroy"); }); }); store.value.splice(store.value.findIndex((el) => el._self === _id), 1); }, async [Symbol.asyncDispose]() { await this.destroy(); } }); return { value: promise, resolve: resolveFunc, stop: void 0 }; } var _newOrchestratorRegistry = () => ({ store: (0, vue.ref)([]), _isOrchestratorInstalled: (0, vue.ref)(false), _isToastAppend: (0, vue.ref)(false) }); var useOrchestratorRegistry = () => { const orchestratorRegistry = (0, vue.inject)(require_keys.orchestratorRegistryKey, null); if (orchestratorRegistry) return orchestratorRegistry; const newOrchestratorRegistry = _newOrchestratorRegistry(); (0, vue.provide)(require_keys.orchestratorRegistryKey, newOrchestratorRegistry); return newOrchestratorRegistry; }; //#endregion exports._newOrchestratorRegistry = _newOrchestratorRegistry; exports.buildPromise = buildPromise; exports.useOrchestratorRegistry = useOrchestratorRegistry; //# sourceMappingURL=index.umd.js.map