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

React component to edit json schema in a UI.

  • 0.4.1
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-83.61%
Maintainers
0
Weekly downloads
 
Created
Source

NPM Version

React Json Schema Editor

A configurable React component to display and edit a JSON Schema.

How to use

Coming from a story:

Default.args = {
  initialSchema: schema,
  renderPropertyName: ({ propertyName }) => (
    <h6 style={{ color: "red" }}>{propertyName}</h6>
  ),
  renderAddPropertyButton: ({ onClick }) => (
    <button onClick={onClick}>+</button>
  ),
  renderRemovePropertyButton: ({ onClick }) => (
    <button onClick={onClick}>Remove</button>
  ),
  renderInput: ({ onChange, value, type, field, options }) => {
    if (type === "string") {
      return (
        <input
          type="text"
          value={value}
          onChange={(e) => onChange(e.target.value || "")}
        />
      );
    }
    if (type === "float" || type === "integer") {
      return (
        <input
          type="number"
          value={value}
          onChange={(e) => onChange(e.target.value || "")}
        />
      );
    }
    if (type === "bigString") {
      return (
        <textarea
          rows={3}
          cols={50}
          value={value}
          onChange={(e) => onChange(e.target.value || "")}
        />
      );
    }
    if (type === "select") {
      return (
        <select
          value={value}
          onChange={(e) => onChange(e.target.value)}
          name={field}
          id={`${field}-select`}
        >
          {options?.map((opt) => (
            <option value={opt}>{opt}</option>
          ))}
        </select>
      );
    }
    if (type === "enum") {
      return <>ENUM</>;
    }
  },
};

Keywords

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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