index.fcbcb027.js 1.7 KB

1
  1. import{E as $,G as d,H as L,a0 as P,d as b,U as u,a1 as B,W as j,a2 as f,M as k,a3 as D,a4 as N,a5 as U,j as r,a6 as C,a7 as R,a8 as z,X as _,N as F,O as G}from"./ResizeObserver.es.39b48a47.js";const[H,o]=$("image"),M={src:String,alt:String,fit:String,position:String,round:Boolean,width:d,height:d,radius:d,lazyLoad:Boolean,iconSize:d,showError:L,errorIcon:P("photo-fail"),iconPrefix:String,showLoading:L,loadingIcon:P("photo")};var O=b({name:H,props:M,emits:["load","error"],setup(e,{emit:g,slots:s}){const n=u(!1),i=u(!0),l=u(),{$Lazyload:t}=B().proxy,S=j(()=>{const a={width:f(e.width),height:f(e.height)};return k(e.radius)&&(a.overflow="hidden",a.borderRadius=f(e.radius)),a});D(()=>e.src,()=>{n.value=!1,i.value=!0});const v=a=>{i.value=!1,g("load",a)},h=a=>{n.value=!0,i.value=!1,g("error",a)},m=(a,c,I)=>I?I():r(F,{name:a,size:e.iconSize,class:c,classPrefix:e.iconPrefix},null),x=()=>{if(i.value&&e.showLoading)return r("div",{class:o("loading")},[m(e.loadingIcon,o("loading-icon"),s.loading)]);if(n.value&&e.showError)return r("div",{class:o("error")},[m(e.errorIcon,o("error-icon"),s.error)])},E=()=>{if(n.value||!e.src)return;const a={alt:e.alt,class:o("img"),style:{objectFit:e.fit,objectPosition:e.position}};return e.lazyLoad?C(r("img",z({ref:l},a),null),[[R("lazy"),e.src]]):r("img",z({src:e.src,onLoad:v,onError:h},a),null)},w=({el:a})=>{const c=()=>{a===l.value&&i.value&&v()};l.value?c():_(c)},y=({el:a})=>{a===l.value&&!n.value&&h()};return t&&N&&(t.$on("loaded",w),t.$on("error",y),U(()=>{t.$off("loaded",w),t.$off("error",y)})),()=>{var a;return r("div",{class:o({round:e.round}),style:S.value},[E(),x(),(a=s.default)==null?void 0:a.call(s)])}}});const V=G(O);export{V as I};