Skip to content

Commit

Permalink
fix(jsoneditor): should render array in AnyInput
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Dec 18, 2024
1 parent c760a68 commit b5ae385
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
19 changes: 19 additions & 0 deletions nodepkg/jsoneditor/example/jsoneditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class JSONSchema {
@t.record(t.string(), t.any())
@t.optional()
manifests!: Record<string, any>;

@t.annotate({ title: "任意类型" })
@t.record(t.string(), t.any())
@t.optional()
anyjson: any;
}

export default component(() => {
Expand All @@ -62,6 +67,20 @@ export default component(() => {
ports: [],
manifests: {
"x": {}
},
anyjson: {
obj: {
a: 1
},
arr: ["1", "2", "3"],
nested: [
{
a: 1
},
{
a: 2
}
]
}
});

Expand Down
2 changes: 1 addition & 1 deletion nodepkg/jsoneditor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@innoai-tech/jsoneditor",
"version": "0.3.6",
"version": "0.3.7",
"monobundle": {
"build": {
"clean": true
Expand Down
4 changes: 2 additions & 2 deletions nodepkg/jsoneditor/src/inputs/AnyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export const AnyInput = component$<{
props.value$,
render((value) => {
if (isArray(value)) {
return <ArrayInput value={value} typedef={t.any()} ctx={props.ctx} />;
return <ArrayInput value={value} typedef={t.array(t.any())} ctx={props.ctx} />;
}

if (isObject(value)) {
return <RecordInput value={value} typedef={t.record(t.string(), t.any())} ctx={props.ctx} />;
}

return <ValueInput value={value} typedef={t.any()} ctx={props.ctx} allowRawJSON/>;
return <ValueInput value={value} typedef={t.any()} ctx={props.ctx} allowRawJSON />;
})
);
});
10 changes: 9 additions & 1 deletion nodepkg/jsoneditor/src/inputs/ValueInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ export const ValueInputActions = styled("div")({
roundedRight: "sm",
display: "flex",
px: 2,
py: 1,
ml: -4
});

Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit b5ae385

Please sign in to comment.