(function(c,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core"],t):(c=typeof globalThis!="undefined"?globalThis:c||self,t(c.index={},c.Vue,c.core))})(this,function(c,t,v){"use strict";const b={modelValue:{type:Boolean,default:!1},zIndex:{type:Number,default:1e3},showOverlay:{type:Boolean,default:!0},escKeyCloseable:{type:Boolean,default:!0},position:{type:String,default:"right"},lockScroll:{type:Boolean,default:!0},closeOnClickOverlay:{type:Boolean,default:!0},beforeClose:{type:Function}},h={visible:{type:Boolean,default:!1},onClick:{type:Function}};function u(e,o,n){let l=e;return o&&(l+=`__${o}`),n&&(l+=`--${n}`),l}function y(e,o=!1){const n=o?`.devui-${e}`:`devui-${e}`;return{b:()=>u(n),e:r=>r?u(n,r):"",m:r=>r?u(n,"",r):"",em:(r,m)=>r&&m?u(n,r,m):""}}var S="",V=t.defineComponent({name:"DDrawerOverlay",props:h,emits:["click"],setup(e,o){const n=y("drawer"),l=a=>{o.emit("click",a)};return()=>t.createVNode(t.Transition,{name:"drawer-overlay-fade"},{default:()=>[e.visible&&t.createVNode("div",{class:n.e("overlay"),onClick:l},null)]})}});function O(){if(document.documentElement.scrollHeight>document.documentElement.clientHeight){const e=document.documentElement.scrollTop,o=document.documentElement.getAttribute("style");return document.documentElement.style.position="fixed",document.documentElement.style.top=`-${e}px`,document.documentElement.style.width=document.documentElement.style.width||"100%",document.documentElement.style.overflowY="scroll",()=>{o?document.documentElement.setAttribute("style",o):document.documentElement.removeAttribute("style"),document.documentElement.scrollTop=e}}}function E(e,o){const n=y("drawer"),l=t.ref(),a=t.computed(()=>({[n.b()]:!0,[n.m(e.position)]:!0})),s=()=>{o("update:modelValue",!1),o("close")};let d;const r=()=>{e.beforeClose?e.beforeClose(s):s()},m=()=>{e.closeOnClickOverlay&&r()},w=f=>{f.code==="Escape"&&r()};v.onClickOutside(l,r);const C=()=>{d==null||d(),document.removeEventListener("keyup",w)};return t.watch(()=>e.modelValue,f=>{f?(o("open"),e.lockScroll&&(d=O()),e.escKeyCloseable&&document.addEventListener("keyup",w)):C()}),t.onUnmounted(C),{drawerRef:l,drawerClasses:a,handleOverlayClick:m}}var N="",i=t.defineComponent({name:"DDrawer",inheritAttrs:!1,props:b,emits:["close","update:modelValue","open"],setup(e,{emit:o,slots:n,attrs:l}){const{drawerRef:a,drawerClasses:s,handleOverlayClick:d}=E(e,o);return()=>t.createVNode(t.Teleport,{to:"body"},{default:()=>[e.showOverlay&&t.createVNode(V,{visible:e.modelValue,style:{zIndex:e.zIndex},onClick:d},null),t.createVNode(t.Transition,{name:`drawer-fly-${e.position}`},{default:()=>{var r;return[e.modelValue&&t.createVNode("div",t.mergeProps({ref:a,class:s.value,style:{zIndex:e.zIndex+1}},l),[(r=n.default)==null?void 0:r.call(n)])]}})]})}});function k(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const g={modelValue:!1,content:"",zIndex:1e3,showOverlay:!0,escKeyCloseable:!0,position:"right",lockScroll:!0,closeOnClickOverlay:!0};function D(e){const o=document.createElement("div"),n=e.content;delete e.content;const l=t.createApp({setup(){const a=()=>{e.modelValue=!1};return t.onUnmounted(()=>{document.body.removeChild(o)}),()=>t.createVNode(i,t.mergeProps(e,{"onUpdate:modelValue":a}),k(n)?n:{default:()=>[n]})}});return document.body.appendChild(o),l.mount(o),l}class p{open(o){const n=t.reactive({...g,...o}),l=D(n);return n.modelValue=!0,{close:()=>{n.modelValue=!1,l.unmount()}}}}var x={title:"Drawer \u62BD\u5C49\u677F",category:"\u53CD\u9988",status:"75%",install(e){e.component(i.name,i),e.config.globalProperties.$drawerService=new p}};c.Drawer=i,c.DrawerService=p,c.default=x,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
