Skip to content

Commit

Permalink
Merge remote-tracking branch 'redux-form/master'
Browse files Browse the repository at this point in the history
* redux-form/master: (61 commits)
  Exported getFormNames (redux-form#2519)
  v6.5.0
  Do not set FieldArray as touched on submit, as it causes its entry in storeState.fields to become an object instead of an array. The ARRAY_* reducers expects the fields entry to be an array. Fixes redux-form#2014. (redux-form#2473)
  Chore/switch shallowequal to lodash isequalwith (redux-form#2506)
  Keep track of registration count in registeredFields (redux-form#2470)
  fix: when the Field type is "file", value can not be updated (redux-form#2452)
  Remove undocumented name, validate and warn from FieldArray props. (redux-form#2467)
  Clarify what to do when StackOverflow questions get no answers (redux-form#2497)
  Excluded tests from code climate
  Enable Code Climate (redux-form#2486)
  Update ConnectedFields cached handlers when names prop changes. Fixes bug introduced by redux-form#2161. (redux-form#2474)
  Breaking change: Change Fields names instance API to return FormSection prefixed names, to be consistent with Field and FieldArray. (redux-form#2464)
  Add initial value selector (redux-form#2460)
  Add more tests for validateIfNeeded & warnIfNeeded (redux-form#2450)
  Provide validation functions with access to form props (redux-form#2431)
  feat(initialize): add keepSubmitSucceeded option (redux-form#2426)
  Synced Immutable and plain exports (+ tests) (redux-form#2425)
  Choose getIn based off Iterable.isIterable() (redux-form#2423)
  Fixed redux-form#2444 unexpected value updates when radio lose focus (redux-form#2445)
  Beerpay badge
  ...
  • Loading branch information
selvagsz committed Feb 6, 2017
2 parents 48f2f71 + ba3b22e commit 68a00ea
Show file tree
Hide file tree
Showing 152 changed files with 4,110 additions and 1,109 deletions.
13 changes: 13 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
engines:
duplication:
enabled: false
config:
languages:
- javascript
eslint:
enabled: true
ratings:
paths:
- "**.js"
exclude_paths:
- "**.spec.js"
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: node_js

before_install:
- npm install -g npm@latest

node_js:
- "6"
- "5"
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Before opening an issue, please search the [issue tracker](https://github.com/er

For support or usage questions, please search and ask on [StackOverflow with a `redux-form` tag](https://stackoverflow.com/questions/tagged/redux-form). We ask you to do this because StackOverflow has a much better job at keeping popular questions visible. Unfortunately good answers get lost and outdated on GitHub.

**If you already asked at StackOverflow and still got no answers, post an issue with the question link, so we can either answer it or evolve into a bug/feature request.**

## Sending a pull request

For non-trivial changes, please open an issue with a proposal for a new feature or refactoring before starting on the work. We don’t want you to waste your efforts on a pull request that we won’t want to accept.
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

`redux-form` works with [React Redux](https://github.com/rackt/react-redux) to enable an html form in
[React](https://github.com/facebook/react) to use [Redux](https://github.com/rackt/redux) to store all of its state.
[![Beerpay](https://beerpay.io/erikras/redux-form/badge.svg)](https://beerpay.io/erikras/redux-form)

[<img src="logo.png" align="right" class="logo" height="151" width="250"/>](http://erikras.github.io/redux-form/)

Expand All @@ -20,12 +21,12 @@

## Documentation

* [Getting Started](https://redux-form.com/6.3.1/docs/GettingStarted.md/)
* [Examples](https://redux-form.com/6.3.1/examples/)
* [API](https://redux-form.com/6.3.1/docs/api/)
* [FAQ](https://redux-form.com/6.3.1/docs/faq/)
* [Getting Started](https://redux-form.com/6.5.0/docs/GettingStarted.md/)
* [Examples](https://redux-form.com/6.5.0/examples/)
* [API](https://redux-form.com/6.5.0/docs/api/)
* [FAQ](https://redux-form.com/6.5.0/docs/faq/)
* [Release Notes](https://github.com/erikras/redux-form/releases)
* [Older Documentation](https://redux-form.com/6.3.1/docs/DocumentationVersions.md/)
* [Older Documentation](https://redux-form.com/6.5.0/docs/DocumentationVersions.md/)

## Videos

Expand Down
5 changes: 5 additions & 0 deletions docs/DocumentationVersions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Documentation Versions

* [6.5.0](https://redux-form.com/6.5.0/)
* [6.4.3](https://redux-form.com/6.4.3/)
* [6.4.2](https://redux-form.com/6.4.2/)
* [6.4.1](https://redux-form.com/6.4.1/)
* [6.4.0](https://redux-form.com/6.4.0/)
* [6.3.1](https://redux-form.com/6.3.1/)
* [6.3.0](https://redux-form.com/6.3.0/)
* [6.2.1](https://redux-form.com/6.2.1/)
Expand Down
2 changes: 1 addition & 1 deletion docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ class ContactPage extends React.Component {

If you're starting out with `redux-form`, a good place to continue learning about how to connect
up the inputs to `redux-form` would be the
[Simple Form Example](https://redux-form.com/6.3.1/examples/simple).
[Simple Form Example](https://redux-form.com/6.5.0/examples/simple).
4 changes: 2 additions & 2 deletions docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ const upper = value => value && value.toUpperCase()
<Field name="myUppercaseField" component="input" normalize={upper}/>
```

See the [Normalizing Example](https://redux-form.com/6.3.1/examples/normalizing/) and
[Value Lifecycle](https://redux-form.com/6.3.1/docs/ValueLifecycle.md/) for
See the [Normalizing Example](https://redux-form.com/6.5.0/examples/normalizing/) and
[Value Lifecycle](https://redux-form.com/6.5.0/docs/ValueLifecycle.md/) for
more details.

## Listening to other actions
Expand Down
12 changes: 9 additions & 3 deletions docs/api/ActionCreators.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ insert, so the item already at the `to` position will be bumped to a higher inde

> Marks the given field as `active` and `visited`.
### `initialize(form:String, data:Object, keepDirty:boolean)`
### `initialize(form:String, data:Object, [keepDirty:boolean], [options:{keepDirty:boolean, keepSubmitSucceeded:boolean}])`

> Sets the initial values in the form with which future data values will be compared to calculate
`dirty` and `pristine`. The `data` parameter may contain deep nested array and object values that match the shape of
your form fields. If the `keepDirty` parameter is `true`, the values of currently dirty fields will be retained
to avoid overwriting user edits.
your form fields.

> If the `keepDirty` parameter is `true`, the values of currently dirty fields will be retained
to avoid overwriting user edits. (`keepDirty` can appear as either the third argument, or a property of `options` as
the 3rd or 4th argument, for the sake of backwards compatibility).

> If the `keepSubmitSucceeded` parameter is `true`,
it will not clear the `submitSucceeded` flag if it is set.

### `registerField(form:String, name:String, type:String)`

Expand Down
63 changes: 52 additions & 11 deletions docs/api/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ A string path, in dot-and-bracket notation, corresponding to a value in the form
be as simple as `'firstName'` or as complicated as
`contact.billing.address[2].phones[1].areaCode`. See the [Usage](#usage) section below for details.

Numeric field names, e.g. `name="42"` or `name="foo.5.email`, are not supported, as they can
be confused for array indexes.

#### `component : Component|Function|String` [required]

A `Component`, stateless function, or string corresponding to a default JSX element.
Expand Down Expand Up @@ -72,13 +75,41 @@ would pass `value => value.toUpperCase()`. The parameters to your normalize func
> All the values in the entire form before the current change. This will be an Immutable `Map` if
> you are using Immutable JS.
#### `onBlur : (event, newValue, previousValue) => void` [optional]

A callback that will be called whenever an `onBlur` event is fired from the underlying input.
If you call `event.preventDefault()`, the `BLUR` action will _NOT_ be dispatched, and the value
and focus state will not be updated in the Redux store.

#### `onChange : (event, newValue, previousValue) => void` [optional]

A callback that will be called whenever an `onChange` event is fired from the underlying input.
If you call `event.preventDefault()`, the `CHANGE` action will _NOT_ be dispatched, and the value
will not be updated in the Redux store.

#### `onDragStart : (event) => void` [optional]

A callback that will be called whenever an `onDragStart` event is fired from the underlying input.

#### `onDrop : (event, newValue, previousValue) => void` [optional]

A callback that will be called whenever an `onDrop` event is fired from the underlying input.
If you call `event.preventDefault()`, the `CHANGE` action will _NOT_ be dispatched, and the value
will not be updated in the Redux store.

#### `onFocus : (event) => void` [optional]

A callback that will be called whenever an `onFocus` event is fired from the underlying input.
If you call `event.preventDefault()`, the `FOCUS` action will _NOT_ be dispatched, and
the focus state will not be updated in the Redux store.

#### `props : object` [optional]

Object with custom props to pass through the `Field` component into a component provided
to `component` prop. This props will be merged to props provided by `Field` itself. This _may_ be
useful if you are using TypeScript. This construct is completely optional; the primary way of
passing props along to your `component` is to give them directly to the `Field` component, but
if, for whatever reason, you prefer to bundle them into a separate object, you may do so by
useful if you are using TypeScript. This construct is completely optional; the primary way of
passing props along to your `component` is to give them directly to the `Field` component, but
if, for whatever reason, you prefer to bundle them into a separate object, you may do so by
passing them into `props`.

#### `parse : (value, name) => parsedValue` [optional]
Expand All @@ -90,13 +121,13 @@ localized date formats into `Date`s.
`parse` is called with the field `value` and `name` as arguments and should return the new
parsed value to be stored in the Redux store.

#### `validate : (value, allValues) => error` [optional]
#### `validate : (value, allValues, props) => error` [optional]

Allows you to to provide a field-level validation rule. The function will be given the current value of the field and all the other form values. If the field is valid, it should return `undefined`, if the field is invalid, it should return an error (usually, but not necessarily, a `String`).
Allows you to to provide a field-level validation rule. The function will be given the current value of the field, all the other form values, and any props passed to the form. If the field is valid, it should return `undefined`, if the field is invalid, it should return an error (usually, but not necessarily, a `String`).

#### `warn : (value, allValues) => warning` [optional]
#### `warn : (value, allValues, props) => warning` [optional]

Allows you to to provide a field-level warning rule. The function will be given the current value of the field and all the other form values. If the field needs a warning, it should return the warning (usually, but not necessarily, a `String`). If the field does not need a warning, it should return `undefined`.
Allows you to to provide a field-level warning rule. The function will be given the current value of the field, all the other form values, and any props passed to the form. If the field needs a warning, it should return the warning (usually, but not necessarily, a `String`). If the field does not need a warning, it should return `undefined`.

#### `withRef : boolean` [optional]

Expand Down Expand Up @@ -191,7 +222,8 @@ The following properties and methods are available on an instance of a `Field` c
#### `name : String`

> The `name` prop that you passed in.
> When nested in `FormSection`, returns the `name` prop prefixed with the `FormSection` name.
Otherwise, returns the `name` prop that you passed in.

#### `pristine : boolean`

Expand Down Expand Up @@ -228,7 +260,8 @@ to be destructured into your `<input/>` component.
#### `input.name : String`

> The name prop passed in.
> When nested in `FormSection`, returns the `name` prop prefixed with the `FormSection` name.
Otherwise, returns the `name` prop that you passed in.

#### `input.onBlur(eventOrValue) : Function`

Expand Down Expand Up @@ -297,9 +330,9 @@ tracking for you.
> The error for this field if its value is not passing validation. Both synchronous,
> asynchronous, and submit validation errors will be reported here.
#### `meta.warning : String` [optional]
#### `meta.form : String`

> The warning for this field if its value is not passing warning validation.
> The name of the `form`. Could be useful if you want to manually dispatch actions.
#### `meta.invalid : boolean`

Expand All @@ -313,6 +346,10 @@ tracking for you.

> `true` if the field is currently being submitted
#### `meta.submitFailed : boolean`

> `true` if the form had `onSubmit` called and failed to submit _for any reason_. A subsequent successful submit will set it back to false.
#### `meta.touched : boolean`

> `true` if the field has been touched. By default this will be set when the field is blurred.
Expand All @@ -325,3 +362,7 @@ tracking for you.

> `true` if this field has ever had focus. It will only work if you are passing `onFocus` to
> your input element.
#### `meta.warning : String` [optional]

> The warning for this field if its value is not passing warning validation.
16 changes: 11 additions & 5 deletions docs/api/FieldArray.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ be as simple as `'firstName'` or as complicated as

A `Component` or stateless function to render the field array.

#### `validate : (value, allValues) => error` [optional]
#### `validate : (value, allValues, props) => error` [optional]

Allows you to to provide a field-level validation rule. The function will be given the current value of the array field and all the other form values. If the array is valid, it should return `undefined`, if the array is invalid, it should return an error (usually, but not necessarily, a `String`).
Allows you to to provide a field-level validation rule. The function will be given the current value of the array field, all the other form values, and any props passed to the form. If the array is valid, it should return `undefined`, if the array is invalid, it should return an error (usually, but not necessarily, a `String`).

#### `warn : (value, allValues) => warning` [optional]
#### `warn : (value, allValues, props) => warning` [optional]

Allows you to to provide a field-level warning rule. The function will be given the current value of the array and all the other form values. If the array needs a warning, it should return the warning (usually, but not necessarily, a `String`). If the array does not need a warning, it should return `undefined`.
Allows you to to provide a field-level warning rule. The function will be given the current value of the array field, all the other form values, and any props passed to the form. If the array needs a warning, it should return the warning (usually, but not necessarily, a `String`). If the array does not need a warning, it should return `undefined`.

#### `withRef : boolean` [optional]

Expand All @@ -54,7 +54,8 @@ The following properties and methods are available on an instance of a `FieldArr

#### `name : String`

> The `name` prop that you passed in.
> When nested in `FormSection`, returns the `name` prop prefixed with the `FormSection` name.
Otherwise, returns the `name` prop that you passed in.

#### `valid : boolean`

Expand All @@ -78,6 +79,11 @@ object, alongside `fields` and `meta`.
The `fields` object is a "pseudo-array", in that it has many of the same properties and methods
as a javascript `Array`, providing both reading and writing functionality.

#### `fields.name : Function`

> When nested in `FormSection`, returns the `name` prop prefixed with the `FormSection` name.
Otherwise, returns the `name` prop that you passed in.

#### `fields.forEach(callback) : Function`

> A method to iterate over each value of the array. See the section on [Iteration](#iteration)
Expand Down
5 changes: 3 additions & 2 deletions docs/api/Fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ The following properties and methods are available on an instance of a `Field` c

#### `names : Array<String>`

> The `names` prop that you passed in.
> When nested in `FormSection`, returns the `names` prop prefixed with the `FormSection` name.
Otherwise, returns a copy of the `names` prop that you passed in.

#### `pristine : boolean`

Expand All @@ -148,7 +149,7 @@ For example, if your `names` are `[ 'name.first', 'name.last', 'email' ]`, the `
## Props

The props that `Fields` will pass to your component are [the same `input` and `meta` structures
that `Field` generates](https://redux-form.com/6.3.1/docs/api/Field.md/#props), except that
that `Field` generates](https://redux-form.com/6.5.0/docs/api/Field.md/#props), except that
they are broken up into the structure of the fields you gave as `names`.

Any additional props that you pass to `Field` will be included at the root of the props structure
Expand Down
35 changes: 35 additions & 0 deletions docs/api/Form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# `Form`

The `Form` component is a simple wrapper for the React `<form>` component that allows
the surrounding `redux-form`-decorated component to trigger its `onSubmit` function.

It is only useful if you are:

- performing your submission from inside your form component by passing
`onSubmit={this.props.handleSubmit(this.mySubmitFunction)}` to your `<form>`
component
- **AND EITHER:**
- initiating your submission via the [`submit()` Instance API](http://redux-form.com/6.5.0/docs/api/ReduxForm.md/#-submit-promise-) (i.e. calling it directly on a reference to your decorated form component)
- initiating your submission by [dispatching the `submit(form)` action](http://redux-form.com/6.5.0/examples/remoteSubmit/)

If you are passing in your `onSubmit` function as a config parameter or prop, this component will do nothing for you.

## Importing

```javascript
var Form = require('redux-form').Form; // ES5
```
```javascript
import { Form } from 'redux-form'; // ES6
```
## Props you can pass to `Form`

Any that you can pass to `<form>`, but only one is required.

### `onSubmit : Function` [required]

> The function to call when form submission is triggered.
## Usage

All you do is replace your `<form>` with `<Form>`.
9 changes: 9 additions & 0 deletions docs/api/FormSection.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ It does this by prefixing the name of `Field`, `Fields` and `FieldArray` childre

> The name all child fields should be prefixed with.
### `component : String | Component` [optional]

> If you give `FormSection` more than one child element, it will be forced to create a component
to wrap them with. You can specify what type of component you would like it to be (`div`,
`section`, `span`). Defaults to `'div'`.

> Note that any additional props (e.g. 'className', 'style') that you pass to `FormSection` will be
passed along to the wrapper component.

## Example usage

An example use case for `FormSection` is an order form where it's possible to have enter the details of a buyer and a separate recipient.
Expand Down
4 changes: 2 additions & 2 deletions docs/api/FormValueSelector.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { formValueSelector } from 'redux-form'; // ES6
### `form : String` [required]

> The name of the form you are connecting to. Must be the same as the `form` config value you
gave to [`reduxForm()`](https://redux-form.com/6.3.1/docs/api/ReduxForm.md/).
gave to [`reduxForm()`](https://redux-form.com/6.5.0/docs/api/ReduxForm.md/).

### `getFormState : Function` [optional]

Expand Down Expand Up @@ -105,4 +105,4 @@ connect(
## Example

See the
[Selecting Form Values](https://redux-form.com/6.3.1/examples/selectingFormValues/) example.
[Selecting Form Values](https://redux-form.com/6.5.0/examples/selectingFormValues/) example.
2 changes: 1 addition & 1 deletion docs/api/Props.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> The `props` listed on this page are the `props` that `redux-form` generates to give
to your decorated form component. The `props` that _you pass into your wrapped component_ are
listed [here](https://redux-form.com/6.3.1/docs/api/ReduxForm.md/).
listed [here](https://redux-form.com/6.5.0/docs/api/ReduxForm.md/).

> If you are a strict `PropTypes` completionist, `redux-form` exports all of these
[`propTypes`](https://github.com/erikras/redux-form/blob/master/src/propTypes.js),
Expand Down
17 changes: 17 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@
---

## [`FormSection`](FormSection.md)

> The component needed to prefix the names of a group of fields.
> [`View source on GitHub`](https://github.com/erikras/redux-form/blob/master/src/FormSection.js)
---

## [`Form`](Form.md)

> A simple wrapper for the React `<form>` component that allows
the surrounding `redux-form`-decorated component to trigger its `onSubmit` function.

> [`View source on GitHub`](https://github.com/erikras/redux-form/blob/master/src/Form.js)
---

## [`formValueSelector(form:String, [getFormState:Function])`](FormValueSelector.md)

> Creates a selector for use in `connect()`ing to form values in the Redux store.
Expand Down

0 comments on commit 68a00ea

Please sign in to comment.