@@ -53,6 +53,15 @@ export interface ObjectGridProps {
5353function 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
0 commit comments