bootstrap-vue-next
Version:
BootstrapVueNext is an early and lovely component library for Vue 3 & Nuxt 3 based on Bootstrap 5 and Typescript.
1 lines • 2.29 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../../../src/composables/useModal/index.ts"],"sourcesContent":["import {\n type ComponentInternalInstance,\n computed,\n getCurrentInstance,\n type MaybeRefOrGetter,\n toValue,\n} from 'vue'\nimport {useSharedModalStack} from '../useModalManager'\n\nexport const useModal = (id: MaybeRefOrGetter<string | undefined> = undefined) => {\n const {registry} = useSharedModalStack()\n const instance = getCurrentInstance()\n\n const findBModal = (component: ComponentInternalInstance): ComponentInternalInstance | null => {\n if (!component.parent) {\n return null\n }\n\n if (component.parent.type.__name === 'BModal') {\n return component.parent\n }\n\n return findBModal(component.parent)\n }\n\n const modalComponent = computed(() => {\n const resolvedId = toValue(id)\n\n if (resolvedId) {\n if (!registry) return null\n for (const [, modal] of registry.value) {\n if (toValue(modal?.exposed?.id) === resolvedId) {\n return modal\n }\n }\n\n return null\n }\n\n if (!instance) {\n return null\n }\n\n return findBModal(instance)\n })\n\n const modal = computed(() => modalComponent.value?.proxy)\n\n return {\n show() {\n modalComponent.value?.exposed?.show()\n },\n hide(trigger?: string) {\n modalComponent.value?.exposed?.hide(trigger, true)\n },\n modal,\n }\n}\n"],"names":["modal"],"mappings":";;AASa,MAAA,WAAW,CAAC,KAA2C,WAAc;AAC1E,QAAA,EAAC,SAAQ,IAAI,oBAAoB;AACvC,QAAM,WAAW,mBAAmB;AAE9B,QAAA,aAAa,CAAC,cAA2E;AACzF,QAAA,CAAC,UAAU,QAAQ;AACd,aAAA;AAAA,IAAA;AAGT,QAAI,UAAU,OAAO,KAAK,WAAW,UAAU;AAC7C,aAAO,UAAU;AAAA,IAAA;AAGZ,WAAA,WAAW,UAAU,MAAM;AAAA,EACpC;AAEM,QAAA,iBAAiB,SAAS,MAAM;;AAC9B,UAAA,aAAa,QAAQ,EAAE;AAE7B,QAAI,YAAY;AACV,UAAA,CAAC,SAAiB,QAAA;AACtB,iBAAW,CAAGA,EAAAA,MAAK,KAAK,SAAS,OAAO;AACtC,YAAI,SAAQA,sCAAO,YAAPA,mBAAgB,EAAE,MAAM,YAAY;AACvCA,iBAAAA;AAAAA,QAAA;AAAA,MACT;AAGK,aAAA;AAAA,IAAA;AAGT,QAAI,CAAC,UAAU;AACN,aAAA;AAAA,IAAA;AAGT,WAAO,WAAW,QAAQ;AAAA,EAAA,CAC3B;AAED,QAAM,QAAQ,SAAS,MAAM;;AAAA,gCAAe,UAAf,mBAAsB;AAAA,GAAK;AAEjD,SAAA;AAAA,IACL,OAAO;;AACU,iCAAA,UAAA,mBAAO,YAAP,mBAAgB;AAAA,IACjC;AAAA,IACA,KAAK,SAAkB;;AACrB,iCAAe,UAAf,mBAAsB,YAAtB,mBAA+B,KAAK,SAAS;AAAA,IAC/C;AAAA,IACA;AAAA,EACF;AACF;"}