@iqmo/browser
Version:
Browser Stlite
2 lines (1 loc) • 1.54 kB
JavaScript
import{r as l,c as h,L as f,bP as x,ao as g,bl as b,j as c,bQ as y}from"./index-0xtYjrTa.js";const m=l.createContext(null);m.displayName="ElementFullscreenContext";const w=h("div",{target:"elp1w7k0"})(({theme:e,isExpanded:t})=>({width:"100%",...t?{position:"fixed",top:0,left:0,bottom:0,right:0,background:e.colors.bgColor,zIndex:e.zIndices.fullscreenWrapper,padding:e.spacing.md,paddingTop:e.sizes.fullScreenHeaderHeight,overflow:"auto",display:"flex",alignItems:"center",justifyContent:"center"}:{}}),""),C=()=>{const{setFullScreen:e}=l.useContext(f),[t,r]=l.useState(!1),{fullHeight:n,fullWidth:i}=x(),o=l.useCallback(a=>{r(a),e(a)},[e]),u=l.useCallback(()=>{document.body.style.overflow="hidden",o(!0)},[o]),s=l.useCallback(()=>{document.body.style.overflow="unset",o(!1)},[o]),d=l.useCallback(a=>{a.keyCode===27&&t&&s()},[s,t]);return l.useEffect(()=>(document.addEventListener("keydown",d,!1),()=>{document.removeEventListener("keydown",d,!1)}),[d]),l.useMemo(()=>({expanded:t,zoomIn:u,zoomOut:s,fullHeight:n,fullWidth:i}),[t,u,s,n,i])},k=({children:e,height:t})=>{const r=g(),{expanded:n,fullHeight:i,fullWidth:o,zoomIn:u,zoomOut:s}=C(),[d,a]=b(),p=l.useMemo(()=>({width:n?o:d,height:n?i:t,expanded:n,expand:u,collapse:s}),[n,i,o,t,d,u,s]);return c.jsx(m.Provider,{value:p,children:c.jsx(w,{ref:a,isExpanded:n,"data-testid":"stFullScreenFrame",theme:r,children:e})})};function v(e){const t=r=>c.jsx(k,{children:c.jsx(e,{...r})});return t.displayName=`withFullScreenWrapper(${e.displayName||e.name})`,y(t,e)}export{m as E,v as w};