Fix formatting

This commit is contained in:
olaservo 2025-06-01 21:05:33 -07:00
commit 0a1de24fdf

View file

@ -31,7 +31,7 @@ const getArrayItemDefault = (schema: JsonSchemaType): JsonValue => {
if ("default" in schema && schema.default !== undefined) { if ("default" in schema && schema.default !== undefined) {
return schema.default; return schema.default;
} }
switch (schema.type) { switch (schema.type) {
case "string": case "string":
return ""; return "";
@ -289,13 +289,15 @@ const DynamicJsonForm = ({
case "array": { case "array": {
const arrayValue = Array.isArray(currentValue) ? currentValue : []; const arrayValue = Array.isArray(currentValue) ? currentValue : [];
if (!propSchema.items) return null; if (!propSchema.items) return null;
// If the array items are simple, render as form fields, otherwise use JSON editor // If the array items are simple, render as form fields, otherwise use JSON editor
if (isSimpleObject(propSchema.items)) { if (isSimpleObject(propSchema.items)) {
return ( return (
<div className="space-y-4"> <div className="space-y-4">
{propSchema.description && ( {propSchema.description && (
<p className="text-sm text-gray-600">{propSchema.description}</p> <p className="text-sm text-gray-600">
{propSchema.description}
</p>
)} )}
{propSchema.items?.description && ( {propSchema.items?.description && (
@ -333,10 +335,7 @@ const DynamicJsonForm = ({
const defaultValue = getArrayItemDefault( const defaultValue = getArrayItemDefault(
propSchema.items as JsonSchemaType, propSchema.items as JsonSchemaType,
); );
handleFieldChange(path, [ handleFieldChange(path, [...arrayValue, defaultValue]);
...arrayValue,
defaultValue,
]);
}} }}
title={ title={
propSchema.items?.description propSchema.items?.description
@ -350,7 +349,7 @@ const DynamicJsonForm = ({
</div> </div>
); );
} }
// For complex arrays, fall back to JSON editor // For complex arrays, fall back to JSON editor
return ( return (
<JsonEditor <JsonEditor