Skip to content

Commit 9afc309

Browse files
committed
feat: enhance form and grid components with improved metadata handling and className utility
1 parent 9b5bf85 commit 9afc309

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/components/src/renderers/form/form.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ ComponentRegistry.register('form',
278278
{/* Render the actual field component based on type */}
279279
{renderFieldComponent(type, {
280280
...fieldProps,
281+
// specialized fields needs raw metadata, but we should traverse down if it exists
282+
// field is the field configuration loop variable
283+
field: (field as any).field || field,
281284
...formField,
282285
inputType: fieldProps.inputType,
283286
options: fieldProps.options,

packages/fields/src/widgets/GridField.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { FieldWidgetProps } from './types';
3+
import { cn } from '@object-ui/components';
34

45
/**
56
* GridField - Sub-table/grid data display
@@ -16,15 +17,15 @@ export function GridField({ value, field, readonly, ...props }: FieldWidgetProps
1617

1718
if (readonly) {
1819
return (
19-
<div className={`text-sm ${props.className || ''}`}>
20+
<div className={cn("text-sm", props.className)}>
2021
<span className="text-gray-700">{value.length} rows</span>
2122
</div>
2223
);
2324
}
2425

2526
// Simple read-only table view
2627
return (
27-
<div className={`border border-gray-200 rounded-md overflow-hidden ${props.className || ''}`}>
28+
<div className={cn("border border-gray-200 rounded-md overflow-hidden", props.className)}>
2829
<div className="overflow-auto max-h-60">
2930
<table className="w-full text-sm">
3031
<thead className="bg-gray-50 border-b border-gray-200">

packages/layout/src/Page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import { SchemaRenderer } from '@object-ui/react';
44
import { PageSchema, SchemaNode } from '@object-ui/types';
55
import { PageHeader } from './PageHeader';
6+
import { cn } from '@object-ui/components';
67

78
// Helper to ensure children is always an array
89
const getChildren = (children?: SchemaNode[] | SchemaNode): SchemaNode[] => {
@@ -11,11 +12,15 @@ const getChildren = (children?: SchemaNode[] | SchemaNode): SchemaNode[] => {
1112
return [children];
1213
};
1314

14-
export function Page({ schema, ...props }: { schema: PageSchema } & any) {
15+
export function Page({ schema, className, style, id, ...props }: { schema: PageSchema; className?: string; style?: React.CSSProperties; id?: string } & any) {
1516
const children = getChildren(schema.children);
1617

1718
return (
18-
<div className="flex flex-col h-full space-y-4">
19+
<div
20+
id={id || schema.id}
21+
className={cn("flex flex-col h-full space-y-4", className)}
22+
style={style}
23+
>
1924
<PageHeader
2025
title={schema.title}
2126
description={schema.description}

0 commit comments

Comments
 (0)