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