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.86 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),o=require("../../../keys-W3DrYQSP.js"),l={install(l){const t=e.ref(new Map),a=e.ref(!1),s=o=>{let l=()=>{};const a=new Promise((e=>{l=e}));return Object.assign(a,{id:o,ref:null,show(){return this.ref?(this.ref.show(),a):this.set({modelValue:!0})},hide(e){return this.ref?(this.ref.hide(e,!0),a):this.set({modelValue:!1})},toggle(){var e;return this.ref?(this.ref.toggle(),a):this.set({modelValue:!(null==(e=this.get())?void 0:e.modelValue)})},get:()=>t.value.get(o),set(l){var s;const r=t.value.get(o);if(r){const a={...e.toValue(r),...e.toValue(l)};r.modelValue!==a.modelValue&&(null==(s=r["onUpdate:modelValue"])||s.call(r,a.modelValue)),t.value.set(o,{...a,title:e.toValue(a.title),body:e.toValue(a.body),modelValue:e.toValue(a.modelValue)})}return a},async destroy(){var l,a;const s=t.value.get(o);s&&(null==(a=(l=s.promise).stop)||a.call(l),s.modelValue&&await new Promise((o=>{s.modelValue=!1;const l=s.onHidden;s.onHidden=e=>{null==l||l(e),o(e)},e.nextTick((()=>{var e;null==(e=s["onUpdate:modelValue"])||e.call(s,!1)}))})),t.value.delete(o))},async[Symbol.asyncDispose](){await this.destroy()}}),{value:a,resolve:l}},r=(o={},l={})=>{var r;if(!a.value)throw new Error("The BModalOrchestrator component must be mounted to use the modal controller");const{component:n,slots:u}=e.toValue(o);n&&(e.isRef(o)?o.value.component=e.markRaw(n):"object"==typeof o&&(o.component=e.markRaw(n))),u&&(e.isRef(o)?o.value.slots=e.markRaw(u):"object"==typeof o&&(o.slots=e.markRaw(u)));const d=e.toRef(o),i=(null==(r=d.value)?void 0:r.id)||Symbol("Modals controller"),c=s(i);return c.stop=e.watch(d,(a=>{const s={...e.toValue(a)},r={...t.value.get(i)||{}};s.props&&(Object.assign(r,s.props),s.props=void 0);for(const o in s)o.startsWith("on")?r[o]=s[o]:r[o]=e.toValue(s[o]);t.value.set(i,{...r,...void 0===r.modelValue&&{modelValue:!0},"onUpdate:modelValue":l=>{var a;null==(a=s["onUpdate:modelValue"])||a.call(s,l);const{modelValue:r}=e.toValue(o);e.isRef(o)&&!e.isRef(r)&&(o.value.modelValue=l),e.isRef(r)&&!e.isReadonly(r)&&(r.value=l);const n=t.value.get(i);n&&t.value.set(i,{...n,modelValue:l})},options:l,promise:c})}),{immediate:!0,deep:!0}),e.onScopeDispose((()=>{var e,o;const l=t.value.get(i);l&&(null==(o=(e=l.promise.value).destroy)||o.call(e))}),!0),c.value};l.provide(o.modalControllerPluginKey,{_isOrchestratorInstalled:a,create:r,modals:t,show:(e={})=>(console.warn("[BootstrapVueNext] useModalController: The show() method is deprecated. Use create({}).show() instead."),r(e,{returnBoolean:!0}).show()),confirm:(e={})=>(console.warn("[BootstrapVueNext] useModalController: The confirm() method is deprecated. Use create({}).show() instead."),r(e,{returnBoolean:!0}).show())})}};exports.modalControllerPlugin=l; //# sourceMappingURL=index.umd.js.map