1 |
- import{aB as te,aC as N,aL as se,bq as ne,d as O,aY as oe,aD as ie,bn as re,b$ as ce,r as c,K as u,br as f,L as ue,l as ve,o as i,c as v,aE as x,g as T,t as de,a,Z as g,F as A,aj as pe,P as m,v as fe,w as me,au as ye,aF as ge,an as we,c0 as he,bt as be,c1 as _e,bY as F,c2 as ke,c3 as Se,aG as xe,__tla as ze}from"./index-e3afde76.js";import{E as Ee,__tla as Ce}from"./el-image-viewer-9d1c7d33.js";let P,Le=Promise.all([(()=>{try{return ze}catch{}})(),(()=>{try{return Ce}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:N([String,Object])},previewSrcList:{type:N(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},q=["src","loading"],D={key:0},M=O({name:"ElImage",inheritAttrs:!1});P=xe(ge(O({...M,props:Y,emits:j,setup(n,{emit:d}){const l=n;let z="";const{t:K}=oe(),o=ie("image"),R=re(),G=ce(),w=c(),p=c(!1),r=c(!0),h=c(!1),y=c(),s=c(),H=f&&"loading"in HTMLImageElement.prototype;let b,_;const Z=u(()=>[o.e("inner"),k.value&&o.e("preview"),r.value&&o.is("loading")]),J=u(()=>R.style),Q=u(()=>{const{fit:e}=l;return f&&e?{objectFit:e}:{}}),k=u(()=>{const{previewSrcList:e}=l;return Array.isArray(e)&&e.length>0}),U=u(()=>{const{previewSrcList:e,initialIndex:t}=l;let $=t;return t>e.length-1&&($=0),$}),E=u(()=>l.loading!=="eager"&&(!H&&l.loading==="lazy"||l.lazy)),S=()=>{f&&(r.value=!0,p.value=!1,w.value=l.src)};function V(e){r.value=!1,p.value=!1,d("load",e)}function W(e){r.value=!1,p.value=!0,d("error",e)}function C(){ke(y.value,s.value)&&(S(),I())}const L=Se(C,200,!0);async function B(){var e;if(!f)return;await we();const{scrollContainer:t}=l;he(t)?s.value=t:be(t)&&t!==""?s.value=(e=document.querySelector(t))!=null?e:void 0:y.value&&(s.value=_e(y.value)),s.value&&(b=F(s,"scroll",L),setTimeout(()=>C(),100))}function I(){f&&s.value&&L&&(b==null||b(),s.value=void 0)}function X(e){if(e.ctrlKey)return e.deltaY<0||e.deltaY>0?(e.preventDefault(),!1):void 0}function ee(){k.value&&(_=F("wheel",X,{passive:!1}),z=document.body.style.overflow,document.body.style.overflow="hidden",h.value=!0,d("show"))}function ae(){_==null||_(),document.body.style.overflow=z,h.value=!1,d("close")}function le(e){d("switch",e)}return ue(()=>l.src,()=>{E.value?(r.value=!0,p.value=!1,I(),B()):S()}),ve(()=>{E.value?B():S()}),(e,t)=>(i(),v("div",{ref_key:"container",ref:y,class:g([a(o).b(),e.$attrs.class]),style:ye(a(J))},[p.value?x(e.$slots,"error",{key:0},()=>[T("div",{class:g(a(o).e("error"))},de(a(K)("el.image.error")),3)]):(i(),v(A,{key:1},[w.value!==void 0?(i(),v("img",pe({key:0},a(G),{src:w.value,loading:e.loading,style:a(Q),class:a(Z),onClick:ee,onLoad:V,onError:W}),null,16,q)):m("v-if",!0),r.value?(i(),v("div",{key:1,class:g(a(o).e("wrapper"))},[x(e.$slots,"placeholder",{},()=>[T("div",{class:g(a(o).e("placeholder"))},null,2)])],2)):m("v-if",!0)],64)),a(k)?(i(),v(A,{key:2},[h.value?(i(),fe(a(Ee),{key:0,"z-index":e.zIndex,"initial-index":a(U),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",D,[x(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};
|