1.2.5 • Published 4 years ago

context-form v1.2.5

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

README

Form Management for React & React Native with a simple and flexible API.
Demo: https://youshido.github.io/context-form/demo/
Docs: https://youshido.github.io/context-form/

Thanks to the Context API (as of React 16.3) it is possible to write a library for the Form Management with a very clean and almost invisible API where you don't have to pass Form's props all over your project.

Main Features

  • Declarative API with no need for extra props passing
  • InitialValues as a simple prop to the <Form initialValues={} />
  • Controlled and Uncontrolled Form State
  • Field Arrays and Groups with custom JSX/Fields structure
  • Easy to implement Custom Controls
  • Support for the complex JSX structure inside the Form
  • Themes support — implement project-wide styling in a single file
  • Ready to go integrations with Bootstrap, Ant and Material UI
  • And it's simply a <Form /> that's fun to use :)

Installation

Add context-form package to your project using yarn or npm:

$ yarn add context-form (or npm i context-form)

Once you installed Context Form as a dependency you can try it out with this basic example of the uncontrolled form (note, it uses console to log the values submitted and does automatic field validation for a title field (required is just a shortcut for the more extensive rules props)

Once you installed Context Form as a dependency you can try it out with this basic example of the uncontrolled form (note, it uses console to log the values submitted and does automatic field validation for a title field (required is just a shortcut for the more extensive rules props):

import React, { Component } from 'react';
import Form, { Field, FormFooter } from 'context-form';

class ProductPage extends Component {
    /**
     * By default `onSubmit` will be called only if validation
     */
    onSubmit = ({ values }) => {
        console.log('Form Values', values);
    };
    render() {
        return (
            <Form onSubmit={this.onSubmit}>
                <Field name="firstName" />
                <Field name="lastName" />
                <Field name="title" required />
                // FormFooter is used just for layout purpose
                <FormFooter>
                    <button>Submit</button>
                </FormFooter>
            </Form>
        )
    }
}

You can now take a look at the more advances usage in the docs: https://youshido.github.io/context-form/

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

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

5 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.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

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago