@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) • 639 B
JavaScript
"use client";
import{useContext as o,createElement as e,Fragment as r}from"react";import{PortalContext as t}from"./portal-provider.client.js";import{useDataChannel as n}from"../hook/useDataChannel.js";function a({layer:o,index:r,onClose:t}){const a=n(o.channel),{Component:l}=o;return e(l,{data:a,depth:r+1,close:t})}function l(){const n=o(t);if(!n)throw new Error("PortalHost must be used within a PortalProvider");const{stack:l,hidePortalById:i}=n;return 0===l.length?null:e(r,null,...l.map((o,r)=>e(a,{key:o.id,layer:o,index:r,onClose:()=>i(o.id)})))}a.displayName="PortalLayerRenderer",l.displayName="PortalHost";export{l as default};