Add description to array input fields
This commit is contained in:
@@ -132,6 +132,17 @@ const DynamicJsonForm = ({
|
|||||||
const arrayValue = Array.isArray(currentValue) ? currentValue : [];
|
const arrayValue = Array.isArray(currentValue) ? currentValue : [];
|
||||||
if (!propSchema.items) return null;
|
if (!propSchema.items) return null;
|
||||||
return (
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{propSchema.description && (
|
||||||
|
<p className="text-sm text-gray-600">{propSchema.description}</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{propSchema.items?.description && (
|
||||||
|
<p className="text-sm text-gray-500">
|
||||||
|
Items: {propSchema.items.description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{arrayValue.map((item, index) => (
|
{arrayValue.map((item, index) => (
|
||||||
<div key={index} className="flex items-center gap-2">
|
<div key={index} className="flex items-center gap-2">
|
||||||
@@ -163,10 +174,12 @@ const DynamicJsonForm = ({
|
|||||||
[...arrayValue, generateDefaultValue(propSchema.items as JsonSchemaType)]
|
[...arrayValue, generateDefaultValue(propSchema.items as JsonSchemaType)]
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
title={propSchema.items?.description ? `Add new ${propSchema.items.description}` : 'Add new item'}
|
||||||
>
|
>
|
||||||
Add Item
|
Add Item
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user