1 |
- import{cx as me,aY as ve,a$ as pe,b5 as be,ce as ge,bb as Y,d as V,cy as G,cz as ke,cA as _e,bH as we,b1 as xe,cB as ye,r as C,cC as Ie,cm as ze,b as _,aP as j,am as Ce,B as he,o as h,l as q,i,w as b,g as v,W as f,a,ar as J,aO as Ne,a2 as N,b2 as w,cD as Oe,c as F,F as K,cE as Te,cF as Ae,cG as Ee,cH as Le,aN as Re,cI as Xe,cJ as Ye,k as Fe,C as Se,a1 as Be,aF as $e,X as De,cK as Me,b3 as Pe,cL as E,bE as z,cM as We,b4 as He,__tla as Ve}from"./index-afaf388d.js";let U,O,Ge=Promise.all([(()=>{try{return Ve}catch{}})()]).then(async()=>{O=function(g,T,m){var n=!0,p=!0;if(typeof g!="function")throw new TypeError("Expected a function");return me(m)&&(n="leading"in m?!!m.leading:n,p="trailing"in m?!!m.trailing:p),ve(g,T,{leading:n,maxWait:T,trailing:p})};const Z=pe({urlList:{type:be(Array),default:()=>ge([])},zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:Boolean,teleported:Boolean,closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7}}),Q={close:()=>!0,switch:g=>Y(g),rotate:g=>Y(g)},ee=["src"],ae=V({name:"ElImageViewer"});U=He(Pe(V({...ae,props:Z,emits:Q,setup(g,{expose:T,emit:m}){const n=g,p={CONTAIN:{name:"contain",icon:G(ke)},ORIGINAL:{name:"original",icon:G(_e)}},{t:se}=we(),l=xe("image-viewer"),{nextZIndex:ne}=ye(),L=C(),S=C([]),B=Ie(),y=C(!0),k=C(n.initialIndex),A=ze(p.CONTAIN),t=C({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),le=_(()=>{const{urlList:e}=n;return e.length<=1}),$=_(()=>k.value===0),D=_(()=>k.value===n.urlList.length-1),te=_(()=>n.urlList[k.value]),oe=_(()=>[l.e("btn"),l.e("prev"),l.is("disabled",!n.infinite&&$.value)]),ie=_(()=>[l.e("btn"),l.e("next"),l.is("disabled",!n.infinite&&D.value)]),ce=_(()=>{const{scale:e,deg:s,offsetX:o,offsetY:u,enableTransition:c}=t.value;let r=o/e,d=u/e;switch(s%360){case 90:case-270:[r,d]=[d,-r];break;case 180:case-180:[r,d]=[-r,-d];break;case 270:case-90:[r,d]=[-d,r]}const I={transform:`scale(${e}) rotate(${s}deg) translate(${r}px, ${d}px)`,transition:c?"transform .3s":""};return A.value.name===p.CONTAIN.name&&(I.maxWidth=I.maxHeight="100%"),I}),ue=_(()=>Y(n.zIndex)?n.zIndex:ne());function R(){B.stop(),m("close")}function re(){y.value=!1}function de(e){y.value=!1,e.target.alt=se("el.image.error")}function fe(e){if(y.value||e.button!==0||!L.value)return;t.value.enableTransition=!1;const{offsetX:s,offsetY:o}=t.value,u=e.pageX,c=e.pageY,r=O(I=>{t.value={...t.value,offsetX:s+I.pageX-u,offsetY:o+I.pageY-c}}),d=E(document,"mousemove",r);E(document,"mouseup",()=>{d()}),e.preventDefault()}function M(){t.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}function P(){if(y.value)return;const e=We(p),s=Object.values(p),o=A.value.name,u=(s.findIndex(c=>c.name===o)+1)%e.length;A.value=p[e[u]],M()}function X(e){const s=n.urlList.length;k.value=(e+s)%s}function W(){$.value&&!n.infinite||X(k.value-1)}function H(){D.value&&!n.infinite||X(k.value+1)}function x(e,s={}){if(y.value)return;const{minScale:o,maxScale:u}=n,{zoomRate:c,rotateDeg:r,enableTransition:d}={zoomRate:n.zoomRate,rotateDeg:90,enableTransition:!0,...s};switch(e){case"zoomOut":t.value.scale>o&&(t.value.scale=Number.parseFloat((t.value.scale/c).toFixed(3)));break;case"zoomIn":t.value.scale<u&&(t.value.scale=Number.parseFloat((t.value.scale*c).toFixed(3)));break;case"clockwise":t.value.deg+=r,m("rotate",t.value.deg);break;case"anticlockwise":t.value.deg-=r,m("rotate",t.value.deg)}t.value.enableTransition=d}return j(te,()=>{Ce(()=>{const e=S.value[0];e!=null&&e.complete||(y.value=!0)})}),j(k,e=>{M(),m("switch",e)}),he(()=>{var e,s;(function(){const o=O(c=>{switch(c.code){case z.esc:n.closeOnPressEscape&&R();break;case z.space:P();break;case z.left:W();break;case z.up:x("zoomIn");break;case z.right:H();break;case z.down:x("zoomOut")}}),u=O(c=>{x((c.deltaY||c.deltaX)<0?"zoomIn":"zoomOut",{zoomRate:n.zoomRate,enableTransition:!1})});B.run(()=>{E(document,"keydown",o),E(document,"wheel",u)})})(),(s=(e=L.value)==null?void 0:e.focus)==null||s.call(e)}),T({setActiveItem:X}),(e,s)=>(h(),q(Me,{to:"body",disabled:!e.teleported},[i(De,{name:"viewer-fade",appear:""},{default:b(()=>[v("div",{ref_key:"wrapper",ref:L,tabindex:-1,class:f(a(l).e("wrapper")),style:J({zIndex:a(ue)})},[v("div",{class:f(a(l).e("mask")),onClick:s[0]||(s[0]=Ne(o=>e.hideOnClickModal&&R(),["self"]))},null,2),N(" CLOSE "),v("span",{class:f([a(l).e("btn"),a(l).e("close")]),onClick:R},[i(a(w),null,{default:b(()=>[i(a(Oe))]),_:1})],2),N(" ARROW "),a(le)?N("v-if",!0):(h(),F(K,{key:0},[v("span",{class:f(a(oe)),onClick:W},[i(a(w),null,{default:b(()=>[i(a(Te))]),_:1})],2),v("span",{class:f(a(ie)),onClick:H},[i(a(w),null,{default:b(()=>[i(a(Ae))]),_:1})],2)],64)),N(" ACTIONS "),v("div",{class:f([a(l).e("btn"),a(l).e("actions")])},[v("div",{class:f(a(l).e("actions__inner"))},[i(a(w),{onClick:s[1]||(s[1]=o=>x("zoomOut"))},{default:b(()=>[i(a(Ee))]),_:1}),i(a(w),{onClick:s[2]||(s[2]=o=>x("zoomIn"))},{default:b(()=>[i(a(Le))]),_:1}),v("i",{class:f(a(l).e("actions__divider"))},null,2),i(a(w),{onClick:P},{default:b(()=>[(h(),q(Re(a(A).icon)))]),_:1}),v("i",{class:f(a(l).e("actions__divider"))},null,2),i(a(w),{onClick:s[3]||(s[3]=o=>x("anticlockwise"))},{default:b(()=>[i(a(Xe))]),_:1}),i(a(w),{onClick:s[4]||(s[4]=o=>x("clockwise"))},{default:b(()=>[i(a(Ye))]),_:1})],2)],2),N(" CANVAS "),v("div",{class:f(a(l).e("canvas"))},[(h(!0),F(K,null,Fe(e.urlList,(o,u)=>Se((h(),F("img",{ref_for:!0,ref:c=>S.value[u]=c,key:o,src:o,style:J(a(ce)),class:f(a(l).e("img")),onLoad:re,onError:de,onMousedown:fe},null,46,ee)),[[Be,u===k.value]])),128))],2),$e(e.$slots,"default")],6)]),_:3})],8,["disabled"]))}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/image-viewer/src/image-viewer.vue"]]))});export{U as E,Ge as __tla,O as t};
|