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.89 kB
JavaScript
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),o=require("../../../keys-W3DrYQSP.js"),l={install(l){const t=e.ref([]),s=e.ref(!1),a=o=>{let l=()=>{};const s=new Promise((e=>{l=e}));return Object.assign(s,{id:o,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===o)),set(l){var a;const n=t.value.findIndex((e=>e._self===o)),i=t.value[n];if(i){const o={...e.toValue(i),...e.toValue(l)};i.modelValue!==o.modelValue&&(null==(a=i["onUpdate:modelValue"])||a.call(i,o.modelValue)),t.value.splice(n,1,{...o,title:e.toValue(o.title),body:e.toValue(o.body),modelValue:e.toValue(o.modelValue)})}return s},async destroy(){var l,s;const a=t.value.find((e=>e._self===o));a&&(null==(s=(l=a.promise).stop)||s.call(l),a.modelValue&&await new Promise((o=>{const l=a.onHidden;a.onHidden=e=>{null==l||l(e),o(e)},e.nextTick((()=>{this.hide("destroy")}))})),t.value.splice(t.value.findIndex((e=>e._self===o)),1))},async[Symbol.asyncDispose](){await this.destroy()}}),{value:s,resolve:l}},n=(o={},l={})=>{var n;const{component:i,slots:u}=e.toValue(o);i&&(e.isRef(o)?o.value.component=e.markRaw(i):"object"==typeof o&&(o.component=e.markRaw(i))),u&&(e.isRef(o)?o.value.slots=e.markRaw(u):"object"==typeof o&&(o.slots=e.markRaw(u)));const r=e.toRef(o),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 i={...e.toValue(a)},u=t.value.findIndex((e=>e._self===d)),c=-1===u?{}:t.value[u],v={_self:d,...c||{},promise:p,options:l};i.props&&(Object.assign(v,i.props),i.props=void 0),i.pos&&(v.position=i.pos,i.pos=void 0);for(const o in i)o.startsWith("on")?v[o]=i[o]:v[o]=e.toValue(i[o]);v.position=v.position||"top-end",v.modelValue=v.modelValue??5e3,v["onUpdate:modelValue"]=l=>{var s;null==(s=i["onUpdate:modelValue"])||s.call(i,l);const{modelValue:a}=e.toValue(o);if(e.isRef(o)&&!e.isRef(a)&&(o.value.modelValue=l),e.isRef(a)&&!e.isReadonly(a)&&(a.value=l),v.modelValue!==l){const e=t.value.find((e=>e._self===d));e&&(e.modelValue=l)}},-1===u?(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(u,1,v)}),{deep:!0,immediate:!0}),e.onScopeDispose((()=>{var e,o;const l=t.value.find((e=>e._self===d));l&&(null==(o=(e=l.promise.value).destroy)||o.call(e))}),!0),p.value};l.provide(o.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))})}};exports.toastPlugin=l;
//# sourceMappingURL=index.umd.js.map
;