@jengaui/root
Version:
Jenga UI Root component in React
20 lines (15 loc) • 2.12 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var react = require('react');
var overlays = require('@react-aria/overlays');
var styledComponents = require('styled-components');
var tastycss = require('tastycss');
var providers = require('@jengaui/providers');
var core = require('@jengaui/core');
var utils = require('@jengaui/utils');
var portal = require('@jengaui/portal');
var alertDialog = require('@jengaui/alert-dialog');
var notification = require('@jengaui/notification');
var jsxRuntime = require('react/jsx-runtime');
var J=tastycss.tasty({id:"Jenga UI-kit-root",className:"root"}),M={display:"block",preset:"t3",...Object.keys(core.TOKENS).reduce((r,i)=>(r[`@${i}`]=core.TOKENS[i],r),{})},O=[...tastycss.BASE_STYLES,...tastycss.BLOCK_STYLES],u=typeof CSS<"u"&&typeof(CSS==null?void 0:CSS.supports)=="function"?CSS.supports("height: 100dvh"):!1;function Z(r){let{children:i,bodyStyles:S,fonts:g,publicUrl:y,router:h,font:P,monospaceFont:v,applyLegacyTokens:T,...l}=r,o=react.useRef(null),[p,b]=react.useState(),t=utils.useViewportSize(),[n,a]=react.useState(u?void 0:t.height),s=react.useRef();react.useEffect(()=>{u&&typeof window<"u"||(s.current&&clearTimeout(s.current),t.height<(n||0)&&t.height<window.innerHeight?s.current=setTimeout(()=>{a(t.height);},500):a(t.height));},[n,t.height]),react.useEffect(()=>{p||b(o==null?void 0:o.current);},[]);let R=tastycss.extractStyles(l,O,M);return jsxRuntime.jsx(providers.Provider,{router:h,root:p,children:jsxRuntime.jsx(styledComponents.StyleSheetManager,{disableVendorPrefixes:!0,children:jsxRuntime.jsxs(J,{ref:o,...tastycss.filterBaseProps(l,{eventProps:!0}),styles:R,style:{"--jenga-dynamic-viewport-height":n?n+"px":"100dvh"},children:[jsxRuntime.jsx(core.GlobalStyles,{bodyStyles:S,applyLegacyTokens:T,publicUrl:y,fonts:g,font:P,monospaceFont:v}),jsxRuntime.jsx(overlays.ModalProvider,{children:jsxRuntime.jsx(portal.PortalProvider,{value:o,children:jsxRuntime.jsx(notification.NotificationsProvider,{rootRef:o,children:jsxRuntime.jsx(alertDialog.AlertDialogApiProvider,{children:i})})})})]})})})}
exports.Root = Z;