index.ffff4535.js 4.5 KB

123
  1. import{r as A,G as V,e as N,$ as g,q as P,t as O,A as z,B as R,T as j,ak as D,H as q,L as $,D as I,O as B,b as G,aD as H}from"./vue.e266cb73.js";import{ab as Y,Y as x,i as F,ae as b,X as k}from"./index.dcc65bf7.js";function K(t){let e;const l=A(!1),n=V({...t,originalPosition:"",originalOverflow:"",visible:!1});function a(o){n.text=o}function s(){const o=n.parent,r=d.ns;if(!o.vLoadingAddClassList){let c=o.getAttribute("loading-number");c=Number.parseInt(c)-1,c?o.setAttribute("loading-number",c.toString()):(x(o,r.bm("parent","relative")),o.removeAttribute("loading-number")),x(o,r.bm("parent","hidden"))}i(),m.unmount()}function i(){var o,r;(r=(o=d.$el)==null?void 0:o.parentNode)==null||r.removeChild(d.$el)}function v(){var o;t.beforeClose&&!t.beforeClose()||(l.value=!0,clearTimeout(e),e=window.setTimeout(f,400),n.visible=!1,(o=t.closed)==null||o.call(t))}function f(){if(!l.value)return;const o=n.parent;l.value=!1,o.vLoadingAddClassList=void 0,s()}const u=N({name:"ElLoading",setup(o,{expose:r}){const{ns:c,zIndex:S}=Y("loading");return r({ns:c,zIndex:S}),()=>{const L=n.spinner||n.svg,T=g("svg",{class:"circular",viewBox:n.svgViewBox?n.svgViewBox:"0 0 50 50",...L?{innerHTML:L}:{}},[g("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none"})]),E=n.text?g("p",{class:c.b("text")},[n.text]):void 0;return g(j,{name:c.b("fade"),onAfterLeave:f},{default:P(()=>[O(z("div",{style:{backgroundColor:n.background||""},class:[c.b("mask"),n.customClass,n.fullscreen?"is-fullscreen":""]},[g("div",{class:c.b("spinner")},[T,E])]),[[R,n.visible]])])})}}}),m=D(u),d=m.mount(document.createElement("div"));return{...q(n),setText:a,removeElLoadingChild:i,close:v,handleAfterLeave:f,vm:d,get $el(){return d.$el}}}let p;const y=function(t={}){if(!F)return;const e=M(t);if(e.fullscreen&&p)return p;const l=K({...e,closed:()=>{var a;(a=e.closed)==null||a.call(e),e.fullscreen&&(p=void 0)}});X(e,e.parent,l),h(e,e.parent,l),e.parent.vLoadingAddClassList=()=>h(e,e.parent,l);let n=e.parent.getAttribute("loading-number");return n?n=`${Number.parseInt(n)+1}`:n="1",e.parent.setAttribute("loading-number",n),e.parent.appendChild(l.$el),$(()=>l.visible.value=e.visible),e.fullscreen&&(p=l),l},M=t=>{var e,l,n,a;let s;return I(t.target)?s=(e=document.querySelector(t.target))!=null?e:document.body:s=t.target||document.body,{parent:s===document.body||t.body?document.body:s,background:t.background||"",svg:t.svg||"",svgViewBox:t.svgViewBox||"",spinner:t.spinner||!1,text:t.text||"",fullscreen:s===document.body&&((l=t.fullscreen)!=null?l:!0),lock:(n=t.lock)!=null?n:!1,customClass:t.customClass||"",visible:(a=t.visible)!=null?a:!0,target:s}},X=async(t,e,l)=>{const{nextZIndex:n}=l.vm.zIndex||l.vm._.exposed.zIndex,a={};if(t.fullscreen)l.originalPosition.value=b(document.body,"position"),l.originalOverflow.value=b(document.body,"overflow"),a.zIndex=n();else if(t.parent===document.body){l.originalPosition.value=b(document.body,"position"),await $();for(const s of["top","left"]){const i=s==="top"?"scrollTop":"scrollLeft";a[s]=`${t.target.getBoundingClientRect()[s]+document.body[i]+document.documentElement[i]-Number.parseInt(b(document.body,`margin-${s}`),10)}px`}for(const s of["height","width"])a[s]=`${t.target.getBoundingClientRect()[s]}px`}else l.originalPosition.value=b(e,"position");for(const[s,i]of Object.entries(a))l.$el.style[s]=i},h=(t,e,l)=>{const n=l.vm.ns||l.vm._.exposed.ns;["absolute","fixed","sticky"].includes(l.originalPosition.value)?x(e,n.bm("parent","relative")):k(e,n.bm("parent","relative")),t.fullscreen&&t.lock?k(e,n.bm("parent","hidden")):x(e,n.bm("parent","hidden"))},C=Symbol("ElLoading"),w=(t,e)=>{var l,n,a,s;const i=e.instance,v=o=>B(e.value)?e.value[o]:void 0,f=o=>{const r=I(o)&&(i==null?void 0:i[o])||o;return r&&A(r)},u=o=>f(v(o)||t.getAttribute(`element-loading-${H(o)}`)),m=(l=v("fullscreen"))!=null?l:e.modifiers.fullscreen,d={text:u("text"),svg:u("svg"),svgViewBox:u("svgViewBox"),spinner:u("spinner"),background:u("background"),customClass:u("customClass"),fullscreen:m,target:(n=v("target"))!=null?n:m?void 0:t,body:(a=v("body"))!=null?a:e.modifiers.body,lock:(s=v("lock"))!=null?s:e.modifiers.lock};t[C]={options:d,instance:y(d)}},Z=(t,e)=>{for(const l of Object.keys(e))G(e[l])&&(e[l].value=t[l])},_={mounted(t,e){e.value&&w(t,e)},updated(t,e){const l=t[C];e.oldValue!==e.value&&(e.value&&!e.oldValue?w(t,e):e.value&&e.oldValue?B(e.value)&&Z(e.value,l.options):l==null||l.instance.close())},unmounted(t){var e;(e=t[C])==null||e.instance.close()}},U={install(t){t.directive("loading",_),t.config.globalProperties.$loading=y},directive:_,service:y};export{U as E};
  2. //# sourceMappingURL=index.ffff4535.js.map