1.0.9 • Published 2 years ago

react-variety-form v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Variety Form

Sometimes in our work, we are forced to go extra fast to finish our project because of any urgent request for a demo to show a new form or to create a simple form. Anyway, we can use any framework to handle it. But, you need extra time to install and set up. React Variety Form provides a simple form that can help you to give a style choice, validation, and responsiveness without any configs.

NPM JavaScript Style Guide

Demo

Visit to Live Preview

Install

npm install react-variety-form

Example Usage

import React from 'react'
import {
  TextBox,
  TextArea,
  Select,
  SelectSearch,
  Radios,
  CheckBox
} from 'react-variety-form'

const Example = () => {
  function handleChange(value) {
    // your logic
  }

  render() {
    return (
       <TextBox onChange={handleChange} />
       <TextArea isRounded />
       <Select isDisable />
       <SelectSearch  />
       <Radios options={['Male', 'Female']} />
       <CheckBox />
    )
  }
}

export default Example

Common Props

Common Props are properties than can use for all columns.

PropsTyppeDefaultDescription
isRoundedbooleanfalserounded style bordered. default is flat
isErrorbooleanfalsecustom error based on your logic
errorCausebooleannPlease enter data correctly!custom error message when you give an error based on your logic
isRequiredbooleanfalsetag for the label which is the column that is mandatory. If true there is asterisk tag with red color
mandatoryMessagestringField is required!custom error mandatory. not applicable for SelectSearch, CheckBox and Radios
isDisablebooleanfalseprevent change value
onChangefunctionset value for your current state

Text Box

Text Box is the most used input form. Then format and validation are necessary to prevent wrong inputted.

PropsTyppeDefaultDescription
labelstringFull Namethe label is can custom based on your business
valuestringempty stringset default state
placeholderstringType heregive a hint to the user to know what will they type
maxLengthnumber255limit text inputted
isNumberOnlybooleanfalseprevent input characters besides number type or only number allowed
isEmailbooleanfalseallow email format only
emailErrorMessagestringFormat email is wrong!show error email when input and format dont match
progressbooleanfalseshow progress length of characters typed

Text Area

Basically almost the same as Text Box. But, there are several added properties that can be used to complete features. Props isNumberOnly and isEmail are not applicable on it.

PropsTyppeDefaultDescription
labelstringAddresswhy address? bacause text area provide a wide space. but, easy to custom as like you want
rowsnumber5create widely area with a given number

Select

Select gives a choice option based on data. You only give an array object data and define value and name.

PropsTyppeDefaultDescription
labelstringCategoryyou can custom as like you want
dataarray[]give an array and must object
namestringempty stringkey from the element of property data which will be used to show on option
valuestringempty stringkey from the element of property data which will be set as state
selectedstringempty stringa value of state
directionstringSelect a categorya first option to direct to user

Mention property array, name and value. Below given an example how to implemment it.

const Example = () => {
  const data = [
    {
        id: 178,
        fruitName: 'Apple'
    },
    {
        id: 179,
        fruitName: 'Pear'
    }
  ]
  render() {
    return (
       <Select data={data} name="fruitName" value="id" />
    )
  }
}

Select Search

It was used to search bulky lists by type of characters. For several props same with select props. But, for props value will be instead of selected. Please adjust as needed for props placeholder and label.

Radio Button

You can determine how many options that show on form with array.

PropsTyppeDefaultDescription
labelstringGenderthis is can custom by own
optionsarray[]determie options
namestringoption-namename of option
isColumnbooleanfalseis true mean are options order by column, vice-versa is row

Check Box

Check Box return boolean true or false

PropsTyppeDefaultDescription
labelstringAgreesomtimes checkbox used for agreement
statementstringI am agree with the statements and conditionsthe statement value

Conclusion

React Variety Form give easy design and use to handle common to prevent wrong process.

License

MIT © faridho

1.0.9

2 years ago

1.0.8

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago