el-image-6a280602.js 4.0 KB

1
  1. import{av as te,aw as B,bc as se,bd as ne,d as N,be as oe,ax as ie,bf as re,bg as ce,r as c,J as u,bh as m,K as ue,k as ve,o as i,c as v,ay as S,g as T,t as de,a,Y as g,F as $,ai as pe,O as f,q as me,w as fe,at as ye,az as ge,am as we,bi as be,bj as he,bk as ke,bl as M,bm as _e,bn as xe,aA as Se,__tla as ze}from"./index-73e02845.js";import{E as Ee,__tla as Ie}from"./el-image-viewer-a6b3dac3.js";let P,Ce=Promise.all([(()=>{try{return ze}catch{}})(),(()=>{try{return Ie}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:B([String,Object])},previewSrcList:{type:B(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},K=["src","loading"],q={key:0},F=N({name:"ElImage",inheritAttrs:!1});P=Se(ge(N({...F,props:Y,emits:j,setup(n,{emit:d}){const l=n;let z="";const{t:R}=oe(),o=ie("image"),D=re(),H=ce(),w=c(),p=c(!1),r=c(!0),b=c(!1),y=c(),s=c(),J=m&&"loading"in HTMLImageElement.prototype;let h,k;const G=u(()=>[o.e("inner"),_.value&&o.e("preview"),r.value&&o.is("loading")]),Q=u(()=>D.style),U=u(()=>{const{fit:e}=l;return m&&e?{objectFit:e}:{}}),_=u(()=>{const{previewSrcList:e}=l;return Array.isArray(e)&&e.length>0}),V=u(()=>{const{previewSrcList:e,initialIndex:t}=l;let A=t;return t>e.length-1&&(A=0),A}),E=u(()=>l.loading!=="eager"&&(!J&&l.loading==="lazy"||l.lazy)),x=()=>{m&&(r.value=!0,p.value=!1,w.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 I(){_e(y.value,s.value)&&(x(),O())}const C=xe(I,200,!0);async function L(){var e;if(!m)return;await we();const{scrollContainer:t}=l;be(t)?s.value=t:he(t)&&t!==""?s.value=(e=document.querySelector(t))!=null?e:void 0:y.value&&(s.value=ke(y.value)),s.value&&(h=M(s,"scroll",C),setTimeout(()=>I(),100))}function O(){m&&s.value&&C&&(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(){_.value&&(k=M("wheel",Z,{passive:!1}),z=document.body.style.overflow,document.body.style.overflow="hidden",b.value=!0,d("show"))}function ae(){k==null||k(),document.body.style.overflow=z,b.value=!1,d("close")}function le(e){d("switch",e)}return ue(()=>l.src,()=>{E.value?(r.value=!0,p.value=!1,O(),L()):x()}),ve(()=>{E.value?L():x()}),(e,t)=>(i(),v("div",{ref_key:"container",ref:y,class:g([a(o).b(),e.$attrs.class]),style:ye(a(Q))},[p.value?S(e.$slots,"error",{key:0},()=>[T("div",{class:g(a(o).e("error"))},de(a(R)("el.image.error")),3)]):(i(),v($,{key:1},[w.value!==void 0?(i(),v("img",pe({key:0},a(H),{src:w.value,loading:e.loading,style:a(U),class:a(G),onClick:ee,onLoad:W,onError:X}),null,16,K)):f("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)):f("v-if",!0)],64)),a(_)?(i(),v($,{key:2},[b.value?(i(),me(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:fe(()=>[e.$slots.viewer?(i(),v("div",q,[S(e.$slots,"viewer")])):f("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"])):f("v-if",!0)],64)):f("v-if",!0)],6))}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/image/src/image.vue"]]))});export{P as E,Ce as __tla};