diff --git a/packages/runtime/src/App.tsx b/packages/runtime/src/App.tsx index dd9a72bc..cb467017 100644 --- a/packages/runtime/src/App.tsx +++ b/packages/runtime/src/App.tsx @@ -57,20 +57,24 @@ const ImplWrapper: React.FC<{ // traits const traitsProps = {}; + const wrappers: React.FC[] = []; for (const t of c.traits) { const tImpl = registry.getTrait( t.parsedType.version, t.parsedType.name ).impl; - const tProps = tImpl({ + const { props: tProps, component: Wrapper } = tImpl({ ...t.properties, mergeState, subscribeMethods, }); merge(traitsProps, tProps); + if (Wrapper) { + wrappers.push(Wrapper); + } } - return ( + let C = ( ); + + while (wrappers.length) { + const W = wrappers.pop()!; + C = {C}; + } + + return C; }; const DebugStore: React.FC = () => { diff --git a/packages/runtime/src/registry.tsx b/packages/runtime/src/registry.tsx index 47435ed7..dc90d561 100644 --- a/packages/runtime/src/registry.tsx +++ b/packages/runtime/src/registry.tsx @@ -11,6 +11,7 @@ import ChakraUITabs from "./components/chakra-ui/Tabs"; import CoreState from "./traits/core/state"; import CoreEvent from "./traits/core/event"; import CoreSlot from "./traits/core/slot"; +import CoreHidden from "./traits/core/hidden"; type ImplementedRuntimeComponent = RuntimeComponent & { impl: ComponentImplementation; @@ -40,7 +41,10 @@ export type TraitImplementation = ( mergeState: MergeState; subscribeMethods: SubscribeMethods; } -) => any; +) => { + props: any; + component?: React.FC; +}; class Registry { components: Map> = new Map(); @@ -97,3 +101,4 @@ registry.registerComponent(ChakraUITabs); registry.registerTrait(CoreState); registry.registerTrait(CoreEvent); registry.registerTrait(CoreSlot); +registry.registerTrait(CoreHidden);