bootstrap-vue-next
Version:
Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development
1 lines • 3.52 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugins/registry/index.ts"],"sourcesContent":["import {\n breadcrumbGlobalIndexKey,\n breadcrumbRegistryKey,\n modalManagerKey,\n showHideRegistryKey,\n} from '../../utils/keys'\nimport {_newShowHideRegistry} from '../../composables/useRegistry'\nimport type {BreadcrumbItemRaw} from '../../types/BreadcrumbTypes'\nimport {type ComponentInternalInstance, computed, type Plugin, type Ref, ref} from 'vue'\n\nexport const registryPlugin: Plugin = {\n install(app) {\n // Provide global showHide registry\n const {register, values} = _newShowHideRegistry()\n app.provide(showHideRegistryKey, {register, values})\n\n // Provide global breadcrumb registry\n const items = ref<Record<string, BreadcrumbItemRaw[]>>({\n [breadcrumbGlobalIndexKey]: [],\n })\n const reset = (key: string = breadcrumbGlobalIndexKey) => {\n items.value[key] = []\n }\n app.provide(breadcrumbRegistryKey, {items, reset})\n\n /**\n * A collection of all currently active modals\n *\n * It was made into a map so that if a modal is ever added into the stack twice, it will not be duplicated\n * (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)\n * Didn't feel like fixing it in the modal component, so I just made it a map\n */\n const stack: Ref<Map<number, ComponentInternalInstance>> = ref(new Map())\n\n const countStack = computed(() => stack.value.size)\n const valuesStack = computed(() => [...stack.value.values()])\n const lastStack = computed(() => valuesStack.value[valuesStack.value.length - 1])\n\n const pushStack = (modal: Readonly<ComponentInternalInstance>) => {\n stack.value.set(modal.uid, modal)\n }\n const removeStack = (modal: Readonly<ComponentInternalInstance>) => {\n stack.value.delete(modal.uid)\n }\n\n /**\n * A collection of all registered modals\n */\n const registry: Ref<Map<number, ComponentInternalInstance>> = ref(new Map())\n\n // Utility getters not made, would not be used (count, last)\n\n const pushRegistry = (modal: Readonly<ComponentInternalInstance>) => {\n registry.value.set(modal.uid, modal)\n }\n const removeRegistry = (modal: Readonly<ComponentInternalInstance>) => {\n registry.value.delete(modal.uid)\n }\n\n app.provide(modalManagerKey, {\n countStack,\n lastStack,\n registry: computed(() => registry.value),\n stack: valuesStack,\n pushStack,\n removeStack,\n pushRegistry,\n removeRegistry,\n })\n },\n}\n"],"mappings":";;;;AAUA,IAAa,iBAAyB,EACpC,QAAQ,KAAK;CAEX,MAAM,EAAC,UAAU,WAAU,sBAAsB;AACjD,KAAI,QAAQ,qBAAqB;EAAC;EAAU;EAAO,CAAC;CAGpD,MAAM,QAAQ,IAAyC,GACpD,2BAA2B,EAAE,EAC/B,CAAC;CACF,MAAM,SAAS,MAAc,6BAA6B;AACxD,QAAM,MAAM,OAAO,EAAE;;AAEvB,KAAI,QAAQ,uBAAuB;EAAC;EAAO;EAAM,CAAC;;;;;;;;CASlD,MAAM,QAAqD,oBAAI,IAAI,KAAK,CAAC;CAEzE,MAAM,aAAa,eAAe,MAAM,MAAM,KAAK;CACnD,MAAM,cAAc,eAAe,CAAC,GAAG,MAAM,MAAM,QAAQ,CAAC,CAAC;CAC7D,MAAM,YAAY,eAAe,YAAY,MAAM,YAAY,MAAM,SAAS,GAAG;CAEjF,MAAM,aAAa,UAA+C;AAChE,QAAM,MAAM,IAAI,MAAM,KAAK,MAAM;;CAEnC,MAAM,eAAe,UAA+C;AAClE,QAAM,MAAM,OAAO,MAAM,IAAI;;;;;CAM/B,MAAM,WAAwD,oBAAI,IAAI,KAAK,CAAC;CAI5E,MAAM,gBAAgB,UAA+C;AACnE,WAAS,MAAM,IAAI,MAAM,KAAK,MAAM;;CAEtC,MAAM,kBAAkB,UAA+C;AACrE,WAAS,MAAM,OAAO,MAAM,IAAI;;AAGlC,KAAI,QAAQ,iBAAiB;EAC3B;EACA;EACA,UAAU,eAAe,SAAS,MAAM;EACxC,OAAO;EACP;EACA;EACA;EACA;EACD,CAAC;GAEL"}