@iqmo/browser
Version:
Browser Stlite
2 lines (1 loc) • 1.55 kB
JavaScript
import{c as h,r as l,b6 as f,b5 as x,bN as b,z as g,bO as y,j as c,bs as w}from"./index-C9lG8Cnd.js";const C=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"}:{}}),""),m=l.createContext(null);m.displayName="ElementFullscreenContext";const k=()=>{const{setFullScreen:e}=l.useContext(f),[t,r]=l.useState(!1),{fullHeight:n,fullWidth:i}=x(b),s=l.useCallback(a=>{r(a),e(a)},[e]),u=l.useCallback(()=>{document.body.style.overflow="hidden",s(!0)},[s]),o=l.useCallback(()=>{document.body.style.overflow="unset",s(!1)},[s]),d=l.useCallback(a=>{a.keyCode===27&&t&&o()},[o,t]);return l.useEffect(()=>(document.addEventListener("keydown",d,!1),()=>{document.removeEventListener("keydown",d,!1)}),[d]),l.useMemo(()=>({expanded:t,zoomIn:u,zoomOut:o,fullHeight:n,fullWidth:i}),[t,u,o,n,i])},v=({children:e,height:t})=>{const r=g(),{expanded:n,fullHeight:i,fullWidth:s,zoomIn:u,zoomOut:o}=k(),[d,a]=y(),p=l.useMemo(()=>({width:n?s:d,height:n?i:t,expanded:n,expand:u,collapse:o}),[n,i,s,t,d,u,o]);return c.jsx(m.Provider,{value:p,children:c.jsx(C,{ref:a,isExpanded:n,"data-testid":"stFullScreenFrame",theme:r,children:e})})};function z(e){const t=r=>c.jsx(v,{children:c.jsx(e,{...r})});return t.displayName=`withFullScreenWrapper(${e.displayName||e.name})`,w(t,e)}export{m as E,z as w};