|
| 1 | +/** |
| 2 | + * ObjectUI Demo Page |
| 3 | + * |
| 4 | + * Demonstrates the @object-ui integration in ObjectOS. |
| 5 | + * Shows how to use @object-ui/react components with the ObjectStack backend. |
| 6 | + * |
| 7 | + * Route: /settings/objectui-demo |
| 8 | + */ |
| 9 | + |
| 10 | +import { useState } from 'react'; |
| 11 | +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; |
| 12 | +import { Button } from '@/components/ui/button'; |
| 13 | +import { Badge } from '@/components/ui/badge'; |
| 14 | +import { ObjectUIExample } from '@/components/objectui'; |
| 15 | +import { CheckCircle2 } from 'lucide-react'; |
| 16 | + |
| 17 | +export default function ObjectUIDemoPage() { |
| 18 | + const [selectedObject, setSelectedObject] = useState('contacts'); |
| 19 | + const [selectedView, setSelectedView] = useState('grid'); |
| 20 | + |
| 21 | + const demoObjects = [ |
| 22 | + { name: 'contacts', label: 'Contacts' }, |
| 23 | + { name: 'accounts', label: 'Accounts' }, |
| 24 | + { name: 'opportunities', label: 'Opportunities' }, |
| 25 | + ]; |
| 26 | + |
| 27 | + const views = [ |
| 28 | + { name: 'grid', label: 'Grid View' }, |
| 29 | + { name: 'form', label: 'Form View' }, |
| 30 | + { name: 'kanban', label: 'Kanban View' }, |
| 31 | + ]; |
| 32 | + |
| 33 | + return ( |
| 34 | + <div className="space-y-6"> |
| 35 | + {/* Header */} |
| 36 | + <div> |
| 37 | + <h2 className="text-3xl font-bold tracking-tight">ObjectUI Integration</h2> |
| 38 | + <p className="text-muted-foreground"> |
| 39 | + Demonstration of @object-ui components integrated with ObjectStack backend. |
| 40 | + </p> |
| 41 | + </div> |
| 42 | + |
| 43 | + {/* Installation Status */} |
| 44 | + <Card> |
| 45 | + <CardHeader> |
| 46 | + <CardTitle className="flex items-center gap-2"> |
| 47 | + <CheckCircle2 className="size-5 text-green-600" /> |
| 48 | + ObjectUI Packages Installed |
| 49 | + </CardTitle> |
| 50 | + <CardDescription> |
| 51 | + The following @object-ui packages are now available in development: |
| 52 | + </CardDescription> |
| 53 | + </CardHeader> |
| 54 | + <CardContent> |
| 55 | + <div className="flex flex-wrap gap-2"> |
| 56 | + <Badge variant="secondary">@object-ui/core@2.0.0</Badge> |
| 57 | + <Badge variant="secondary">@object-ui/react@2.0.0</Badge> |
| 58 | + <Badge variant="secondary">@object-ui/components@2.0.0</Badge> |
| 59 | + <Badge variant="secondary">@object-ui/layout@2.0.0</Badge> |
| 60 | + <Badge variant="secondary">@object-ui/fields@2.0.0</Badge> |
| 61 | + <Badge variant="secondary">@object-ui/data-objectstack@2.0.0</Badge> |
| 62 | + </div> |
| 63 | + </CardContent> |
| 64 | + </Card> |
| 65 | + |
| 66 | + {/* Interactive Demo */} |
| 67 | + <Card> |
| 68 | + <CardHeader> |
| 69 | + <CardTitle>Interactive Demo</CardTitle> |
| 70 | + <CardDescription> |
| 71 | + Select an object and view mode to see the ObjectUI components in action. |
| 72 | + </CardDescription> |
| 73 | + </CardHeader> |
| 74 | + <CardContent className="space-y-4"> |
| 75 | + {/* Object Selector */} |
| 76 | + <div> |
| 77 | + <label className="text-sm font-medium mb-2 block">Select Object</label> |
| 78 | + <div className="flex gap-2"> |
| 79 | + {demoObjects.map((obj) => ( |
| 80 | + <Button |
| 81 | + key={obj.name} |
| 82 | + variant={selectedObject === obj.name ? 'default' : 'outline'} |
| 83 | + onClick={() => setSelectedObject(obj.name)} |
| 84 | + size="sm" |
| 85 | + > |
| 86 | + {obj.label} |
| 87 | + </Button> |
| 88 | + ))} |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + |
| 92 | + {/* View Selector */} |
| 93 | + <div> |
| 94 | + <label className="text-sm font-medium mb-2 block">Select View</label> |
| 95 | + <div className="flex gap-2"> |
| 96 | + {views.map((view) => ( |
| 97 | + <Button |
| 98 | + key={view.name} |
| 99 | + variant={selectedView === view.name ? 'default' : 'outline'} |
| 100 | + onClick={() => setSelectedView(view.name)} |
| 101 | + size="sm" |
| 102 | + > |
| 103 | + {view.label} |
| 104 | + </Button> |
| 105 | + ))} |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + |
| 109 | + {/* ObjectUI Renderer */} |
| 110 | + <div className="border rounded-lg p-4 bg-muted/50"> |
| 111 | + <ObjectUIExample |
| 112 | + objectName={selectedObject} |
| 113 | + view={selectedView} |
| 114 | + /> |
| 115 | + </div> |
| 116 | + </CardContent> |
| 117 | + </Card> |
| 118 | + |
| 119 | + {/* Documentation */} |
| 120 | + <Card> |
| 121 | + <CardHeader> |
| 122 | + <CardTitle>Usage Guide</CardTitle> |
| 123 | + <CardDescription> |
| 124 | + How to use @object-ui components in your application |
| 125 | + </CardDescription> |
| 126 | + </CardHeader> |
| 127 | + <CardContent className="prose prose-sm max-w-none"> |
| 128 | + <h3 className="text-base font-semibold">Basic Usage</h3> |
| 129 | + <pre className="bg-muted p-4 rounded-lg overflow-x-auto"> |
| 130 | +{`import { SchemaRenderer } from '@object-ui/react'; |
| 131 | +import { objectUIAdapter } from '@/lib/object-ui-adapter'; |
| 132 | +
|
| 133 | +function MyComponent() { |
| 134 | + return ( |
| 135 | + <SchemaRenderer |
| 136 | + adapter={objectUIAdapter} |
| 137 | + objectName="contacts" |
| 138 | + view="grid" |
| 139 | + /> |
| 140 | + ); |
| 141 | +}`} |
| 142 | + </pre> |
| 143 | + |
| 144 | + <h3 className="text-base font-semibold mt-4">Available Packages</h3> |
| 145 | + <ul className="list-disc list-inside space-y-1"> |
| 146 | + <li><code>@object-ui/core</code> - Core logic and types</li> |
| 147 | + <li><code>@object-ui/react</code> - React components and SchemaRenderer</li> |
| 148 | + <li><code>@object-ui/components</code> - Standard UI components (Shadcn-based)</li> |
| 149 | + <li><code>@object-ui/layout</code> - Application shell components</li> |
| 150 | + <li><code>@object-ui/fields</code> - Field renderers</li> |
| 151 | + <li><code>@object-ui/data-objectstack</code> - ObjectStack data adapter</li> |
| 152 | + </ul> |
| 153 | + </CardContent> |
| 154 | + </Card> |
| 155 | + </div> |
| 156 | + ); |
| 157 | +} |
0 commit comments