UNPKG

bootstrap-vue-next

Version:

BootstrapVueNext is an early and lovely component library for Vue 3 & Nuxt 3 based on Bootstrap 5 and Typescript.

52 lines (51 loc) 1.46 kB
import { getCurrentInstance, computed, toValue } from "vue"; import { u as useSharedModalStack } from "../../../useModalManager-CBl09N75.mjs"; const useModal = (id = void 0) => { const { registry } = useSharedModalStack(); const instance = getCurrentInstance(); const findBModal = (component) => { if (!component.parent) { return null; } if (component.parent.type.__name === "BModal") { return component.parent; } return findBModal(component.parent); }; const modalComponent = computed(() => { var _a; const resolvedId = toValue(id); if (resolvedId) { if (!registry) return null; for (const [, modal2] of registry.value) { if (toValue((_a = modal2 == null ? void 0 : modal2.exposed) == null ? void 0 : _a.id) === resolvedId) { return modal2; } } return null; } if (!instance) { return null; } return findBModal(instance); }); const modal = computed(() => { var _a; return (_a = modalComponent.value) == null ? void 0 : _a.proxy; }); return { show() { var _a, _b; (_b = (_a = modalComponent.value) == null ? void 0 : _a.exposed) == null ? void 0 : _b.show(); }, hide(trigger) { var _a, _b; (_b = (_a = modalComponent.value) == null ? void 0 : _a.exposed) == null ? void 0 : _b.hide(trigger, true); }, modal }; }; export { useModal }; //# sourceMappingURL=index.mjs.map