3.1.1 • Published 4 years ago

advanced-react-input v3.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago
(v3.1.0-beta)

Advanced React Input

Advanced React Input is a component library to build form in a normalized JavaScript/database oriented way without the HTML form caveats

Installation

# with npm
npm i --save advanced-react-input

# with yarn
yarn add advanced-react-input

Usage

Basic usage of <Input /> component

import Input from 'advanced-react-input'

const SomeTextInputComponent = () => (
  <Input
    type={'string'}
    className={'some-text-input'}
    defaultValue={'Foo'}
    placeholder={'Enter text here..'}
    disabled={false}
    onChange={(value) => console.log(value)}
    onFocus={({ value }) => console.log(`focused ! Current value is "${value}"`)}
    onBlur={({ value }) => console.log(`blurred! Current value is "${value}"`)}
  />
)

Basic usage of <Form /> component

import Input, { Form } from 'advanced-react-input'

const handleSubmit = (data) => {
  console.log(data); // { a: "foo", b: "lorem ipsum", c: 14, d: true, e: ['foo', 'bar'] }
}

const SomeForm = () => (
  <Form
    className={'some-form'}
    onSubmit={handleSubmit}
  >
    {(setValue, submit, data) => (
      <>
        <Input
          type={'string'}
          defaultValue={'foo'}
          onChange={(value) => setValue('a', value)}
        />
        <Input
          type={'textarea'}
          defaultValue={'lorem ipsum'}
          onChange={(value) => setValue('b', value)}
        />
        <Input
          type={'int'}
          defaultValue={14}
          onChange={(value) => setValue('c', value)}
        />
        <Input
          type={'boolean'}
          defaultValue={true}
          onChange={(value) => setValue('d', value)}
        />
        <Input
          type={'checkbox'}
          defaultValue={['foo', 'bar']}
          options={[
            { label: 'Foo', value: 'foo' },
            'bar',
            { label: 'Hello', 'world' },
          ]}
          onChange={(value) => setValue('e', value)}
        />

        <button>Submit</button>
      </>
    )}
  </Form>
)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

3.1.1

4 years ago

3.1.0-beta

4 years ago

2.1.4

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.3

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago