Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-json-schema-ui-editor

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-json-schema-ui-editor - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

1

dist/index.d.ts

@@ -137,2 +137,3 @@ import * as react_jsx_runtime from 'react/jsx-runtime';

type: (typeof jsonSchemaPossibleFieldType)[number];
errors?: string[];
}

@@ -139,0 +140,0 @@ interface ButtonInputParams {

@@ -8,2 +8,12 @@ // src/components/JsonSchemaContext.tsx

import _ from "lodash";
// src/hooks/errors.ts
var EmptyPropertyNameError = class extends Error {
constructor(message) {
super(message);
this.name = "EmptyPropertyName";
}
};
// src/hooks/useJsonSchema.ts
var useJsonSchema = (init = {}, onChange) => {

@@ -14,2 +24,3 @@ const isFirstRender = useRef(true);

}, []);
const [errors, setErrors] = useState([]);
const [schema, setSchema] = useState(init);

@@ -65,2 +76,12 @@ useEffect(() => {

const addPropertyToObject = (path, property) => {
if (property.length === 0) {
setErrors((prev) => [
...prev.filter((e) => e.path !== path),
{
path,
error: new EmptyPropertyNameError("Property name can't be empty")
}
]);
return;
}
setSchema(

@@ -74,2 +95,7 @@ (prev) => _.setWith(

);
setErrors(
(prev) => prev.filter(
(e) => e.path !== path && e.error instanceof EmptyPropertyNameError
)
);
};

@@ -79,2 +105,3 @@ const getPathState = (path) => {

};
const getPathErrors = (path) => errors.filter((e) => e.path === path).map((e) => e.error);
return {

@@ -90,3 +117,4 @@ schema,

getPathState,
getPropertyPath
getPropertyPath,
getPathErrors
}

@@ -137,3 +165,4 @@ };

const {
actions: { addPropertyToObject }
actions: { addPropertyToObject },
derived: { getPathErrors }
} = useJsonSchemaContext();

@@ -148,3 +177,4 @@ const [propertyToBeAdded, setPropertyToBeAdded] = useState2("");

type: "string",
value: propertyToBeAdded
value: propertyToBeAdded,
errors: getPathErrors(path || "").map((e) => e.message)
}),

@@ -151,0 +181,0 @@ renderAddPropertyButton({

2

package.json
{
"name": "react-json-schema-ui-editor",
"version": "0.2.0",
"version": "0.3.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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc