Coder Social home page Coder Social logo

formst's Introduction

1) Introduction

Formst is a model-driven library for quickly building high-performance forms in React. Unlike most form libraries that are UI-First, Formst is Data-First.

2) Motivation:

While working on a recent project, GeekyAnts devs realised that there was no easy way to build forms for React apps. Yes, there are solutions available but they're not quite optimal. It is difficult to find a single library that provides great UX, speed and features such as interdependency between form fields. That's when we decided to build Formst, a library that allows you to build high-performance, responsive forms for your React apps.

3) Features

  • High-performance: ****Formst is MST-based which makes it fast and *powerful*.
  • Responsive: Create responsive forms for your React apps with ease.
  • Forms for Everything: Build flat, stepper or nested forms based on your app needs.
  • Middleware: Use middleware to modify form behaviour such as pre-processing input values.

4) Installation

Use 'yarn' or 'npm' to install this library as shown below:

# yarn
yarn add mst-form-creator

# npm
npm add mst-form-creator

5) Dependencies

MobX, mobx-react/mobx-react-lite and MobX-state-tree.

6) Usage

  • Create a form model as shown below:

    const TodoForm = createFormModel(
      'TodoForm',
      {
        title: types.string,
        description: types.string,
      },
    
      {
        validation: {
          title: ['required'],
          description: 'required',
        },
      }
    ).actions(self => ({
      onSubmit: () => {
        setTimeout(() => {
          alert(JSON.stringify(getSnapshot(self), null, 2));
        }, 100);
      },
    }));
  • Create an instance of the model:

    const todoForm = TodoForm.create({
      title: '',
      description: '',
    });
  • Wrap the components inside MSTForm and use the Field API to render the fields:

    <MSTForm formInstance={todoForm}>
      <form onSubmit={todoForm.handleSubmit}>
        <Field name="title" />
        <ErrorMessage name="title" />
    
        <Field name="description" />
        <ErrorMessage name="description" />
    
        <button type="submit">Submit</button>
      </form>
    </MSTForm>

7) Example

This simple login form will take two inputs that are validated on submission. It can also display specific error messages for invalid input values.

8) Tech Stack

React & Javascript.

9) Contributors

10) How to Contribute

Thank you for your interest in contributing to Formst! We are lucky to have you ๐Ÿ™‚ Head over to Contribution Guidelines and learn how you can be a part of a wonderful, growing community.

For major changes, please open an issue first to discuss changes and update tests as appropriate.

11) License

Licensed under the MIT License, Copyright ยฉ 2020 GeekyAnts. See LICENSE for more information.

formst's People

Contributors

ajamuar avatar himanshu-satija avatar makkarmeenu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.