mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
import{c as p,e as a,d as m,f as g}from"./use-translate.d2900b8c.js";import{m as r,n as w,u as k,w as y}from"./with-install.19a35764.js";import{m as O,u as P}from"./mount-component.f3744995.js";import{p as S,P as h}from"./index.e6e790ed.js";import{z as N,e as l,A as b}from"./vue-libs.b44bc779.js";const[C,D]=p("notify"),x=a({},S,{type:r("danger"),color:String,message:w,position:r("top"),className:k,background:String,lockScroll:Boolean}),u=N({name:C,props:x,emits:["update:show"],setup(e,{emit:t,slots:s}){const d=f=>t("update:show",f);return()=>l(h,{show:e.show,class:[D([e.type]),e.className],style:{color:e.color,background:e.background},overlay:!1,position:e.position,duration:.2,lockScroll:e.lockScroll,"onUpdate:show":d},{default:()=>[s.default?s.default():e.message]})}});let i,n;const B=e=>g(e)?e:{message:e};function I(){({instance:n}=O({setup(){const{state:e,toggle:t}=P();return()=>l(u,b(e,{"onUpdate:show":t}),null)}}))}function o(e){if(!!m)return n||I(),e=a({},o.currentOptions,B(e)),n.open(e),clearTimeout(i),e.duration>0&&(i=window.setTimeout(o.clear,e.duration)),n}const c=()=>({type:"danger",color:void 0,message:"",onClose:void 0,onClick:void 0,onOpened:void 0,duration:3e3,position:void 0,className:"",lockScroll:!1,background:void 0});o.clear=()=>{n&&n.toggle(!1)};o.currentOptions=c();o.setDefaultOptions=e=>{a(o.currentOptions,e)};o.resetDefaultOptions=()=>{o.currentOptions=c()};o.Component=y(u);o.install=e=>{e.use(o.Component),e.config.globalProperties.$notify=o};export{o as N};
|