import { FabricContext, NodeTreeContext, provide, RootContext, useContext, useNodeTree } from '@kubb/fabric-core' import type { FabricReactElement, FabricReactNode } from '../types.ts' export type FabricProps = { /** * Metadata associated with the App. */ meta?: TMeta /** * Children nodes. */ children?: FabricReactNode } /** * Fabric container containing the FabricContext carrying `meta` and an `exit` hook. */ export function Fabric({ children, ...props }: FabricProps): FabricReactElement { const { meta = {} } = props const { exit } = useContext(RootContext) const nodeTree = useNodeTree() if (nodeTree) { const childTree = nodeTree.addChild({ type: 'App', props }) provide(NodeTreeContext, childTree) } provide(FabricContext, { exit, meta }) return <>{children} } Fabric.displayName = 'Fabric'