@stlite/browser
Version:
Browser Stlite
2 lines (1 loc) • 1.86 kB
JavaScript
import{c,r as I,bz as j,b5 as C,j as i,b4 as E,l as v}from"./index-B3URMCDH.js";import{w as L,E as T}from"./withFullScreenWrapper-BjTH4Fdh.js";import{S as p,T as W}from"./Toolbar-CHE7Bjyi.js";const y=c("div",{target:"e115fcil2"})(({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:"fit-content"}),""),F=c("div",{target:"e115fcil1"})(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0,">img":{borderRadius:e.radii.default}}),""),M=c("div",{target:"e115fcil0"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS}),""),S=v.getLogger("ImageList");function D({element:e,endpoints:g,disableFullscreenMode:h}){const x=j(e.imgs),{expanded:o,width:f,height:n,expand:u,collapse:w}=C(T),m=f||0;let s;const r=e.width;if([-1,-3,-4].includes(r))s=void 0;else if([-2,-5].includes(r))s=m;else if(r>0)s=r;else throw Error(`Invalid image width: ${r}`);const t={};n&&o?(t.maxHeight=n,t.objectFit="contain",t.width="100%"):(t.width=s??"100%",t.maxWidth="100%");const b=d=>{const a=d.currentTarget.src;S.error(`Client Error: Image source error - ${a}`),g.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",a)};return i.jsxs(p,{width:m,height:n,useContainerWidth:o,topCentered:!0,children:[i.jsx(W,{target:p,isFullScreen:o,onExpand:u,onCollapse:w,disableFullscreenMode:h}),i.jsx(y,{className:"stImage","data-testid":"stImage",children:x.map((d,a)=>{const l=d;return i.jsxs(F,{"data-testid":"stImageContainer",children:[i.jsx("img",{style:t,src:g.buildMediaURL(l.url),alt:a.toString(),onError:b}),l.caption&&i.jsx(M,{"data-testid":"stImageCaption",style:t,children:i.jsx(E,{source:l.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]},a)})})]})}const G=L(D),H=I.memo(G);export{H as default};