bootstrap-vue-next
Version:
Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development
1 lines • 3.54 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,qBAAqB;CAChD,IAAI,QAAQ,qBAAqB;EAAC;EAAU;CAAM,CAAC;CAGnD,MAAM,QAAQ,IAAyC,GACpD,2BAA2B,CAAC,EAC/B,CAAC;CACD,MAAM,SAAS,MAAc,6BAA6B;EACxD,MAAM,MAAM,OAAO,CAAC;CACtB;CACA,IAAI,QAAQ,uBAAuB;EAAC;EAAO;CAAK,CAAC;;;;;;;;CASjD,MAAM,QAAqD,oBAAI,IAAI,IAAI,CAAC;CAExE,MAAM,aAAa,eAAe,MAAM,MAAM,IAAI;CAClD,MAAM,cAAc,eAAe,CAAC,GAAG,MAAM,MAAM,OAAO,CAAC,CAAC;CAC5D,MAAM,YAAY,eAAe,YAAY,MAAM,YAAY,MAAM,SAAS,EAAE;CAEhF,MAAM,aAAa,UAA+C;EAChE,MAAM,MAAM,IAAI,MAAM,KAAK,KAAK;CAClC;CACA,MAAM,eAAe,UAA+C;EAClE,MAAM,MAAM,OAAO,MAAM,GAAG;CAC9B;;;;CAKA,MAAM,WAAwD,oBAAI,IAAI,IAAI,CAAC;CAI3E,MAAM,gBAAgB,UAA+C;EACnE,SAAS,MAAM,IAAI,MAAM,KAAK,KAAK;CACrC;CACA,MAAM,kBAAkB,UAA+C;EACrE,SAAS,MAAM,OAAO,MAAM,GAAG;CACjC;CAEA,IAAI,QAAQ,iBAAiB;EAC3B;EACA;EACA,UAAU,eAAe,SAAS,KAAK;EACvC,OAAO;EACP;EACA;EACA;EACA;CACF,CAAC;AACH,EACF"}