# fitx-form

> JSON controlled responsive react form

Latest version **1.0.12** (published 2020-04-26) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2020-04-26 |
| First published | 2019-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 495.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Balkishan S |
| Maintainers | ryder_kishan |
| Keywords | React, JSON, Form |

## Links

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

## Dependencies (4)

- [ki-ui](https://npm.io/package/ki-ui.md) ^1.0.6
- [ramda](https://npm.io/package/ramda.md) ^0.27.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.28

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.12 (latest) — 2020-04-26
- 1.0.11 — 2020-04-26
- 1.0.10 — 2020-03-31
- 1.0.9 — 2020-03-31
- 1.0.8 — 2020-03-31
- 1.0.7 — 2020-03-31
- 1.0.6 — 2020-03-31
- 1.0.5 — 2020-03-31
- 1.0.4 — 2020-03-31
- 1.0.3 — 2020-03-31
- 1.0.2 — 2020-03-31
- 1.0.1 — 2020-03-31
- 1.0.0 — 2019-12-26

## README

<h1 align="center">Fitx Form</h1>

A responsive [React](https://reactjs.org/) form for various input types controlled by a JSON component for faster and easier web development.

<div align="center">

[![npm package](https://img.shields.io/npm/v/fitx-form/latest.svg)](https://www.npmjs.com/package/fitx-form)
[![npm downloads](https://img.shields.io/npm/dm/fitx-form.svg)](https://www.npmjs.com/package/fitx-form)
</div>

![Fitx - Form Image](https://raw.githubusercontent.com/RyderKishan/fitx-form/master/src/assets/json.png)
![Fitx - Form Output](https://raw.githubusercontent.com/RyderKishan/fitx-form/master/src/assets/output.png)

## Installation

fitx-form is available as an [npm package](https://www.npmjs.com/package/fitx-form).

```sh
// with npm
npm install fitx-form

// with yarn
yarn add fitx-form
```

Please note that `@next` will only point to pre-releases; to get the latest stable release use `@latest` instead.


## Usage

constants.js

```jsx
export default [
  {
    elements: [
      {
        id: 'fName',
        name: 'First Name',
        type: 'TextInput',
        placeholder: 'Full Name',
      },
    ],
    groupName: 'Personal Details',
    groupId: 'personalDetails',
  },
];
```
Here is a quick example to get you started, **it's all you need**:

```jsx
import React from 'react';
import ReactDOM from 'react-dom';
import FitxForm from 'fitx-form';
import * as R from 'ramda';
import * as Constants from './constants';

function App() {
  return (
    <FitxForm
      metaData={Constants.metaData}
    />
  );
}

ReactDOM.render(<App />, document.querySelector('#app'));
```
Full working exapmle with handlers is given in the Example section

## Documentation

#### FitxForm Props

| Props | Type | Description |  
|-----------|:-----------|:-----------|
| `formValues` | object | The value object |
| `metaData` | array | Array of the components |
| `onChange` | func | On Change event |
| `onClick` | func | On Click event |
| `columns` | number | Number of columns to be displayed |

#### Component Props

| Props | Type | Description |  
|-----------|:-----------|:-----------|
| `allowClear` | bool | Enables date clear button |
| `defaultValue` | Based on the `type` | Default value for the field, Triggers onChange when component renders |
| `disabled` | bool | Mark the element to be disabled |
| `displayName` | string | Display text of `ButtonInput` |
| `emptyOption` | bool | Display empty option in `SelectInput` as `placeHolder` |
| `error` | bool | Show the error container and display `errorText` |
| `errorText` | string | String to be displayed in the error container |
| `helperText` | string | String to be displayed as a helper text in error container |
| `max` | number | The max input for Number and Date |
| `maxLength` | number | Max length of the input in chars |
| `min` | number | The min input for Number and Date |
| `onClick` | func | Triggers on a `ButtonInput` click `() => (groupId, elementId)` |
| `onChange` | func | Triggers on a value change `() => (groupId, elementId, value)` |
| `onSelect` | func | Triggers on a value select `() => (groupId, elementId, value)` |
| `options` | array | List of options as `{ label, value, disabled}` |
| `options.label` | string | The display name of the option |
| `options.value` | string | The id of the option |
| `options.disabled` | bool | Disables the option |
| `placeholder` | string | String to be displayed as a placeholder |
| `readOnly` | bool | Marks the field as read only |
| `regex` | regexp | Regex for input value -> error is true if regex fails |
| `spellCheck` | bool | Enables native spell check in text inputs |
| `value` | string | The value to be hardcoded |
| `type` | ButtonInput, CheckboxInput, DateInput, RadioInput, SelectInput, TextInput| The Component Type |
| `subType` | string | Sub type of available components  |

## Example

Full Working Example

[Constants File](https://raw.githubusercontent.com/RyderKishan/fitx-form/master/src/constants/index.js).

```jsx
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import FitxForm from 'fitx-form';
import * as R from 'ramda';
import * as Constants from './constants';

function App() {
  const [values, setValues] = useState({});
  const onFormValuesChange = (groupId, elementId, value) => {
    const lensProp = R.lensPath([groupId, elementId]);
    const newValue = R.set(lensProp, value, { ...values });
    setValues(newValue);
  };
  const onFormElementClick = (groupId, elementId) => {
    let query = `${groupId} ${elementId}`;
    switch (query) {
      case 'personalDetails submit':
        onPartySave();
        break;
      default: {
        query = '';
      }
    }
  };
  return (
    <FitxForm
      formValues={values}
      metaData={Constants.metaData}
      onChange={onFormValuesChange}
      onClick={onFormElementClick}
      columns={2}
    />
  );
}

ReactDOM.render(<App />, document.querySelector('#app'));
```

![Fitx - Form Exapmle](https://raw.githubusercontent.com/RyderKishan/fitx-form/master/src/assets/example.png)

## Changelog

Recently Updated?
Please read the [changelog](https://github.com//RyderKishan/fitx-form/releases).

## Roadmap

1. To Add custom themes
2. Make is more backward compactible

## Author

Balkishan S

[Github](https://github.com/RyderKishan), [Medium](https://medium.com/@kishan020696), [Facebook](https://www.facebook.com/kishan020696), 

## License

This project is licensed under the terms of the [MIT license](/LICENSE).

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