From 33e0b9f20f9801e254b69b0034734b02e110482b Mon Sep 17 00:00:00 2001 From: utnim2 Date: Mon, 27 May 2024 20:43:07 +0530 Subject: [PATCH] added some reviewed change --- packages/ui/components/VisualEditor.tsx | 59 ++++++++++++++++--------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/packages/ui/components/VisualEditor.tsx b/packages/ui/components/VisualEditor.tsx index 24049000a..e205dd39f 100644 --- a/packages/ui/components/VisualEditor.tsx +++ b/packages/ui/components/VisualEditor.tsx @@ -68,7 +68,6 @@ export const VisualEditor: React.FC = ({ schema, onSchemaChan { type: 'regular', title: 'Number', onSelect: () => handleArrayItemTypeDropdownSelect('number') }, { type: 'regular', title: 'Boolean', onSelect: () => handleArrayItemTypeDropdownSelect('boolean') }, { type: 'regular', title: 'Object', onSelect: () => handleArrayItemTypeDropdownSelect('object') }, - { type: 'regular', title: 'Array', onSelect: () => handleArrayItemTypeDropdownSelect('array') }, ]; const renderRootTypeDisplay = () => { @@ -90,12 +89,6 @@ export const VisualEditor: React.FC = ({ schema, onSchemaChan > {displayRootType} - } - items={rootTypeOptions} - side="bottom" - align="start" - /> ); }; @@ -116,12 +109,6 @@ export const VisualEditor: React.FC = ({ schema, onSchemaChan > {`Array<${itemType}>`} - } - items={itemTypeOptions} - side="bottom" - align="start" - /> ); } @@ -129,17 +116,49 @@ export const VisualEditor: React.FC = ({ schema, onSchemaChan }; return ( -
+
{renderRootTypeDisplay()} {renderArrayItemTypeDisplay()} + + + + } + items={rootTypeOptions} + /> + {schemaObject.type === "array" && ( + + + + } + items={itemTypeOptions} + /> + )}
- handleSchemaChange(newSchema)} - path={schemaObject.type === 'array' ? 'items' : ''} - level={0} - /> + {(schemaObject.type === "object" || schemaObject.type === "array") && ( + handleSchemaChange(newSchema)} + path={schemaObject.type === "array" ? "items" : ""} + level={0} + /> + )}
); };