react-json-schema-ui-editor
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -23,3 +23,14 @@ // src/components/JsonSchemaContext.tsx | ||
const setSchemaProperty = (path, property) => { | ||
setSchema((prev) => _.setWith(_.clone(prev), path, property, _.clone)); | ||
setSchema((prev) => { | ||
const splittedPath = path.split("."); | ||
if (splittedPath[splittedPath.length - 1] === "type" && property === "array") { | ||
return _.setWith( | ||
_.setWith(_.clone(prev), path, property, _.clone), | ||
`${getPropertyPath(splittedPath.slice(0, -1).join("."))}items`, | ||
{ type: "string" }, | ||
_.clone | ||
); | ||
} | ||
return _.setWith(_.clone(prev), path, property, _.clone); | ||
}); | ||
}; | ||
@@ -105,3 +116,3 @@ const removeSchemaProperty = (propertyPath) => { | ||
// src/components/JsonSchemaPropertyRow.tsx | ||
import { useState as useState3 } from "react"; | ||
import "react"; | ||
@@ -182,3 +193,4 @@ // src/jsonSchemaDescriptor.ts | ||
renderRemovePropertyButton, | ||
renderPropertyName | ||
renderPropertyName, | ||
isArrayItems | ||
}) => { | ||
@@ -189,3 +201,2 @@ const { | ||
} = useJsonSchemaContext(); | ||
const [areChildrenCollapsed, setChildrenCollapsed] = useState3(true); | ||
const currentRowState = getPathState(path); | ||
@@ -203,3 +214,6 @@ const currentRowIsObject = currentRowState.type === "object"; | ||
onChange: (value) => { | ||
setSchemaProperty(`${getPropertyPath(path)}type`, value); | ||
setSchemaProperty( | ||
`${getPropertyPath(path)}type`, | ||
value | ||
); | ||
}, | ||
@@ -213,3 +227,6 @@ value: currentRowState.type, | ||
onChange: (value) => { | ||
setSchemaProperty(`${getPropertyPath(path)}description`, value); | ||
setSchemaProperty( | ||
`${getPropertyPath(path)}description`, | ||
value | ||
); | ||
}, | ||
@@ -232,3 +249,6 @@ value: currentRowState.description, | ||
onChange: (value) => { | ||
setSchemaProperty(`${getPropertyPath(path)}enum`, value); | ||
setSchemaProperty( | ||
`${getPropertyPath(path)}enum`, | ||
value | ||
); | ||
}, | ||
@@ -247,3 +267,3 @@ value: currentRowState.enum, | ||
), | ||
path && renderRemovePropertyButton({ | ||
path && !isArrayItems && renderRemovePropertyButton({ | ||
onClick: () => removeSchemaProperty(path) | ||
@@ -265,3 +285,3 @@ }) | ||
/* @__PURE__ */ jsxs3("div", { children: [ | ||
currentRowIsObject && areChildrenCollapsed && Object.keys(currentRowState.properties || {}).map((prop) => /* @__PURE__ */ jsx2( | ||
currentRowIsObject && Object.keys(currentRowState.properties || {}).map((prop) => /* @__PURE__ */ jsx2( | ||
JsonSchemaPropertyRow, | ||
@@ -286,3 +306,4 @@ { | ||
path: `${getPropertyPath(path)}items`, | ||
name | ||
name: `${name || ""} items`, | ||
isArrayItems: true | ||
} | ||
@@ -289,0 +310,0 @@ ) |
{ | ||
"name": "react-json-schema-ui-editor", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "React component to edit json schema in a UI.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
77758
8
840
1
67