npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsonschema-form-for-material-ui

v1.4.3

Published

Material UI implementation of react-jsonschema-form

Downloads

98

Readme

jsonschema-form-for-material-ui

A Material UI port of react-jsonschema-form.

Project forked from Graham King.

The initial project had lots of stuff in it, including a strict node version and demo server.

This package:

  • Updated packages
  • Not pre-bundled
  • Better layout
  • Will be supported and updated

I will be monitoring Mozilla's repo for changes: they plan on becoming ui-agnostic, and I will migrate this project into a wrapper of that one when that happens (which will be a major version bump)

Update: Mozilla is doing something similar: See https://github.com/mozilla-services/react-jsonschema-form/issues/1222 for details

Installation

npm install --save jsonschema-form-for-material-ui

Usage

import SchemaForm from 'jsonschema-form-for-material-ui';

const styles = theme => ({
  field: {},
  formButtons: {},
  root: {},
});

const schema = {
  "title": "A registration form",
  "description": "A simple form example.",
  "type": "object",
  "required": [
    "firstName",
    "lastName"
  ],
  "properties": {
    "firstName": {
      "type": "string",
      "title": "First name"
    },
    "lastName": {
      "type": "string",
      "title": "Last name"
    },
    "age": {
      "type": "integer",
      "title": "Age"
    }
  }
}

const uiSchema = {
  "firstName": {
    "ui:autofocus": true,
    "ui:emptyValue": ""
  },
  "age": {
    "ui:widget": "updown",
    "ui:title": "Age of person",
    "ui:description": "This description will be in a Popover"
  }
}

const initialFormData = {
  "firstName": "Chuck",
  "lastName": "Norris",
  "age": 75,
}

<SchemaForm
  classes={classes}
  schema={schema}
  uiSchema={uiSchema}
  formData={initialFormData}
  onCancel={this.onCancel}
  onSubmit={this.onSubmit}
  onChange={this.onFormChanged}
/>

API

| Prop | Description | | --------------- | ---------------------------------------------------------------------------------------- | | schema | The JSON Schema that will be the base of the form | | classes | withStyles() classes that get passed to root components for better styling of the form | | uiSchema | Extra styling for fields. Each key references one schema key | | formData | The initial data with which to populate the form | | onCancel | Called when the Cancel button is pressed | | onSubmit | Called when the Submit button is pressed | | onChange | Called when form data is changed | | cancelText | Text for the Cancel button (Cancel by default) | | submitText | Text for the Submit button (Submit by default) | | showErrorList | Boolean to display the error list | | showHelperError | Boolean to display error in FormHelperText |

Classes

| name | element | | ----------- | ------------------------------- | | root | The surrounding Paper element | | field | Fields container | | formButtons | Button div | | button | Cancel/Submit form button | | cancel | Cancel form button | | submit | Submit form button |

In-depth prop descriptions

uiSchema

ui:widget - string

This setting handles the input type that will be shown.

Default - textarea

  • radio
  • updown
  • password
  • textarea
  • checkboxes
  • ~~alt-datetime (~~todo~~)~~

ui:title - string

Title of field that will be shown

ui:description - string

The description text that will be shown when hovering on the info icon

ui:options - object

inline - boolean

disabled - boolean

disabled - function(data, objectData) should return boolean

~~inputType (~~todo~~) - Format the input to a specific type (e.g. Phone, Credit Card, Date, etc)~~

ui:help - string

Help text that will be shown below the input

ui:orientation - string

row

default

Contributing

Issues and pull requests welcome!

Give the initial author credit, too.