UNPKG

bootstrap-vue-next

Version:

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

3 lines (2 loc) 2.13 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),l=require("../../../keys-W3DrYQSP.js"),o=require("../../../useModalManager-s_gKy0a-.js");exports.useModalController=()=>{const r=()=>(console.warn("useModalController() was called outside of the setup() function! or the plugin is not provided."),Promise.resolve(null)),n=e.inject(l.modalControllerPluginKey,{modals:e.ref(new Map),_isOrchestratorInstalled:e.ref(!1),create:r,show:r,confirm:r});if(n.create===r)throw Error("useModalController() was called outside of the setup() function! or the plugin is not provided.");const{lastStack:u,stack:d,registry:t}=o.useSharedModalStack(),a=e.getCurrentInstance();return{hide:(e,l)=>{var o,r,t;if(void 0===l)void 0===l&&(null==u?void 0:u.value)&&(null==(o=null==u?void 0:u.value.exposed)||o.hide(e));else{const o=null==d?void 0:d.value.find((e=>{var o;return(null==(o=e.exposed)?void 0:o.id)===l}));if(o)return void(null==(r=o.exposed)||r.hide(e));const u=n.modals.value.get(l);u?(u.modelValue=!1,null==(t=u["onUpdate:modelValue"])||t.call(u,!1)):null==d||d.value.forEach((o=>{var r,n;(null==(r=o.exposed)?void 0:r.id)===l&&(null==(n=o.exposed)||n.hide(e,!0))}))}},hideAll:e=>{null==d||d.value.forEach((l=>{var o;null==(o=l.exposed)||o.hide(e,!0)}))},get:l=>{var o;if(n.modals.value.get(l)){const e=n.modals.value.get(l);return{modal:e,show(){null==e||e.promise.value.show()},hide(l){null==e||e.promise.value.hide(l)}}}if(null==t?void 0:t.value)for(const[,r]of(null==t?void 0:t.value.entries())??[])if(e.toValue(null==(o=r.exposed)?void 0:o.id)===l)return{modal:r,show(){var e;null==(e=r.exposed)||e.show()},hide(e){var l;null==(l=r.exposed)||l.hide(e,!0)}};return null},current:()=>{const l=e=>e.parent?"BModal"===e.parent.type.__name?e.parent:l(e.parent):null;if(!a)return null;const o=e.computed((()=>l(a))),r=e.computed((()=>{var e;return null==(e=o.value)?void 0:e.proxy}));return{show(){var e,l;null==(l=null==(e=o.value)?void 0:e.exposed)||l.show()},hide(e){var l,r;null==(r=null==(l=o.value)?void 0:l.exposed)||r.hide(e,!0)},modal:r}},...n}}; //# sourceMappingURL=index.umd.js.map