Skip to content

Commit 4b3bb5f

Browse files
committed
Add description to array input fields
1 parent a4469f7 commit 4b3bb5f

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

client/src/components/DynamicJsonForm.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,19 @@ const DynamicJsonForm = ({
132132
const arrayValue = Array.isArray(currentValue) ? currentValue : [];
133133
if (!propSchema.items) return null;
134134
return (
135-
<div className="space-y-2">
136-
{arrayValue.map((item, index) => (
135+
<div className="space-y-4">
136+
{propSchema.description && (
137+
<p className="text-sm text-gray-600">{propSchema.description}</p>
138+
)}
139+
140+
{propSchema.items?.description && (
141+
<p className="text-sm text-gray-500">
142+
Items: {propSchema.items.description}
143+
</p>
144+
)}
145+
146+
<div className="space-y-2">
147+
{arrayValue.map((item, index) => (
137148
<div key={index} className="flex items-center gap-2">
138149
{renderFormFields(
139150
propSchema.items as JsonSchemaType,
@@ -154,18 +165,20 @@ const DynamicJsonForm = ({
154165
</Button>
155166
</div>
156167
))}
157-
<Button
158-
variant="outline"
159-
size="sm"
160-
onClick={() => {
161-
handleFieldChange(
162-
path,
163-
[...arrayValue, generateDefaultValue(propSchema.items as JsonSchemaType)]
164-
);
165-
}}
166-
>
167-
Add Item
168-
</Button>
168+
<Button
169+
variant="outline"
170+
size="sm"
171+
onClick={() => {
172+
handleFieldChange(
173+
path,
174+
[...arrayValue, generateDefaultValue(propSchema.items as JsonSchemaType)]
175+
);
176+
}}
177+
title={propSchema.items?.description ? `Add new ${propSchema.items.description}` : 'Add new item'}
178+
>
179+
Add Item
180+
</Button>
181+
</div>
169182
</div>
170183
);
171184
}

0 commit comments

Comments
 (0)