1.9.0 • Published 7 days ago

@availity/form v1.9.0

Weekly downloads
18
License
MIT
Repository
github
Last release
7 days ago

@availity/form

Availity form components that are wired to be hooked up to Formik

Version

Installation

npm install @availity/form formik react reactstrap --save

Validation

See yup and @availity/yup

Components

Form

Reactstrap Form component wrapped in Formik

Usage

import React from 'react';
import { Form, Field } from '@availity/form';

const schema = yup.object().shape({
  hello: yup.string().required(),
});

<Form
  initialValues={{
    hello: ""
  }}
  onSubmit={values => alert(JSON.stringify(values))}
  validationSchema={schema}
>
  <Field name="hello" type="text" label="Hello" />
  {/* ... */}
</Form>
// ...

Props

  • initialValues: Object. Required. Object of values to initialize the form components with by name.
  • onSubmit: Function. Required. Action to perform on form submit.
  • onReset: Function. Optional. Action to perform on form reset.
  • initialStatus: any. Optional. Arbitrary value for the status of the form.
  • initialErrors: Object. Optional. Errors to show initially by name.
  • initialTouched: Object. Optional. Initially touched fields by name.
  • validationSchema: Object (yup preferred). Optional. Validation object for each name in the data.
  • validate: Function. Optional. Returns a true/false within a promise.
  • children: Node. Optional. Child components to render within the form

Input

Basic Input field that utilizes the Form validation

Usage

<Form
  initialValues={{
    hello: ""
  }}
  onSubmit={values => alert(JSON.stringify(values))}
  validationSchema={schema}
>
  <Input name="hello" />
  {/* ... */}
</Form>

Props

  • name: String. Required. Identifies the field and matches the validation key.
  • tag: Function or String. Optional. Return the Node or tag to substitute as the input field. Defaults to reactstrap Input.
  • className: String. Optional. Class names to pass down to the input.

Field

Input field wrapped in additional features such as label, feedback, grid options, etc

Usage

<Form
  initialValues={{
    hello: ""
  }}
  onSubmit={values => alert(JSON.stringify(values))}
  validationSchema={schema}
>
  <Field name="hello" label="Greeting"  />
  {/* ... */}
</Form>

Props

  • name: String. Required. Identifies the field and matches.
  • tag: Function or String. Optional. Return the Node or tag to substitute as the input field. Defaults to reactstrap Input.
  • label: Node or String. Optional. Displays a label for the field if defined.
  • labelHidden: Boolean. Optional. Hide the label.
  • disabled: Boolean. Optional. Disable the field.
  • readOnly: Boolean. Optional. Mark the field as readOnly.
  • size: String. Optional. Size of the input field (lg/sm)
  • inputClass: String. Optional. Class names passed to the input.
  • labelClass: String. Optional. Class names passed to the label.
  • helpMessage: String or Object. Optional. Displays info text below the field if defined.
  • errorMessage: String or Object. Optional. Pass the error message to show.
  • labelAttrs: Object. Optional. Pass additional attributes to the label component.
  • groupAttrs: Object. Optional. Pass additional attributes to the form group component.
  • grid: Object. Optional. Object mapping number of columns to the label and input.

Checkbox

Inputs of type checkbox. Checkboxes should be wrapped in a CheckboxGroup

Usage

<Form
  initialValues={{
    hello: [],
  }}
  onSubmit={() => {}}
  validationSchema={yup.object().shape({
    hello: yup.array().required('At least one checkbox is required'),
  })}
>
  <CheckboxGroup name="hello" label="Checkbox Group">
    <Checkbox label="Check One" value="uno" />
    <Checkbox label="Check Two" value="dos" />
    <Checkbox label="Check Three" value="tres" />
  </CheckboxGroup>
  <Button type="submit">Submit</Button>
</Form>

CheckboxGroup Props

  • name: String. Optional. Should match checkbox id for validation.
  • children: Node. Optional. Child components to render, use Checkboxes.
  • label: String. Optional. Label for the group of checkboxes.

Checkbox Props

  • id: String. Optional. Should match checkboxGroup name for validation.
  • label: String. Optional. Label to render for this checkbox.
  • value: String. Optional. Value of the checkbox.
  • disabled: Boolean. Optional. Disable the checkbox.
  • className: String. Optional. Class names for the checkboxes.

Radio

Inputs of type radio. Radios should be wrapped in a RadioGroup.

Usage

<Form
  initialValues={{
    hello: '',
  }}
  onSubmit={() => {}}
  validationSchema={yup.object().shape({
    hello: yup.string().required('This field is required'),
  })}
>
  <RadioGroup name="hello" label="Radio Group">
    <Radio label="Radio One" value="uno" />
    <Radio label="Radio Two" value="dos" />
    <Radio label="Radio Three" value="tres" />
  </RadioGroup>
  <Button type="submit">Submit</Button>
</Form>

RadioGroup Props

  • name: String. Optional. Should match radio id for validation.
  • children: Node. Optional. Child components to render, use Radios.
  • label: String. Optional. Label for the group of radio buttons.

Radio Props

  • id: String. Optional. Should match radioGroup name for validation.
  • label: String. Optional. Label to render for this radio button.
  • value: String. Optional. Value of the radio button.
  • disabled: Boolean. Optional. Disable the radio button.
  • className: String. Optional. Class names for the radio buttons.

FormGroup

Wrapper for an Input field. Uses reactstrap FormGroup.

Usage

<Form
  initialValues={{
    hello: '',
  }}
  onSubmit={() => ({})}
  validationSchema={yup.object().shape({
    hello: yup.string().required(),
  })}
 >
  <FormGroup for="hello">
    <Input name="hello"/>
  </FormGroup>
</Form>

FormGroup Props

  • className: String. Optional. Class names to pass.
  • for: String. Optional. Used to match the wrapped input.

Feedback

Error message container for an input.

Usage

<Form
  initialValues={{
    hello: '',
  }}
  onSubmit={() => ({})}
  validationSchema={yup.object().shape({
    hello: yup.string().required('Oops'),
  })}
>
  <Input name="hello" />
  <Feedback name="hello" />
</Form>

Props

  • name: String. Optional. Name used to match the validation schema to the message.
1.9.0

7 days ago

1.8.1

3 months ago

1.8.0

6 months ago

1.7.6

6 months ago

1.7.5

7 months ago

1.7.4

9 months ago

1.7.3

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

2 years ago

1.5.3-alpha.0

2 years ago

1.6.0

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.4.1-alpha.0

2 years ago

1.4.1-alpha.1

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.3.1

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.4-ts.13

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

0.9.0

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.8.0

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.34

3 years ago

0.5.33

3 years ago

0.5.32

3 years ago

0.5.31

4 years ago

0.4.10-alpha.54

4 years ago

0.4.10-alpha.50

4 years ago

0.4.10-alpha.51

4 years ago

0.4.10-alpha.48

4 years ago

0.4.10-alpha.46

4 years ago

0.4.10-alpha.43

4 years ago

0.5.30

4 years ago

0.4.10-alpha.40

4 years ago

0.5.29

4 years ago

0.5.28

4 years ago

0.5.27

4 years ago

0.5.26

4 years ago

0.5.25

4 years ago

0.5.24

4 years ago

0.5.23

4 years ago

0.5.22

4 years ago

0.5.21

4 years ago

0.5.20

4 years ago

0.5.19

4 years ago

0.5.18

4 years ago

0.5.17

4 years ago

0.5.16

4 years ago

0.5.14

4 years ago

0.5.15

4 years ago

0.5.13

4 years ago

0.5.11

4 years ago

0.5.12

4 years ago

0.5.10

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

1.0.0-alpha.29

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1-alpha.571

5 years ago

0.1.1-alpha.548

5 years ago