@iqmo/browser
Version:
Browser Stlite
2 lines (1 loc) • 2.9 kB
JavaScript
import{c as p,r as i,ao as x,j as s,b8 as y,bb as w,bp as o,b7 as S,bq as T,br as v}from"./index-0xtYjrTa.js";const z=p("button",{target:"elibz2u2"})(({theme:e})=>({fontSize:e.fontSizes.sm,lineHeight:e.lineHeights.base,color:e.colors.fadedText60,backgroundColor:e.colors.transparent,fontFamily:"inherit",margin:e.spacing.none,border:"none",boxShadow:"none",padding:e.spacing.none,"&:hover, &:active, &:focus":{border:"none",outline:"none",boxShadow:"none"},"&:hover":{color:e.colors.primary}}),""),R=p("div",{target:"elibz2u1"})(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing.lg,"> span":{marginTop:e.spacing.twoXS}}),""),j=p("div",{target:"elibz2u0"})(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing.sm,alignItems:"start",justifyContent:"center",overflow:"hidden",minHeight:"100%",fontSize:e.fontSizes.sm,lineHeight:e.lineHeights.base,div:{display:"inline-flex"}}),"");function C(e){const t=S(e);return{Body:{props:{"data-testid":"stToast",className:"stToast"},style:{display:"flex",flexDirection:"row",gap:e.spacing.md,width:e.sizes.toastWidth,marginTop:e.spacing.sm,borderTopLeftRadius:e.radii.default,borderTopRightRadius:e.radii.default,borderBottomLeftRadius:e.radii.default,borderBottomRightRadius:e.radii.default,paddingTop:e.spacing.lg,paddingBottom:e.spacing.lg,paddingLeft:e.spacing.twoXL,paddingRight:e.spacing.twoXL,backgroundColor:t?e.colors.gray10:e.colors.gray90,color:e.colors.bodyText,boxShadow:t?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},CloseIcon:{style:{color:e.colors.fadedText40,width:e.fontSizes.lg,height:e.fontSizes.lg,marginRight:`calc(-1 * ${e.spacing.lg} / 2)`,":hover":{color:e.colors.bodyText}}}}}function L(e){if(e.length>104){let t=e.replace(/^(.{104}[^\s]*).*/,"$1");return t.length>104&&(t=t.substring(0,104).split(" ").slice(0,-1).join(" ")),t.trim()}return e}function k({body:e,icon:t}){const n=x(),r=L(e),d=e!==r,[a,b]=i.useState(!d),[u,h]=i.useState(0),f=i.useCallback(()=>{b(!a)},[a]),l=i.useMemo(()=>C(n),[n]),c=i.useMemo(()=>s.jsxs(R,{expanded:a,children:[t&&s.jsx(y,{iconValue:t,size:"xl",testid:"stToastDynamicIcon"}),s.jsxs(j,{children:[s.jsx(w,{source:a?e:r,allowHTML:!1,isToast:!0}),d&&s.jsx(z,{"data-testid":"stToastViewButton",onClick:f,children:a?"view less":"view more"})]})]}),[d,a,e,t,r,f]);i.useEffect(()=>{if(n.inSidebar)return;const g=o.info(c,{overrides:{...l}});return h(g),()=>{o.update(g,{overrides:{Body:{style:{display:"none"}}}}),o.clear(g)}},[]),i.useEffect(()=>{o.update(u,{children:c,overrides:{...l}})},[u,c,l]);const m=s.jsx(T,{kind:v.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`.\n See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information."});return s.jsx(s.Fragment,{children:n.inSidebar&&m})}const B=i.memo(k);export{B as default};