@meonode/ui
Version:
A structured approach to component composition, direct CSS-first prop styling, built-in theming, smart prop handling (including raw property pass-through), and dynamic children.
3 lines (2 loc) • 1.31 kB
JavaScript
"use client";
import{useState as e,createElement as t}from"react";import{CacheProvider as r}from"@emotion/react";import o from"@emotion/cache";import{Node as n}from"../core.node.js";import{useServerInsertedHTML as i}from"next/navigation.js";import{consumeServerEmotionRules as s,getServerEmotionCache as a}from"../util/server-emotion.util.js";import{consumeServerThemeVariablesCss as d}from"../util/server-theme.util.js";function m({children:m}){const[c]=e(()=>{const e="undefined"==typeof window?a():o({key:"meonode-css"});return e.compat=!0,e}),[f]=e(()=>new Set);return i(()=>{const e=Object.keys(c.inserted).filter(e=>!f.has(e)&&"string"==typeof c.inserted[e]),r=s().filter(e=>!f.has(e.id)),o=d(),n=o&&!f.has(o.id)?[o]:[];if(0===e.length&&0===r.length&&0===n.length)return null;e.forEach(e=>f.add(e)),r.forEach(e=>f.add(e.id)),n.forEach(e=>f.add(e.id));const i=Array.from(new Set([...e,...r.map(e=>e.id),...n.map(e=>e.id)])).sort(),a=new Map([...r,...n].map(e=>[e.id,e.cssText])),m=i.map(e=>{const t=a.get(e);if("string"==typeof t)return t;const r=c.inserted[e];return"string"==typeof r?r:""}).filter(Boolean).join(""),l=i.join(" ");return t("style",{"data-emotion":`${c.key} ${l}`,dangerouslySetInnerHTML:{__html:m}})}),n(r,{value:c,children:m}).render()}m.__meonodeAcceptsServerCss=!0;export{m as default};