# prg-form

> React Form Components For Bulma

Latest version **0.6.2** (published 2018-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install prg-form
pnpm add prg-form
yarn add prg-form
bun add prg-form
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2018-11-11 |
| First published | 2017-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 68.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pragonauts |
| Maintainers | pragonauts, wingbot.ai |
| Keywords | React, Form, Bulma |

## Links

- npm: https://www.npmjs.com/package/prg-form
- Repository: https://github.com/pragonauts/prg-form
- Homepage: https://github.com/pragonauts/prg-form#readme
- Issues: https://github.com/pragonauts/prg-form/issues
- npm.io page: https://npm.io/package/prg-form

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2018-11-11
- 0.6.1 — 2018-11-11
- 0.6.0 — 2018-11-11
- 0.5.7 — 2018-11-11
- 0.5.6 — 2018-03-07
- 0.5.5 — 2018-03-07
- 0.5.4 — 2018-03-05
- 0.5.3 — 2018-02-12
- 0.5.2 — 2017-12-21
- 0.5.2-alpha.5 — 2017-12-21
- 0.5.2-alpha.4 — 2017-12-21
- 0.5.2-alpha.3 — 2017-12-21
- 0.5.2-alpha.2 — 2017-12-21
- 0.5.2-alpha.1 — 2017-12-21
- 0.5.1 — 2017-12-21
- … 12 more at https://npm.io/package/prg-form/versions

## README

# Prg Form

> React Form components for Bulma.css.

There is [API Documentation](http://pragonauts.github.io/prg-form).

## Usage within Form

```javascript

import { Form, Input } from 'prg-form';

<Form
    className="special-class"
    onSubmit={(values, form) => console.log(values)}
    onChange={(input) => console.log(input.name, input.getValue())}
    values={values}
>
    <Input type="email" name="inputName" label="Input Label" />
    <button>Submit</button>
</Form>
```

## Usage without Form

- onchange event is not passed to form

```javascript

import { Input } from 'prg-form';

<Input
    name="inputName"
    label="Input Label"
    value={value}
    onChange={(value, input) => {}}
/>
```

## Basic Form Components

- **<Input>**

    ```javascript
    import { Input } from 'prg-form';

    <Input
        name="inputName"
        label="Input Label"
        type="password"
        maxLength={24}
    />
    ```

- **<Checkbox>**

    ```javascript
    import { Checkbox } from 'prg-form';

    <Checkbox
        name="checkbox"
        defaultValue
    />
    ```

- **<TextArea>**

    ```javascript
    import { TextArea } from 'prg-form';

    <TextArea
        name="inputName"
        readOnly
        cols={30}
        rows={7}
    />
  ```

- **<File>**

    Is nice, because it works with native `<File>` objects.

    ```javascript
    import { File } from 'prg-form';

    // as array of files
    <File
        name="files[]"
        multiple
    />

    <File
        name="file"
    />
    ```

## Advanced using the file upload

```javascript
import { File, ValidatorForm, flat } from 'prg-form';
import Validator from 'prg-validator';

export default function Component ({ onSendSuccess, onSendError }) {
    const validator = new Validator();

    validator.add('file')
        .isFileMaxLength('shlould be smaller then 1Mb', '1m')
        .isFileMime('Should be an excel file', [
            'application/vnd.ms-excel',
            'application/msexcel',
            'application/x-msexcel',
            'application/x-ms-excel',
            'application/x-excel',
            'application/x-dos_ms_excel',
            'application/xls',
            'application/x-xls',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        ])
        .toFileData();

    const onSubmit = (formData) => {
        const data = new FormData();

        const flatData = flat(formData);

        Object.keys(flatData)
            .forEach((key) => {
                data.append(key, flatData[key]);
            });

        this.request = $.ajax({
            method: 'POST',
            url: '/api/upload',
            dataType: 'json',   // JSON Response
            processData: false, // Don't process the files
            contentType: false, // Automatic content type
            data,
            success: responseData => onSendSuccess(responseData),
            error: jqXHR => onSendError(jqXHR)
        });
    };

    return (<div className="container">
        <ValidatorForm
            validator={validator}
            onSubmit={data => onSubmit(data)}
        >
            <File
                name="file"
                label="Please put the Excel file here"
            />
            <button className="button">Go</button>
        </ValidatorForm>
    </div>);
}

```

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