UNPKG

bootstrap-vue-next

Version:

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

60 lines (59 loc) 1.97 kB
import { h as modalManagerKey, i as breadcrumbRegistryKey, r as breadcrumbGlobalIndexKey, x as showHideRegistryKey } from "../../../keys-CQKrwmvN.mjs"; import { _newShowHideRegistry } from "../../composables/useRegistry/index.mjs"; import { computed, ref } from "vue"; //#region src/plugins/registry/index.ts var registryPlugin = { install(app) { const { register, values } = _newShowHideRegistry(); app.provide(showHideRegistryKey, { register, values }); const items = ref({ [breadcrumbGlobalIndexKey]: [] }); const reset = (key = breadcrumbGlobalIndexKey) => { items.value[key] = []; }; app.provide(breadcrumbRegistryKey, { items, reset }); /** * A collection of all currently active modals * * It was made into a map so that if a modal is ever added into the stack twice, it will not be duplicated * (if modelValue is true when started, it gets added in setup scope, then a watcher is triggered and it gets added again in the next tick) * Didn't feel like fixing it in the modal component, so I just made it a map */ const stack = ref(/* @__PURE__ */ new Map()); const countStack = computed(() => stack.value.size); const valuesStack = computed(() => [...stack.value.values()]); const lastStack = computed(() => valuesStack.value[valuesStack.value.length - 1]); const pushStack = (modal) => { stack.value.set(modal.uid, modal); }; const removeStack = (modal) => { stack.value.delete(modal.uid); }; /** * A collection of all registered modals */ const registry = ref(/* @__PURE__ */ new Map()); const pushRegistry = (modal) => { registry.value.set(modal.uid, modal); }; const removeRegistry = (modal) => { registry.value.delete(modal.uid); }; app.provide(modalManagerKey, { countStack, lastStack, registry: computed(() => registry.value), stack: valuesStack, pushStack, removeStack, pushRegistry, removeRegistry }); } }; //#endregion export { registryPlugin }; //# sourceMappingURL=index.mjs.map