mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-04 04:08:13 +00:00
2 lines
3.8 KiB
JavaScript
2 lines
3.8 KiB
JavaScript
import{Q as l,aI as a,I as X,cm as z,ay as G,b0 as U,o as V,a as W,$ as g,l as N,c as K,h as x,cI as $,i as j,au as A,w as Q,cF as q,bv as J,bF as Z,bw as P,N as v,b as F,d as O,g as ee,F as oe,t as Y,a8 as te}from"./base-45eb5090.js";import{t as ne}from"./event-4977bef7.js";import{a as se}from"./focus-trap-318ae2e0.js";var d=(e=>(e[e.TEXT=1]="TEXT",e[e.CLASS=2]="CLASS",e[e.STYLE=4]="STYLE",e[e.PROPS=8]="PROPS",e[e.FULL_PROPS=16]="FULL_PROPS",e[e.HYDRATE_EVENTS=32]="HYDRATE_EVENTS",e[e.STABLE_FRAGMENT=64]="STABLE_FRAGMENT",e[e.KEYED_FRAGMENT=128]="KEYED_FRAGMENT",e[e.UNKEYED_FRAGMENT=256]="UNKEYED_FRAGMENT",e[e.NEED_PATCH=512]="NEED_PATCH",e[e.DYNAMIC_SLOTS=1024]="DYNAMIC_SLOTS",e[e.HOISTED=-1]="HOISTED",e[e.BAIL=-2]="BAIL",e))(d||{});function re(e){return a(e)&&e.type===X}function ue(e){return a(e)&&e.type===z}function pe(e){return a(e)&&!re(e)&&!ue(e)}const Ee=e=>{if(!a(e))return{};const s=e.props||{},t=(a(e.type)?e.type.props:void 0)||{},o={};return Object.keys(t).forEach(n=>{G(t[n],"default")&&(o[n]=t[n].default)}),Object.keys(s).forEach(n=>{o[U(n)]=s[n]}),o},ve=e=>{if(!l(e)||e.length>1)throw new Error("expect to receive a single Vue element child");return e[0]},y=e=>{const s=l(e)?e:[e],t=[];return s.forEach(o=>{var n;l(o)?t.push(...y(o)):a(o)&&l(o.children)?t.push(...y(o.children)):(t.push(o),a(o)&&((n=o.component)!=null&&n.subTree)&&t.push(...y(o.component.subTree)))}),t},ye=(e,s,t)=>{let o={offsetX:0,offsetY:0};const n=i=>{const c=i.clientX,f=i.clientY,{offsetX:p,offsetY:E}=o,m=e.value.getBoundingClientRect(),T=m.left,b=m.top,D=m.width,_=m.height,I=document.documentElement.clientWidth,k=document.documentElement.clientHeight,H=-T+p,B=-b+E,R=I-T-D+p,h=k-b-_+E,S=w=>{const C=Math.min(Math.max(p+w.clientX-c,H),R),L=Math.min(Math.max(E+w.clientY-f,B),h);o={offsetX:C,offsetY:L},e.value.style.transform=`translate(${N(C)}, ${N(L)})`},M=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",M)},u=()=>{s.value&&e.value&&s.value.addEventListener("mousedown",n)},r=()=>{s.value&&e.value&&s.value.removeEventListener("mousedown",n)};V(()=>{W(()=>{t.value?u():r()})}),g(()=>{r()})},Te=e=>{K(e)||ne("[useLockscreen]","You need to pass a ref param to this function");const s=x("popup"),t=$(()=>s.bm("parent","hidden"));if(!j||A(document.body,t.value))return;let o=0,n=!1,u="0";const r=()=>{setTimeout(()=>{P(document.body,t.value),n&&(document.body.style.width=u)},200)};Q(e,i=>{if(!i){r();return}n=!A(document.body,t.value),n&&(u=document.body.style.width),o=se(s.namespace.value);const c=document.documentElement.clientHeight<document.body.scrollHeight,f=q(document.body,"overflowY");o>0&&(c||f==="scroll")&&n&&(document.body.style.width=`calc(100% - ${o}px)`),J(document.body,t.value)}),Z(()=>r())},ae=e=>{if(!e)return{onClick:v,onMousedown:v,onMouseup:v};let s=!1,t=!1;return{onClick:r=>{s&&t&&e(r),s=t=!1},onMousedown:r=>{s=r.target===r.currentTarget},onMouseup:r=>{t=r.target===r.currentTarget}}},ie=F({mask:{type:Boolean,default:!0},customMaskEvent:{type:Boolean,default:!1},overlayClass:{type:O([String,Array,Object])},zIndex:{type:O([String,Number])}}),ce={click:e=>e instanceof MouseEvent};var me=ee({name:"ElOverlay",props:ie,emits:ce,setup(e,{slots:s,emit:t}){const o=x("overlay"),n=c=>{t("click",c)},{onClick:u,onMousedown:r,onMouseup:i}=ae(e.customMaskEvent?void 0:n);return()=>e.mask?oe("div",{class:[o.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:u,onMousedown:r,onMouseup:i},[Y(s,"default")],d.STYLE|d.CLASS|d.PROPS,["onClick","onMouseup","onMousedown"]):te("div",{class:e.overlayClass,style:{zIndex:e.zIndex,position:"fixed",top:"0px",right:"0px",bottom:"0px",left:"0px"}},[Y(s,"default")])}});const be=me;export{be as E,d as P,pe as a,Te as b,ae as c,ve as e,y as f,Ee as g,re as i,ye as u};
|