# easy-form-manager

> plug and play form component

Latest version **1.0.13** (published 2019-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install easy-form-manager
pnpm add easy-form-manager
yarn add easy-form-manager
bun add easy-form-manager
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2019-09-11 |
| First published | 2019-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 2.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | fliip92 |
| Maintainers | jufelipe |

## Links

- npm: https://www.npmjs.com/package/easy-form-manager
- Repository: https://github.com/fliip92/react-easy-form
- Homepage: https://github.com/fliip92/react-easy-form#readme
- Issues: https://github.com/fliip92/react-easy-form/issues
- npm.io page: https://npm.io/package/easy-form-manager

## Recent versions

- 1.0.13 (latest) — 2019-09-11
- 1.0.12 — 2019-09-11
- 1.0.11 — 2019-09-11
- 1.0.10 — 2019-09-11
- 1.0.9 — 2019-09-11
- 1.0.8 — 2019-09-05
- 1.0.7 — 2019-09-05
- 1.0.6 — 2019-09-04
- 1.0.5 — 2019-09-04
- 1.0.4 — 2019-09-02
- 1.0.3 — 2019-09-02
- 1.0.2 — 2019-09-02
- 1.0.1 — 2019-08-28
- 1.0.0 — 2019-08-24

## README

# easy-form-manager
_Simple, Fast, MobX-State-Tree powered form manager [Live Demo](https://easy-form-5bdb0.web.app/)_

# Contents
-   [Installation](#installation)
-   [Getting Started](#getting-started)
-   [Examples](#examples)
-   [Api overview](#api-overview)


# Installation

-   NPM: `npm install easy-form-manager --save`
-   Yarn: `yarn add easy-form-manager`

# Getting started

`<Form>` is a wrapper component automatically inject value and listener to each field contained with fieldid atributte added.

| prop                |  description                                                                          | required  | 
| ------------------- | ------------------------------------------------------------------------------------- | --------- |
| [`onSubmit`]()      | Callback return field values required a submit type button.                           | optional  |
| [`validation`]()    | Callback function expect return true or false.                                        | optional  |
| [`fieldid`]()       | Atributte required must be added to each field.                                       | required  |



```javascript
import { Form } from "easy-form-manager"
//...

render(){
  return(
    <Form 
      onSubmit={(values)=> { /* do something with the values */ }} 
      validation={(values) => /* validate values and return true or false */}
    > 
      <label>This is a field</label>
      <input fieldid="field-id" />
    </Form>
  )
}

```

`<ConditionalRender>` is a wrapper component to hide or render the children

| prop                |  description                                                                          | required  | 
| ------------------- | ------------------------------------------------------------------------------------- | --------- |
| [`condition`]()      | Callback return field values and expect `true` or `false`                            | optional  |

```javascript
import { Form } from "easy-form-manager"
//...

render(){
  return(
    <Form> 
      <ConditionalRender condition={(values)=> /* add some condition as values.fieldid === "something" */ ? true : false}>
        <MoreFields />
        <YepEvenMoreThanOne />
      </ConditionalRender>
    </Form>
  )
}

```



# Examples

To run the examples:

1.  clone this repository
2.  navigate to the demo folder (e.g. `/demo`)
3.  run `yarn install` and `yarn start`

or check the [Live Demo](https://easy-form-5bdb0.web.app/) page

# Api overview
| signature                                                                                                             |                                                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`values()`]()                                                     | Function, return field values                                                                                                                                                                        |
| [`getFieldValue(fieldid) => fieldid.value)`]() | Return an specific field value                                                                                                                                                                |
| [`setValue(fieldid, value)`]()                                              | Set a value to an specific field                                                                                                                                                                                                                |

---
_Source: https://npm.io/package/easy-form-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
