Skip to content

Commit 11e6f36

Browse files
authored
Merge pull request #237 from objectstack-ai/copilot/fix-plugin-loading-issue
2 parents 4d518ee + 1ce0071 commit 11e6f36

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

content/docs/plugins/plugin-grid.mdx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ npm install @object-ui/plugin-grid
1717

1818
## Interactive Examples
1919

20-
<InteractiveDemo
20+
{/* Temporarily disabled due to data-table component bug */}
21+
{/* <InteractiveDemo
2122
schema={{
22-
type: "grid",
23+
type: "object-grid",
2324
columns: [
2425
{ header: "ID", accessorKey: "id", width: 80 },
2526
{ header: "Name", accessorKey: "name" },
@@ -33,12 +34,16 @@ npm install @object-ui/plugin-grid
3334
{ id: 3, name: "Bob Johnson", email: "bob@example.com", role: "User", status: "Inactive" }
3435
],
3536
sortable: true,
36-
filterable: true,
37-
pagination: true
37+
filterable: false,
38+
pagination: false
3839
}}
3940
title="Basic Data Grid"
4041
description="Grid with sorting, filtering, and pagination"
41-
/>
42+
/> */}
43+
44+
:::note
45+
Interactive demo temporarily disabled due to a known issue with the data-table component. See the code examples below for usage.
46+
:::
4247

4348
## Features
4449

packages/plugin-form/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ const ObjectFormRenderer: React.FC<{ schema: any }> = ({ schema }) => {
1919
};
2020

2121
ComponentRegistry.register('object-form', ObjectFormRenderer);
22-
ComponentRegistry.register('form', ObjectFormRenderer); // Alias
22+
// Note: 'form' type is handled by @object-ui/components Form component
23+
// This plugin only handles 'object-form' which integrates with ObjectQL/ObjectStack

packages/plugin-grid/src/ObjectGrid.tsx

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ export interface ObjectGridProps {
5353
function getDataConfig(schema: ObjectGridSchema): ViewData | null {
5454
// New format: explicit data configuration
5555
if (schema.data) {
56+
// Check if data is an array (shorthand format) or already a ViewData object
57+
if (Array.isArray(schema.data)) {
58+
// Convert array shorthand to proper ViewData format
59+
return {
60+
provider: 'value',
61+
items: schema.data,
62+
};
63+
}
64+
// Already in ViewData format
5665
return schema.data;
5766
}
5867

@@ -154,17 +163,28 @@ export const ObjectGrid: React.FC<ObjectGridProps> = ({
154163
const cols = normalizeColumns(schema.columns);
155164

156165
if (cols) {
157-
// If columns are already ListColumn objects, convert them to data-table format
166+
// Check if columns are already in data-table format (have 'accessorKey')
167+
// vs ListColumn format (have 'field')
158168
if (cols.length > 0 && typeof cols[0] === 'object' && cols[0] !== null) {
159-
return (cols as ListColumn[])
160-
.filter((col) => col?.field && typeof col.field === 'string') // Filter out invalid column objects
161-
.map((col) => ({
162-
header: col.label || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' '),
163-
accessorKey: col.field,
164-
...(col.width && { width: col.width }),
165-
...(col.align && { align: col.align }),
166-
sortable: col.sortable !== false,
167-
}));
169+
const firstCol = cols[0] as any;
170+
171+
// Already in data-table format - use as-is
172+
if ('accessorKey' in firstCol) {
173+
return cols;
174+
}
175+
176+
// ListColumn format - convert to data-table format
177+
if ('field' in firstCol) {
178+
return (cols as ListColumn[])
179+
.filter((col) => col?.field && typeof col.field === 'string') // Filter out invalid column objects
180+
.map((col) => ({
181+
header: col.label || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' '),
182+
accessorKey: col.field,
183+
...(col.width && { width: col.width }),
184+
...(col.align && { align: col.align }),
185+
sortable: col.sortable !== false,
186+
}));
187+
}
168188
}
169189

170190
// String array format - filter out invalid entries

packages/plugin-grid/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ const ObjectGridRenderer: React.FC<{ schema: any }> = ({ schema }) => {
1919
};
2020

2121
ComponentRegistry.register('object-grid', ObjectGridRenderer);
22-
ComponentRegistry.register('grid', ObjectGridRenderer); // Alias
22+
// Note: 'grid' type is handled by @object-ui/components Grid layout component
23+
// This plugin only handles 'object-grid' which integrates with ObjectQL/ObjectStack

0 commit comments

Comments
 (0)