1.0.2 • Published 5 months ago

@zhwatts/mui-forms v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

About

Create beautiful advanced forms with a JSON-based schema

Advantages and features

  • Material UI components
  • Built-in layouting
  • Responsive
  • Support for custom components
  • Easily define field relationships and build advanced forms
  • Load data from API
  • Extensible
  • Simple forms
  • Wizard forms
  • Stepper forms
  • Mobile-ready
  • Production-ready

Installation

npm install mui-forms

Documentation

Visit the following page for detailed documentation: https://mui-forms.vercel.app

Basic Usage

1. Define your JSON schema

const exampleSchema = {
    "fields": [{
        "name": "first_name",
        "meta": {
            "displayType": "text",
            "displayName": "First Name"
        }
    }, {
        "name": "last_name",
        "meta": {
            "displayType": "text",
            "displayName": "Last Name"
        }
    }]
}

2. Usage

import React from 'react';
import MuiForms from 'mui-forms';
import exampleSchema from '<example-schema.json>';

export function MyForm() {
    return (
        <MuiForms
            schema={exampleSchema}
            onSubmit={(formData) => {
              // submit data
            }}
        />
    );
}

Input Properties

NameDescription
classNameName of class attribute assigned to the root form element
nameThe name of the form
configConfiguration options for the form. Read more
dataContains initial form data values when the form is loaded. Read more
schemaJSON-based schema for rendering the form. Read more
controlsCustom fields. Read more
componentsCustom template components mapped with schema using displayType property as template. Read more
pageNumberThe default tab on opening the form (grouped form)
lastPageNumberThe last page number will exclude any tabs that appear after the lastPageNumber tab
onChangeA function that will be called whenever the value of a field changes. The second parameter provided to this function contains the complete form data.
onErrorA function that will be called whenever there is an error with a field.
onNextA function that will be called when when the user attempts to navigate to the next section of a grouped form
onPreviousA function that will be called when when the user attempts to navigate to the previous section of a grouped form
onSubmitA function that will be called when the form is submitted
changeResponseModeValue: "form-data", "section-data", "default". form-data: onChange event will pass all the form data as a second parameter. section-data: onChange event will pass all the section data as a second parameter
nextResponseModeValue: "form-data", "page-data" form-data: onNext event will send all the form data (onNext). page-data: onNext event will send all the date of the current page. Note: onNext is triggered on click of Next button

Mandatory properties

  • schema
  • onSubmit

Schema details

Check out details here https://mui-forms.vercel.app/schema

Change logs

Contributions

To contribute, you can fork the repo, make your changes and submit a PR/MR to the master branch.

You can contribute in many ways:

  • Work on features/enhancements
  • Work on bug fixes
  • Improve on existing functionalities
  • Improve documentation
  • Add more examples/improve existing example
  • Participate in discussions
  • Provide your valuable feedback/suggestions.

Give a ⭐️ if you liked this project!

License

MIT © manojadams