11'use client' ;
22
3- import React , { useState , useEffect } from 'react' ;
3+ import React from 'react' ;
44import { SchemaRenderer } from '@object-ui/react' ;
55import type { SchemaNode } from '@object-ui/core' ;
66import { Tabs , Tab } from 'fumadocs-ui/components/tabs' ;
@@ -9,26 +9,6 @@ import { CodeBlock, Pre } from 'fumadocs-ui/components/codeblock';
99// Re-export SchemaNode type for use in MDX files
1010export type { SchemaNode } from '@object-ui/core' ;
1111
12- // Load plugins promise that we can await
13- const pluginsLoading = typeof window !== 'undefined'
14- ? Promise . all ( [
15- import ( '@object-ui/plugin-aggrid' ) ,
16- import ( '@object-ui/plugin-editor' ) ,
17- import ( '@object-ui/plugin-charts' ) ,
18- import ( '@object-ui/plugin-dashboard' ) ,
19- import ( '@object-ui/plugin-kanban' ) ,
20- import ( '@object-ui/plugin-markdown' ) ,
21- import ( '@object-ui/plugin-timeline' ) ,
22- import ( '@object-ui/plugin-calendar' ) ,
23- import ( '@object-ui/plugin-gantt' ) ,
24- import ( '@object-ui/plugin-map' ) ,
25- import ( '@object-ui/plugin-chatbot' ) ,
26- import ( '@object-ui/plugin-form' ) ,
27- import ( '@object-ui/plugin-grid' ) ,
28- import ( '@object-ui/plugin-view' ) ,
29- ] )
30- : Promise . resolve ( [ ] ) ;
31-
3212interface InteractiveDemoProps {
3313 schema : SchemaNode ;
3414 title ?: string ;
@@ -49,14 +29,6 @@ export function InteractiveDemo({
4929 description,
5030 examples
5131} : InteractiveDemoProps ) {
52- const [ pluginsLoaded , setPluginsLoaded ] = useState ( false ) ;
53-
54- useEffect ( ( ) => {
55- // Wait for plugins to load before rendering
56- pluginsLoading . then ( ( ) => {
57- setPluginsLoaded ( true ) ;
58- } ) ;
59- } , [ ] ) ;
6032
6133 // If examples are provided, show a multi-example view
6234 if ( examples && examples . length > 0 ) {
@@ -70,27 +42,23 @@ export function InteractiveDemo({
7042 ) }
7143 < Tabs items = { [ 'Preview' , 'Code' ] } defaultIndex = { 0 } >
7244 < Tab value = "Preview" >
73- { ! pluginsLoaded ? (
74- < div className = "p-6 text-center text-muted-foreground" > Loading plugins...</ div >
75- ) : (
76- < div className = "space-y-6" >
77- { examples . map ( ( example , index ) => (
78- < div key = { index } className = "border rounded-lg overflow-hidden" >
79- { example . label && (
80- < div className = "border-b bg-muted px-4 py-2" >
81- < p className = "text-sm font-medium" > { example . label } </ p >
82- { example . description && (
83- < p className = "text-xs text-muted-foreground mt-0.5" > { example . description } </ p >
84- ) }
85- </ div >
86- ) }
87- < div className = "p-6 bg-background" >
88- < SchemaRenderer schema = { example . schema } />
45+ < div className = "space-y-6" >
46+ { examples . map ( ( example , index ) => (
47+ < div key = { index } className = "border rounded-lg overflow-hidden" >
48+ { example . label && (
49+ < div className = "border-b bg-muted px-4 py-2" >
50+ < p className = "text-sm font-medium" > { example . label } </ p >
51+ { example . description && (
52+ < p className = "text-xs text-muted-foreground mt-0.5" > { example . description } </ p >
53+ ) }
8954 </ div >
55+ ) }
56+ < div className = "p-6 bg-background" >
57+ < SchemaRenderer schema = { example . schema } />
9058 </ div >
91- ) ) }
92- </ div >
93- ) }
59+ </ div >
60+ ) ) }
61+ </ div >
9462 </ Tab >
9563 < Tab value = "Code" >
9664 < div className = "space-y-4" >
@@ -125,11 +93,7 @@ export function InteractiveDemo({
12593 < Tabs items = { [ 'Preview' , 'Code' ] } defaultIndex = { 0 } >
12694 < Tab value = "Preview" >
12795 < div className = "border rounded-lg p-6 bg-background" >
128- { ! pluginsLoaded ? (
129- < div className = "text-center text-muted-foreground" > Loading plugins...</ div >
130- ) : (
131- < SchemaRenderer schema = { schema } />
132- ) }
96+ < SchemaRenderer schema = { schema } />
13397 </ div >
13498 </ Tab >
13599 < Tab value = "Code" >
0 commit comments