UNPKG

@aotearoan/neon

Version:

Neon is a lightweight design library of Vue 3 components with minimal dependencies.

3 lines (2 loc) 1.76 kB
"use strict";const v=require("vue"),A=require("../note/NeonNote.vue.cjs.js"),m=require("../../user-input/button/NeonButton.vue.cjs.js"),n=require("../../../model/feedback/alert/NeonAlertLevel.cjs.js"),o=require("../../../utils/common/event/NeonEventBus.cjs.js"),r=require("../../../utils/feedback/banner/NeonBannerService.cjs.js"),L=v.defineComponent({name:"NeonBanner",components:{NeonNote:A,NeonButton:m},setup(){const t=v.ref([]),a=v.ref(1),f=e=>{t.value=t.value.filter(s=>s.id!==e.id)},c=(e,s)=>{const l=a.value;a.value=a.value+1;const S={...s,level:e,id:l};t.value.unshift(S)},u=e=>{const s=t.value.findIndex(l=>l.key===e);s>=0&&t.value.splice(s,1)},N=e=>{c(n.NeonAlertLevel.Info,e)},i=e=>{c(n.NeonAlertLevel.Success,e)},B=e=>{c(n.NeonAlertLevel.Warn,e)},E=e=>{c(n.NeonAlertLevel.Error,e)},g=()=>{const e=t.value[0];e&&(f(e),e.action.callback())};return v.onMounted(()=>{o.NeonEventBus.on(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Info),N),o.NeonEventBus.on(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Success),i),o.NeonEventBus.on(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Warn),B),o.NeonEventBus.on(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Error),E),o.NeonEventBus.on(r.NeonBannerService.removeEventKey,u)}),v.onUnmounted(()=>{o.NeonEventBus.off(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Info),N),o.NeonEventBus.off(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Success),i),o.NeonEventBus.off(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Warn),B),o.NeonEventBus.off(r.NeonBannerService.generateEventKey(n.NeonAlertLevel.Error),E),o.NeonEventBus.off(r.NeonBannerService.removeEventKey,u)}),{onAction:g,messages:t}}});module.exports=L; //# sourceMappingURL=NeonBanner.cjs.js.map