From b5ae3859f460f001f9838e8dedc6fea28057adca Mon Sep 17 00:00:00 2001 From: Morlay Date: Wed, 18 Dec 2024 11:16:08 +0800 Subject: [PATCH] fix(jsoneditor): should render array in AnyInput --- nodepkg/jsoneditor/example/jsoneditor.tsx | 19 +++++++++++++++++++ nodepkg/jsoneditor/package.json | 2 +- nodepkg/jsoneditor/src/inputs/AnyInput.tsx | 4 ++-- nodepkg/jsoneditor/src/inputs/ValueInput.tsx | 10 +++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/nodepkg/jsoneditor/example/jsoneditor.tsx b/nodepkg/jsoneditor/example/jsoneditor.tsx index 46e8cc0..686d3be 100644 --- a/nodepkg/jsoneditor/example/jsoneditor.tsx +++ b/nodepkg/jsoneditor/example/jsoneditor.tsx @@ -49,6 +49,11 @@ class JSONSchema { @t.record(t.string(), t.any()) @t.optional() manifests!: Record; + + @t.annotate({ title: "任意类型" }) + @t.record(t.string(), t.any()) + @t.optional() + anyjson: any; } export default component(() => { @@ -62,6 +67,20 @@ export default component(() => { ports: [], manifests: { "x": {} + }, + anyjson: { + obj: { + a: 1 + }, + arr: ["1", "2", "3"], + nested: [ + { + a: 1 + }, + { + a: 2 + } + ] } }); diff --git a/nodepkg/jsoneditor/package.json b/nodepkg/jsoneditor/package.json index 0e7dcda..2dea034 100644 --- a/nodepkg/jsoneditor/package.json +++ b/nodepkg/jsoneditor/package.json @@ -1,6 +1,6 @@ { "name": "@innoai-tech/jsoneditor", - "version": "0.3.6", + "version": "0.3.7", "monobundle": { "build": { "clean": true diff --git a/nodepkg/jsoneditor/src/inputs/AnyInput.tsx b/nodepkg/jsoneditor/src/inputs/AnyInput.tsx index 63febfc..a97bef1 100644 --- a/nodepkg/jsoneditor/src/inputs/AnyInput.tsx +++ b/nodepkg/jsoneditor/src/inputs/AnyInput.tsx @@ -13,14 +13,14 @@ export const AnyInput = component$<{ props.value$, render((value) => { if (isArray(value)) { - return ; + return ; } if (isObject(value)) { return ; } - return ; + return ; }) ); }); diff --git a/nodepkg/jsoneditor/src/inputs/ValueInput.tsx b/nodepkg/jsoneditor/src/inputs/ValueInput.tsx index 9eac89a..b17b4b4 100644 --- a/nodepkg/jsoneditor/src/inputs/ValueInput.tsx +++ b/nodepkg/jsoneditor/src/inputs/ValueInput.tsx @@ -529,6 +529,7 @@ export const ValueInputActions = styled("div")({ roundedRight: "sm", display: "flex", px: 2, + py: 1, ml: -4 }); @@ -567,7 +568,14 @@ export const ValueContainer = styled("div")({ alignItems: "center", border: "1px solid", overflow: "hidden", - borderColor: variant("sys.outline-variant", alpha(0.38)) + borderColor: variant("sys.outline-variant", alpha(0.38)), + opacity: 0.38, + "&:hover": { + opacity: 1 + }, + "&:focus-within": { + opacity: 1 + } }, "& textarea,input": {