1 |
- import{bp as ve,aG as me,aw as be,ax as pe,bd as ge,be as Y,d as q,bq as G,br as ke,bs as we,bf as xe,ay as _e,bt as ye,r as h,bu as ze,b6 as Ie,K as w,L as V,an as he,l as Ce,o as C,v as Z,f as i,w as p,g as m,Z as f,a,au as j,b3 as Ne,P as N,aM as x,aK as Oe,c as S,F as H,bv as Te,bw as Ae,bx as Le,by as Re,M as Ee,bz as Xe,bA as Ye,q as Se,x as Be,a4 as $e,az as Fe,$ as Me,bB as De,aA as Pe,bm as L,bC as I,bD as Ke,aB as We,__tla as qe}from"./index-3f6d2b3a.js";let J,O,Ge=Promise.all([(()=>{try{return qe}catch{}})()]).then(async()=>{O=function(g,T,v){var n=!0,b=!0;if(typeof g!="function")throw new TypeError("Expected a function");return ve(v)&&(n="leading"in v?!!v.leading:n,b="trailing"in v?!!v.trailing:b),me(g,T,{leading:n,maxWait:T,trailing:b})};const U=be({urlList:{type:pe(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=q({name:"ElImageViewer"});J=We(Pe(q({...ae,props:U,emits:Q,setup(g,{expose:T,emit:v}){const n=g,b={CONTAIN:{name:"contain",icon:G(ke)},ORIGINAL:{name:"original",icon:G(we)}},{t:se}=xe(),l=_e("image-viewer"),{nextZIndex:ne}=ye(),R=h(),B=h([]),$=ze(),y=h(!0),k=h(n.initialIndex),A=Ie(b.CONTAIN),t=h({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),le=w(()=>{const{urlList:e}=n;return e.length<=1}),F=w(()=>k.value===0),M=w(()=>k.value===n.urlList.length-1),te=w(()=>n.urlList[k.value]),oe=w(()=>[l.e("btn"),l.e("prev"),l.is("disabled",!n.infinite&&F.value)]),ie=w(()=>[l.e("btn"),l.e("next"),l.is("disabled",!n.infinite&&M.value)]),ue=w(()=>{const{scale:e,deg:s,offsetX:o,offsetY:c,enableTransition:u}=t.value;let r=o/e,d=c/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 z={transform:`scale(${e}) rotate(${s}deg) translate(${r}px, ${d}px)`,transition:u?"transform .3s":""};return A.value.name===b.CONTAIN.name&&(z.maxWidth=z.maxHeight="100%"),z}),ce=w(()=>Y(n.zIndex)?n.zIndex:ne());function E(){$.stop(),v("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||!R.value)return;t.value.enableTransition=!1;const{offsetX:s,offsetY:o}=t.value,c=e.pageX,u=e.pageY,r=O(z=>{t.value={...t.value,offsetX:s+z.pageX-c,offsetY:o+z.pageY-u}}),d=L(document,"mousemove",r);L(document,"mouseup",()=>{d()}),e.preventDefault()}function D(){t.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}function P(){if(y.value)return;const e=Ke(b),s=Object.values(b),o=A.value.name,c=(s.findIndex(u=>u.name===o)+1)%e.length;A.value=b[e[c]],D()}function X(e){const s=n.urlList.length;k.value=(e+s)%s}function K(){F.value&&!n.infinite||X(k.value-1)}function W(){M.value&&!n.infinite||X(k.value+1)}function _(e,s={}){if(y.value)return;const{minScale:o,maxScale:c}=n,{zoomRate:u,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/u).toFixed(3)));break;case"zoomIn":t.value.scale<c&&(t.value.scale=Number.parseFloat((t.value.scale*u).toFixed(3)));break;case"clockwise":t.value.deg+=r,v("rotate",t.value.deg);break;case"anticlockwise":t.value.deg-=r,v("rotate",t.value.deg)}t.value.enableTransition=d}return V(te,()=>{he(()=>{const e=B.value[0];e!=null&&e.complete||(y.value=!0)})}),V(k,e=>{D(),v("switch",e)}),Ce(()=>{var e,s;(function(){const o=O(u=>{switch(u.code){case I.esc:n.closeOnPressEscape&&E();break;case I.space:P();break;case I.left:K();break;case I.up:_("zoomIn");break;case I.right:W();break;case I.down:_("zoomOut")}}),c=O(u=>{_((u.deltaY||u.deltaX)<0?"zoomIn":"zoomOut",{zoomRate:n.zoomRate,enableTransition:!1})});$.run(()=>{L(document,"keydown",o),L(document,"wheel",c)})})(),(s=(e=R.value)==null?void 0:e.focus)==null||s.call(e)}),T({setActiveItem:X}),(e,s)=>(C(),Z(De,{to:"body",disabled:!e.teleported},[i(Me,{name:"viewer-fade",appear:""},{default:p(()=>[m("div",{ref_key:"wrapper",ref:R,tabindex:-1,class:f(a(l).e("wrapper")),style:j({zIndex:a(ce)})},[m("div",{class:f(a(l).e("mask")),onClick:s[0]||(s[0]=Ne(o=>e.hideOnClickModal&&E(),["self"]))},null,2),N(" CLOSE "),m("span",{class:f([a(l).e("btn"),a(l).e("close")]),onClick:E},[i(a(x),null,{default:p(()=>[i(a(Oe))]),_:1})],2),N(" ARROW "),a(le)?N("v-if",!0):(C(),S(H,{key:0},[m("span",{class:f(a(oe)),onClick:K},[i(a(x),null,{default:p(()=>[i(a(Te))]),_:1})],2),m("span",{class:f(a(ie)),onClick:W},[i(a(x),null,{default:p(()=>[i(a(Ae))]),_:1})],2)],64)),N(" ACTIONS "),m("div",{class:f([a(l).e("btn"),a(l).e("actions")])},[m("div",{class:f(a(l).e("actions__inner"))},[i(a(x),{onClick:s[1]||(s[1]=o=>_("zoomOut"))},{default:p(()=>[i(a(Le))]),_:1}),i(a(x),{onClick:s[2]||(s[2]=o=>_("zoomIn"))},{default:p(()=>[i(a(Re))]),_:1}),m("i",{class:f(a(l).e("actions__divider"))},null,2),i(a(x),{onClick:P},{default:p(()=>[(C(),Z(Ee(a(A).icon)))]),_:1}),m("i",{class:f(a(l).e("actions__divider"))},null,2),i(a(x),{onClick:s[3]||(s[3]=o=>_("anticlockwise"))},{default:p(()=>[i(a(Xe))]),_:1}),i(a(x),{onClick:s[4]||(s[4]=o=>_("clockwise"))},{default:p(()=>[i(a(Ye))]),_:1})],2)],2),N(" CANVAS "),m("div",{class:f(a(l).e("canvas"))},[(C(!0),S(H,null,Se(e.urlList,(o,c)=>Be((C(),S("img",{ref_for:!0,ref:u=>B.value[c]=u,key:o,src:o,style:j(a(ue)),class:f(a(l).e("img")),onLoad:re,onError:de,onMousedown:fe},null,46,ee)),[[$e,c===k.value]])),128))],2),Fe(e.$slots,"default")],6)]),_:3})],8,["disabled"]))}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/image-viewer/src/image-viewer.vue"]]))});export{J as E,Ge as __tla,O as t};
|