Skip to content

Commit bbabda1

Browse files
Copilothuangyiirene
andcommitted
Add plugin-object to dynamic imports and register its components
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent ba1d743 commit bbabda1

File tree

7 files changed

+103
-35
lines changed

7 files changed

+103
-35
lines changed

apps/site/app/components/InteractiveDemo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const pluginsLoading = typeof window !== 'undefined'
1616
import('@object-ui/plugin-charts'),
1717
import('@object-ui/plugin-kanban'),
1818
import('@object-ui/plugin-markdown'),
19+
import('@object-ui/plugin-object'),
1920
])
2021
: Promise.resolve([]);
2122

apps/site/app/components/ObjectUIProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if (typeof window !== 'undefined') {
1111
import('@object-ui/plugin-charts');
1212
import('@object-ui/plugin-kanban');
1313
import('@object-ui/plugin-markdown');
14+
import('@object-ui/plugin-object');
1415
}
1516

1617
export function ObjectUIProvider({ children }: { children: React.ReactNode }) {

apps/site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@object-ui/plugin-charts": "workspace:*",
1919
"@object-ui/plugin-kanban": "workspace:*",
2020
"@object-ui/plugin-markdown": "workspace:*",
21+
"@object-ui/plugin-object": "workspace:*",
2122
"fumadocs-core": "^16.4.7",
2223
"fumadocs-mdx": "^14.2.6",
2324
"fumadocs-ui": "^16.4.7",

packages/plugin-object/src/index.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
};

packages/plugin-object/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default defineConfig({
2121
],
2222
build: {
2323
lib: {
24-
entry: resolve(__dirname, 'src/index.ts'),
24+
entry: resolve(__dirname, 'src/index.tsx'),
2525
name: 'ObjectUIPluginObject',
2626
formats: ['es', 'cjs'],
2727
fileName: (format) => format === 'es' ? 'index.js' : 'index.cjs',

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)