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.95 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),l=require("../../../keys-W3DrYQSP.js"),o={install(o){const t=e.ref([]),s=e.ref(!1),a=l=>{let o=()=>{};const s=new Promise((e=>{o=e}));return Object.assign(s,{id:l,ref:null,show(){return this.ref?(this.ref.show(),s):this.set({modelValue:!0})},hide(e){return this.ref?(this.ref.hide(e,!0),s):this.set({modelValue:!1})},toggle(){var e;return this.ref?(this.ref.toggle(),s):this.set({modelValue:!(null==(e=this.get())?void 0:e.modelValue)})},get:()=>t.value.find((e=>e._self===l)),set(o){var a;const n=t.value.findIndex((e=>e._self===l)),u=t.value[n];if(u){const l={...e.toValue(u),...e.toValue(o)};u.modelValue!==l.modelValue&&(null==(a=u["onUpdate:modelValue"])||a.call(u,l.modelValue)),t.value.splice(n,1,{...l,title:e.toValue(l.title),body:e.toValue(l.body),modelValue:e.toValue(l.modelValue)})}return s},async destroy(){var o,s;const a=t.value.find((e=>e._self===l));a&&(null==(s=(o=a.promise).stop)||s.call(o),a.modelValue&&await new Promise((l=>{a.modelValue=!1;const o=a.onHidden;a.onHidden=e=>{null==o||o(e),l(e)},e.nextTick((()=>{var e;null==(e=a["onUpdate:modelValue"])||e.call(a,!1)}))})),t.value.splice(t.value.findIndex((e=>e._self===l)),1))},async[Symbol.asyncDispose](){await this.destroy()}}),{value:s,resolve:o}},n=(l={},o={})=>{var n;const{component:u,slots:i}=e.toValue(l);u&&(e.isRef(l)?l.value.component=e.markRaw(u):"object"==typeof l&&(l.component=e.markRaw(u))),i&&(e.isRef(l)?l.value.slots=e.markRaw(i):"object"==typeof l&&(l.slots=e.markRaw(i)));const r=e.toRef(l),d=(null==(n=r.value)?void 0:n.id)||Symbol("Toast controller"),p=a(d);return p.stop=e.watch(r,(a=>{var n;const u={...e.toValue(a)},i=t.value.findIndex((e=>e._self===d)),c=-1===i?{}:t.value[i],v={_self:d,...c||{},promise:p,options:o};u.props&&(Object.assign(v,u.props),u.props=void 0),u.pos&&(v.position=u.pos,u.pos=void 0);for(const l in u)l.startsWith("on")?v[l]=u[l]:v[l]=e.toValue(u[l]);v.position=v.position||"top-end",v.modelValue=v.modelValue??5e3,v["onUpdate:modelValue"]=o=>{var s;null==(s=u["onUpdate:modelValue"])||s.call(u,o);const{modelValue:a}=e.toValue(l);if(e.isRef(l)&&!e.isRef(a)&&(l.value.modelValue=o),e.isRef(a)&&!e.isReadonly(a)&&(a.value=o),v.modelValue!==o){const e=t.value.find((e=>e._self===d));e&&(e.modelValue=o)}},-1===i?(void 0!==(null==(n=r.value)?void 0:n.appendToast)?r.value.appendToast:s.value)?t.value.push(v):t.value.unshift(v):t.value.splice(i,1,v)}),{deep:!0,immediate:!0}),e.onScopeDispose((()=>{var e,l;const o=t.value.find((e=>e._self===d));o&&(null==(l=(e=o.promise.value).destroy)||l.call(e))}),!0),p.value};o.provide(l.toastPluginKey,{_isAppend:s,_isOrchestratorInstalled:e.ref(!1),toasts:t,create:n,show:(e={})=>(console.warn("[BootstrapVueNext] useToastController: The `show` method is deprecated. Use the `create` method instead."),n(e).show())})}};exports.toastPlugin=o; //# sourceMappingURL=index.umd.js.map