index-legacy-5b2bc3d5.js 2.0 KB

1
  1. System.register(["./index-legacy-8f644dad.js"],(function(o,e){"use strict";var r,a,l,i,n,t,s,c,d,u,v,g,f,h,y,m,p,w,b,z,S;return{setters:[o=>{r=o.x,a=o.d,l=o.H,i=o.aA,n=o.c,t=o.y,s=o.ai,c=o.j,d=o.a0,u=o.a2,v=o.o,g=o.K,f=o.a,h=o.z,y=o.E,m=o.C,p=o.av,w=o.bd,b=o.G,z=o.V,S=o.w}],execute:function(){const[e,x]=r("image"),L={src:String,alt:String,fit:String,position:String,round:Boolean,block:Boolean,width:h,height:h,radius:h,lazyLoad:Boolean,iconSize:h,showError:y,errorIcon:m("photo-fail"),iconPrefix:String,showLoading:y,loadingIcon:m("photo")};var j=a({name:e,props:L,emits:["load","error"],setup(o,{emit:e,slots:r}){const a=l(!1),h=l(!0),y=l(),{$Lazyload:m}=i().proxy,S=n((()=>{const e={width:t(o.width),height:t(o.height)};return s(o.radius)&&(e.overflow="hidden",e.borderRadius=t(o.radius)),e}));c((()=>o.src),(()=>{a.value=!1,h.value=!0}));const L=o=>{h.value&&(h.value=!1,e("load",o))},j=()=>{const o=new Event("load");Object.defineProperty(o,"target",{value:y.value,enumerable:!0}),L(o)},E=o=>{a.value=!0,h.value=!1,e("error",o)},I=(e,r,a)=>a?a():f(z,{name:e,size:o.iconSize,"class":r,classPrefix:o.iconPrefix},null),P=()=>{if(a.value||!o.src)return;const e={alt:o.alt,"class":x("img"),style:{objectFit:o.fit,objectPosition:o.position}};return o.lazyLoad?p(f("img",b({ref:y},e),null),[[w("lazy"),o.src]]):f("img",b({ref:y,src:o.src,onLoad:L,onError:E},e),null)},$=({el:o})=>{const e=()=>{o===y.value&&h.value&&j()};y.value?e():g(e)},k=({el:o})=>{o!==y.value||a.value||E()};return m&&d&&(m.$on("loaded",$),m.$on("error",k),u((()=>{m.$off("loaded",$),m.$off("error",k)}))),v((()=>{g((()=>{var e;(null==(e=y.value)?void 0:e.complete)&&!o.lazyLoad&&j()}))})),()=>{var e;return f("div",{"class":x({round:o.round,block:o.block}),style:S.value},[P(),h.value&&o.showLoading?f("div",{"class":x("loading")},[I(o.loadingIcon,x("loading-icon"),r.loading)]):a.value&&o.showError?f("div",{"class":x("error")},[I(o.errorIcon,x("error-icon"),r.error)]):void 0,null==(e=r["default"])?void 0:e.call(r)])}}});o("I",S(j))}}}));