|
| 1 | +/** |
| 2 | + * ObjectUI |
| 3 | + * Copyright (c) 2024-present ObjectStack Inc. |
| 4 | + * |
| 5 | + * This source code is licensed under the MIT license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * @object-ui/plugin-object |
| 11 | + * |
| 12 | + * ObjectQL plugin for Object UI. |
| 13 | + * Provides seamless integration with ObjectQL backends through smart components |
| 14 | + * that automatically generate UI from ObjectQL object schemas. |
| 15 | + * |
| 16 | + * @packageDocumentation |
| 17 | + */ |
| 18 | + |
| 19 | +import React from 'react'; |
| 20 | +import { ComponentRegistry } from '@object-ui/core'; |
| 21 | + |
| 22 | +export { ObjectTable } from './ObjectTable'; |
| 23 | +export type { ObjectTableProps } from './ObjectTable'; |
| 24 | + |
| 25 | +export { ObjectForm } from './ObjectForm'; |
| 26 | +export type { ObjectFormProps } from './ObjectForm'; |
| 27 | + |
| 28 | +export { ObjectView } from './ObjectView'; |
| 29 | +export type { ObjectViewProps } from './ObjectView'; |
| 30 | + |
| 31 | +// Re-export related types from @object-ui/types |
| 32 | +export type { |
| 33 | + ObjectTableSchema, |
| 34 | + ObjectFormSchema, |
| 35 | + ObjectViewSchema, |
| 36 | + ObjectQLComponentSchema, |
| 37 | +} from '@object-ui/types'; |
| 38 | + |
| 39 | +// Import components for registration |
| 40 | +import { ObjectTable } from './ObjectTable'; |
| 41 | +import { ObjectForm } from './ObjectForm'; |
| 42 | +import { ObjectView } from './ObjectView'; |
| 43 | + |
| 44 | +// Create renderer wrappers for ComponentRegistry |
| 45 | +const ObjectTableRenderer: React.FC<{ schema: any }> = ({ schema }) => { |
| 46 | + // For now, render without dataSource since it requires ObjectQL setup |
| 47 | + // This allows the component to at least render in documentation |
| 48 | + return <ObjectTable schema={schema} dataSource={null as any} />; |
| 49 | +}; |
| 50 | + |
| 51 | +const ObjectFormRenderer: React.FC<{ schema: any }> = ({ schema }) => { |
| 52 | + return <ObjectForm schema={schema} dataSource={null as any} />; |
| 53 | +}; |
| 54 | + |
| 55 | +const ObjectViewRenderer: React.FC<{ schema: any }> = ({ schema }) => { |
| 56 | + return <ObjectView schema={schema} dataSource={null as any} />; |
| 57 | +}; |
| 58 | + |
| 59 | +// Register components with ComponentRegistry |
| 60 | +ComponentRegistry.register('object-table', ObjectTableRenderer, { |
| 61 | + label: 'Object Table', |
| 62 | + category: 'plugin', |
| 63 | + inputs: [ |
| 64 | + { name: 'objectName', type: 'string', label: 'Object Name', required: true }, |
| 65 | + { name: 'columns', type: 'array', label: 'Columns' }, |
| 66 | + { name: 'searchable', type: 'boolean', label: 'Searchable', defaultValue: true }, |
| 67 | + { name: 'selectable', type: 'boolean', label: 'Selectable', defaultValue: false }, |
| 68 | + ], |
| 69 | +}); |
| 70 | + |
| 71 | +ComponentRegistry.register('object-form', ObjectFormRenderer, { |
| 72 | + label: 'Object Form', |
| 73 | + category: 'plugin', |
| 74 | + inputs: [ |
| 75 | + { name: 'objectName', type: 'string', label: 'Object Name', required: true }, |
| 76 | + { name: 'fields', type: 'array', label: 'Fields' }, |
| 77 | + { name: 'mode', type: 'enum', label: 'Mode', enum: ['create', 'edit'], defaultValue: 'create' }, |
| 78 | + ], |
| 79 | +}); |
| 80 | + |
| 81 | +ComponentRegistry.register('object-view', ObjectViewRenderer, { |
| 82 | + label: 'Object View', |
| 83 | + category: 'plugin', |
| 84 | + inputs: [ |
| 85 | + { name: 'objectName', type: 'string', label: 'Object Name', required: true }, |
| 86 | + { name: 'fields', type: 'array', label: 'Fields' }, |
| 87 | + { name: 'layout', type: 'enum', label: 'Layout', enum: ['vertical', 'horizontal'], defaultValue: 'vertical' }, |
| 88 | + ], |
| 89 | +}); |
| 90 | + |
| 91 | +// Export for manual use |
| 92 | +export const objectComponents = { |
| 93 | + 'object-table': ObjectTableRenderer, |
| 94 | + 'object-form': ObjectFormRenderer, |
| 95 | + 'object-view': ObjectViewRenderer, |
| 96 | +}; |
0 commit comments