index-3d809b27.js 2.7 KB

12
  1. import{B as z,bt as I,aj as D,aF as C,i as N,t as O,bu as j,g as $,aB as x,w as A,aw as F,bv as U,bw as K,bx as V,aO as y,j as q,k,m as G,f as J,R as L,by as Q}from"./index-312d0758.js";import{t as Z}from"./error-78e43d3e.js";import{a as _}from"./scroll-27bc6409.js";import{P as h}from"./vnode-e253b113.js";const ue=(e,o,n,s)=>{let l={offsetX:0,offsetY:0};const a=u=>{const m=u.clientX,f=u.clientY,{offsetX:v,offsetY:p}=l,d=e.value.getBoundingClientRect(),b=d.left,g=d.top,S=d.width,T=d.height,Y=document.documentElement.clientWidth,B=document.documentElement.clientHeight,P=-b+v,H=-g+p,X=Y-b-S+v,W=B-g-T+p,w=E=>{let i=v+E.clientX-m,r=p+E.clientY-f;s!=null&&s.value||(i=Math.min(Math.max(i,P),X),r=Math.min(Math.max(r,H),W)),l={offsetX:i,offsetY:r},e.value&&(e.value.style.transform=`translate(${C(i)}, ${C(r)})`)},M=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",M)},t=()=>{o.value&&e.value&&o.value.addEventListener("mousedown",a)},c=()=>{o.value&&e.value&&o.value.removeEventListener("mousedown",a)};z(()=>{I(()=>{n.value?t():c()})}),D(()=>{c()})},de=(e,o={})=>{N(e)||Z("[useLockscreen]","You need to pass a ref param to this function");const n=o.ns||O("popup"),s=j(()=>n.bm("parent","hidden"));if(!$||x(document.body,s.value))return;let l=0,a=!1,t="0";const c=()=>{setTimeout(()=>{V(document==null?void 0:document.body,s.value),a&&document&&(document.body.style.width=t)},200)};A(e,u=>{if(!u){c();return}a=!x(document.body,s.value),a&&(t=document.body.style.width),l=_(n.namespace.value);const m=document.documentElement.clientHeight<document.body.scrollHeight,f=F(document.body,"overflowY");l>0&&(m||f==="scroll")&&a&&(document.body.style.width=`calc(100% - ${l}px)`),U(document.body,s.value)}),K(()=>c())},R=e=>{if(!e)return{onClick:y,onMousedown:y,onMouseup:y};let o=!1,n=!1;return{onClick:t=>{o&&n&&e(t),o=n=!1},onMousedown:t=>{o=t.target===t.currentTarget},onMouseup:t=>{n=t.target===t.currentTarget}}},ee=q({mask:{type:Boolean,default:!0},customMaskEvent:{type:Boolean,default:!1},overlayClass:{type:k([String,Array,Object])},zIndex:{type:k([String,Number])}}),te={click:e=>e instanceof MouseEvent},oe="overlay";var ne=G({name:"ElOverlay",props:ee,emits:te,setup(e,{slots:o,emit:n}){const s=O(oe),l=u=>{n("click",u)},{onClick:a,onMousedown:t,onMouseup:c}=R(e.customMaskEvent?void 0:l);return()=>e.mask?J("div",{class:[s.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:a,onMousedown:t,onMouseup:c},[L(o,"default")],h.STYLE|h.CLASS|h.PROPS,["onClick","onMouseup","onMousedown"]):Q("div",{class:e.overlayClass,style:{zIndex:e.zIndex,position:"fixed",top:"0px",right:"0px",bottom:"0px",left:"0px"}},[L(o,"default")])}});const ie=ne;export{ie as E,de as a,R as b,ue as u};