4.0.0 • Published 6 years ago

react-fractal-field v4.0.0

Weekly downloads
32
License
MIT
Repository
github
Last release
6 years ago

npm npm Dependency Status devDependency Status peerDependency Status

react-fractal-field

$ npm install prop-types lodash react react-fractal-field --save

Usage

import { Field, FieldSet } from 'react-fractal-field';

const MyComponent = ({ onSubmit }) => (
  <FieldSet onSubmit={onSubmit} isolated>
    {({ triggerSubmit }) => (
      <div>
        <Field name="value">
          {({ control }) => (
            <div>
              <input {...control} type="text" />
            </div>
          )}
        </Field>
        <button onClick={triggerSubmit}>Submit</button>
      </div>
    )}
  </FieldSet>
)

API

common FieldSet/FieldList/Field props:

Field props:

  • normalize: Function - filter value before call onChange/onSubmit/validate callback
  • format: Function - filter value before rendering (or set value to child field). from outer format to inner format

Common FieldSet/FieldList/Field children function params:

  • triggerChange: Function - call when you want to trigger change field by some case
  • triggerReset: Function - call when you want to trigger submit, obvious
  • value: Any
  • touched: Boolean - true when field or some child field was changed once
  • pristine: Boolean - true when field or some child field was not changed once
  • submitted: Boolean - when this form/field of parent was submitted once
  • valid: Boolean - true if children and this field has no errors
  • invalid: Boolean - true if children and this field/children has errors
  • hasException: Boolean - true if children and this field/children has exceptions
  • error: Any - first error are not false, that returned from validate function
  • invalidChildren: Array - ids of closest children with errors
  • active: Boolean - true if field/children is focusing right now
  • activated: Boolean - true if field/children was focused once
  • form: Object - Props of closest isolated form (or field itself)

Common FieldSet/FieldList/Field children function params when props.form is true:

  • triggerSubmit: Function - call when you want to trigger submit, obvious
  • submitSuccess: Boolean - state of submitting
  • submitFailed: Boolean - state of submitting
  • submitting: Boolean - state of submit processing. in pending (if onSubmit returns the Promise object)
  • submitted: Boolean - true if form was submitted once
  • submittedTimes: Number - count of triggerSubmit calling
  • submitErrors - Any - payload of submitting

Field children function params

  • control: { value, onChange, onBlur, onFocus } - shortcut for putting it into control component (only for components without children fractal-fields)

FieldList children function params:

Remote api

  • triggerSubmit(id)
  • triggerChange(id)
  • onError(callback)
4.0.0

6 years ago

3.11.0

6 years ago

3.10.1

6 years ago

3.10.0

6 years ago

3.9.3

6 years ago

3.9.2

6 years ago

3.9.1

6 years ago

3.9.0

6 years ago

3.8.7

6 years ago

3.8.6

6 years ago

3.8.5

6 years ago

3.8.4

6 years ago

3.8.3

6 years ago

3.8.2

6 years ago

3.8.1

6 years ago

3.8.0

6 years ago

3.7.1

6 years ago

3.7.0

6 years ago

3.6.2

6 years ago

3.6.1

6 years ago

3.6.0

6 years ago

3.5.5

6 years ago

3.5.4

6 years ago

3.5.3

6 years ago

3.5.2

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.2.6

6 years ago

2.2.5

7 years ago

2.2.4

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago