1 |
- import{b3 as te,b4 as A,bb as se,bN as ne,d as B,bl as oe,b5 as ie,bL as re,ce,r as c,Y as u,bO as f,ar as ue,q as ve,o as i,c as v,aN as S,g as T,t as de,a,T as g,F as $,af as pe,a0 as m,x as fe,w as me,ay as ye,b6 as ge,aj as be,cf as we,bQ as he,cg as _e,cb as M,ch as ke,ci as xe,b7 as Se,__tla as ze}from"./index-893d5d13.js";import{E as Ee,__tla as Ne}from"./el-image-viewer-36cc952f.js";let P,Le=Promise.all([(()=>{try{return ze}catch{}})(),(()=>{try{return Ne}catch{}})()]).then(async()=>{const Y=te({hideOnClickModal:Boolean,src:{type:String,default:""},fit:{type:String,values:["","contain","cover","fill","none","scale-down"],default:""},loading:{type:String,values:["eager","lazy"]},lazy:Boolean,scrollContainer:{type:A([String,Object])},previewSrcList:{type:A(Array),default:()=>se([])},previewTeleported:Boolean,zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7}}),j={load:n=>n instanceof Event,error:n=>n instanceof Event,switch:n=>ne(n),close:()=>!0,show:()=>!0},R=["src","loading"],q={key:0},F=B({name:"ElImage",inheritAttrs:!1});P=Se(ge(B({...F,props:Y,emits:j,setup(n,{emit:d}){const l=n;let z="";const{t:D}=oe(),o=ie("image"),H=re(),K=ce(),b=c(),p=c(!1),r=c(!0),w=c(!1),y=c(),s=c(),Q=f&&"loading"in HTMLImageElement.prototype;let h,_;const G=u(()=>[o.e("inner"),k.value&&o.e("preview"),r.value&&o.is("loading")]),J=u(()=>H.style),U=u(()=>{const{fit:e}=l;return f&&e?{objectFit:e}:{}}),k=u(()=>{const{previewSrcList:e}=l;return Array.isArray(e)&&e.length>0}),V=u(()=>{const{previewSrcList:e,initialIndex:t}=l;let O=t;return t>e.length-1&&(O=0),O}),E=u(()=>l.loading!=="eager"&&(!Q&&l.loading==="lazy"||l.lazy)),x=()=>{f&&(r.value=!0,p.value=!1,b.value=l.src)};function W(e){r.value=!1,p.value=!1,d("load",e)}function X(e){r.value=!1,p.value=!0,d("error",e)}function N(){ke(y.value,s.value)&&(x(),I())}const L=xe(N,200,!0);async function C(){var e;if(!f)return;await be();const{scrollContainer:t}=l;we(t)?s.value=t:he(t)&&t!==""?s.value=(e=document.querySelector(t))!=null?e:void 0:y.value&&(s.value=_e(y.value)),s.value&&(h=M(s,"scroll",L),setTimeout(()=>N(),100))}function I(){f&&s.value&&L&&(h==null||h(),s.value=void 0)}function Z(e){if(e.ctrlKey)return e.deltaY<0||e.deltaY>0?(e.preventDefault(),!1):void 0}function ee(){k.value&&(_=M("wheel",Z,{passive:!1}),z=document.body.style.overflow,document.body.style.overflow="hidden",w.value=!0,d("show"))}function ae(){_==null||_(),document.body.style.overflow=z,w.value=!1,d("close")}function le(e){d("switch",e)}return ue(()=>l.src,()=>{E.value?(r.value=!0,p.value=!1,I(),C()):x()}),ve(()=>{E.value?C():x()}),(e,t)=>(i(),v("div",{ref_key:"container",ref:y,class:g([a(o).b(),e.$attrs.class]),style:ye(a(J))},[p.value?S(e.$slots,"error",{key:0},()=>[T("div",{class:g(a(o).e("error"))},de(a(D)("el.image.error")),3)]):(i(),v($,{key:1},[b.value!==void 0?(i(),v("img",pe({key:0},a(K),{src:b.value,loading:e.loading,style:a(U),class:a(G),onClick:ee,onLoad:W,onError:X}),null,16,R)):m("v-if",!0),r.value?(i(),v("div",{key:1,class:g(a(o).e("wrapper"))},[S(e.$slots,"placeholder",{},()=>[T("div",{class:g(a(o).e("placeholder"))},null,2)])],2)):m("v-if",!0)],64)),a(k)?(i(),v($,{key:2},[w.value?(i(),fe(a(Ee),{key:0,"z-index":e.zIndex,"initial-index":a(V),infinite:e.infinite,"zoom-rate":e.zoomRate,"min-scale":e.minScale,"max-scale":e.maxScale,"url-list":e.previewSrcList,"hide-on-click-modal":e.hideOnClickModal,teleported:e.previewTeleported,"close-on-press-escape":e.closeOnPressEscape,onClose:ae,onSwitch:le},{default:me(()=>[e.$slots.viewer?(i(),v("div",q,[S(e.$slots,"viewer")])):m("v-if",!0)]),_:3},8,["z-index","initial-index","infinite","zoom-rate","min-scale","max-scale","url-list","hide-on-click-modal","teleported","close-on-press-escape"])):m("v-if",!0)],64)):m("v-if",!0)],6))}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/image/src/image.vue"]]))});export{P as E,Le as __tla};
|