3.0.0-rc.10 • Published 1 year ago

react-jsonschema-form-material-ui v3.0.0-rc.10

Weekly downloads
635
License
ISC
Repository
github
Last release
1 year ago

React Json Schema Form (Mui)

This Project will soon become a umbrella repo for JSON Schema Support to major Frameworks and UI Frameworks. 

More info on this has been outlined in Universal JSON Schema document.

codecov Known Vulnerabilities GitHub package.json version npm GitHub issues GitHub pull requests

Build and Test CI BrowserStack Status Build Status

A Material UI port of jsonschema-form.

A live playground and Detailed Docs

Install instructions via npm (MUI 5+)

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

Follow Releases page to use latest or preleased tags.

For legacy version of < MUI 4

npm install --save react-jsonschema-form-material-ui@3.0.0-mui-4

Basic Example Usage

// Library
import React from 'react';
import MaterialJsonSchemaForm from 'react-jsonschema-form-material-ui';

// Internals
import schema from '../simple/schema.json';
import uiSchema from '../simple/ui-schema.json';
const givenXhrSchema = require('./path-to your-xhr-schema.json'); // Optional
import givenFormData from '../simple/form-data.json';

export default () => {
  const [formData, setFormData] = React.useState(givenFormData);
  
  return <MaterialJsonSchemaForm 
            schema={schema} 
            uiSchema={uiSchema} 
	    xhrSchema={givenXhrSchema || {}} // Optional
	    theme={} // Optional - You need to explicitly provide your custom theme from MUI5 onwards
            formData={formData} 
            onChange={({ formData }) => setFormData(formData)}
            onSubmit={(submittedData) => console.log('form submitted', submittedData)}
          />;
};

Advanced Example Usage

More detailed example can be seen here

// Library
import React from 'react';
import MaterialJsonSchemaForm from 'react-jsonschema-form-material-ui';

// Internals
const givenSchema = require('./path-to your-schema.json');
const givenUISchema = require('./path-to your-ui-schema.json');
const givenXhrSchema = require('./path-to your-xhr-schema.json');
const givenFormData = require('./path-to your-ui-formData.json');

const Example () => {
    
    const [formData, setFormData] = React.useState(givenFormData);
    
    const onSubmit = (value, callback) => {
        console.log('onSubmit: %s', JSON.stringify(value)); // eslint-disable-line no-console
        setTimeout(() => callback && callback(), 2000); // just an example in real world can be your XHR call
    }
    
    const onCancel = () => {
        console.log('on reset being called');
    }
    
    const onFormChanged = ({ formData }) => setFormData(formData);
    
    const onUpload = (value) => {
        console.log('onUpload: ', value); // eslint-disable-line no-console
    }
    
    return (
         <MaterialJsonSchemaForm
	    // Define Schema
	    schema={givenSchema}
	    uiSchema={givenUISchema}
	    xhrSchema={givenXhrSchema || {}}
            formData={formData}
	    theme={} // Optional - You need to explicitly provide your custom theme from MUI5 onwards
	    
	    // Define Event handlers
            onChange={onFormChanged} 
	    onSubmit={onSubmit}
	    
	    // Every Prop below is optional - every prop above this line is required
            onCancel={onCancel} /* optional */
	    onUpload={onUpload} /* optional */
            onError={onError} /* optional */
	    
            /* Optional Prop for custom functions to be executed for transforming data */
            interceptors={{
                translateRatings: (givenData, uiData) => ({ givenData, uiData }),
            }}
	    
            /* Optional Prop for custom components */
	    components={{
		  customComponent: ({ onChange, ...rest }) => (
			<CustomComponent onChange={onChange} formData={givenFormData} uiData={givenUIData} {...rest} />
		  ),
		  customRating: ({ onChange, ...rest }) => (
			<CustomRating onChange={onChange} formData={givenFormData} uiData={givenUIData} {...rest} />
		  ),
	    }}
	    
            /* Optional Prop for custom validation */
            validations={{
                confirmPassword: ({ schema, validations, formData, value }) => value !== formData.pass1 && ({
		      message: validations.confirmPassword.message,
		      inline: true,
                }),
            }}
	    
            /* Optional Prop to auto submit form on press of enter */
	    submitOnEnter
	/>
    );
}

export default Example;

Latest Version npm version [JSONSchema-Draft-7 Support]

  • Build system now upgraded to webpack 5
  • React select values are no longer stringify results but array values.
  • New Tabs UI to divide sub sections to tabs
  • Additional Properties and Additional Items feature enabled
  • "ui:options" and "ui:style" enabled for prop passing and styling every field
  • On the fly module creation
  • Reference Schema's via http and inline references
  • Support alternatives - oneOf, anyOf, allOf
  • Support for dependencies - array of conditionals
  • new Prop onError to get errors available in form on every change
  • new Prop uiData to control ui only data to add separation of concern with form data
  • Demo updated with monaco editor and live validation changes
  • New interceptors to transform form and uiData using uiSchema - ui:interceptor

For more info you can follow our changelog

Contributing

We welcome all contributions, enhancements, and bug-fixes. Open an issue on GitHub and submit a pull request.

Building/Testing

To build/test the project locally on your computer:

Fork this repo and then clone

git clone https://github.com/vip-git/universal-json-schema.git

Install dependencies and module generator

npm install

Run the demo to test your changes

npm start (open http://localhost:3005 once build is successful)

Run the tests once you are done with your changes

npm test

You can send a PR through and a release will be made following Semantic Versioning once your PR gets merged.

2.2.7

1 year ago

3.0.0-rc.10

1 year ago

2.2.5

2 years ago

2.2.6

2 years ago

3.0.0-rc.6

2 years ago

3.0.0-rc.5

2 years ago

3.0.0-rc.9

2 years ago

3.0.0-rc.8

2 years ago

3.0.0-rc.7

2 years ago

2.2.3

2 years ago

2.2.4

2 years ago

3.0.0-rc.4

2 years ago

3.0.0-rc.3

2 years ago

3.0.0-rc.2

2 years ago

3.0.0-rc.1

2 years ago

3.0.0-rc.0

2 years ago

3.0.0-beta.3

2 years ago

3.0.0-beta.1

3 years ago

3.0.0-beta.0

3 years ago

3.0.0-beta.2

3 years ago

3.0.0-mui-4

3 years ago

3.0.0-alpha.13

3 years ago

3.0.0-alpha.12

3 years ago

3.0.0-alpha.10

3 years ago

3.0.0-alpha.11

3 years ago

3.0.0-alpha.7

3 years ago

3.0.0-alpha.6

3 years ago

3.0.0-alpha.9

3 years ago

3.0.0-alpha.8

3 years ago

3.0.0-alpha.1

3 years ago

3.0.0-alpha.3

3 years ago

3.0.0-alpha.2

3 years ago

3.0.0-alpha.5

3 years ago

3.0.0-alpha.4

3 years ago

3.0.0-alpha.0

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.11

3 years ago

2.1.10

3 years ago

2.1.9

3 years ago

2.1.8

3 years ago

2.1.7

3 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.0

4 years ago

2.0.22

4 years ago

2.0.21

4 years ago

2.0.19

4 years ago

2.0.20

4 years ago

2.0.18

4 years ago

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.14-alpha.0

4 years ago

2.0.13

4 years ago

2.0.12

4 years ago

2.0.11

4 years ago

2.0.11-alpha.0

4 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.0-alpha.10

5 years ago

2.0.0-alpha.9

5 years ago

2.0.0-alpha.8

5 years ago

2.0.0-alpha.7

5 years ago

2.0.0-alpha.6

5 years ago

2.0.0-alpha.5

5 years ago

2.0.0-alpha.4

5 years ago

2.0.0-alpha.3

5 years ago

2.0.0-alpha.2

5 years ago

1.0.110

5 years ago

1.0.109

5 years ago

1.0.108

5 years ago

1.0.107

5 years ago

1.0.105

5 years ago

1.0.104

5 years ago

1.0.103

5 years ago

1.0.102

5 years ago

1.0.101

5 years ago

1.0.100

5 years ago

1.0.99

5 years ago

1.0.98

5 years ago

1.0.97

5 years ago

1.0.96

5 years ago

1.0.95

5 years ago

1.0.94

5 years ago

1.0.93

5 years ago

1.0.92

5 years ago

1.0.91

5 years ago

1.0.90

5 years ago

1.0.89

5 years ago

1.0.88

5 years ago

1.0.87

5 years ago

1.0.86

5 years ago

1.0.85

5 years ago

1.0.84

5 years ago

1.0.83

5 years ago

1.0.82

5 years ago

1.0.81

5 years ago

1.0.80

5 years ago

1.0.79

5 years ago

1.0.78

5 years ago

1.0.77

5 years ago

1.0.76

5 years ago

1.0.75

5 years ago

1.0.74

5 years ago

1.0.73

5 years ago

1.0.72

5 years ago

1.0.71

5 years ago

1.0.70

5 years ago

1.0.68

5 years ago

1.0.67

5 years ago

1.0.66

5 years ago

1.0.65

5 years ago

1.0.64

5 years ago

1.0.63

5 years ago

1.0.62

5 years ago

1.0.61

5 years ago

1.0.60

5 years ago

1.0.59

5 years ago

1.0.58

5 years ago

1.0.57

5 years ago

1.0.56

5 years ago

1.0.55

5 years ago

1.0.54

5 years ago

1.0.53

5 years ago

1.0.52

5 years ago

1.0.51

5 years ago

1.0.50

5 years ago

1.0.49

5 years ago

1.0.48

5 years ago

1.0.47

5 years ago

1.0.46

5 years ago

1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.18

6 years ago