Skip to content

Commit b48f5bc

Browse files
Copilothotlong
andcommitted
Fix README examples and improve code clarity based on review feedback
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent b5b229c commit b48f5bc

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/data-object/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ const dataSource = new ObjectQLDataSource({
2929
function UsersTable() {
3030
return (
3131
<ObjectTable
32-
objectName="users"
32+
schema={{
33+
type: 'object-table',
34+
objectName: 'users'
35+
}}
3336
dataSource={dataSource}
3437
/>
3538
);
@@ -50,10 +53,13 @@ const dataSource = new ObjectQLDataSource({
5053
function UserForm() {
5154
return (
5255
<ObjectForm
53-
objectName="users"
56+
schema={{
57+
type: 'object-form',
58+
objectName: 'users',
59+
mode: 'create',
60+
onSuccess: (data) => console.log('Created:', data)
61+
}}
5462
dataSource={dataSource}
55-
mode="create"
56-
onSuccess={(data) => console.log('Created:', data)}
5763
/>
5864
);
5965
}

packages/data-object/src/ObjectForm.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,14 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
209209
}
210210

211211
// Convert to FormSchema
212+
// Note: FormSchema currently only supports 'vertical' and 'horizontal' layouts
213+
// Map 'grid' and 'inline' to 'vertical' as fallback
212214
const formSchema: FormSchema = {
213215
type: 'form',
214216
fields: formFields,
215-
layout: schema.layout === 'grid' || schema.layout === 'inline' ? 'vertical' : schema.layout || 'vertical',
217+
layout: (schema.layout === 'vertical' || schema.layout === 'horizontal')
218+
? schema.layout
219+
: 'vertical',
216220
columns: schema.columns,
217221
submitLabel: schema.submitText || (schema.mode === 'create' ? 'Create' : 'Update'),
218222
cancelLabel: schema.cancelText,

0 commit comments

Comments
 (0)