Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 0d0f51b

Browse files
committed
Merge branch 'master' of ssh://github.com/davidkpiano/react-redux-form
2 parents eb18aa8 + 6c00ea4 commit 0d0f51b

File tree

6 files changed

+130
-123
lines changed

6 files changed

+130
-123
lines changed

docs/api/Control.md

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
{% raw %}
21
# Control Component
32

43
**Prop Types**
5-
- [`model` (required)](#prop-model)
6-
- [`mapProps`](#prop-mapProps)
7-
- [`updateOn`](#prop-updateOn)
8-
- [`defaultValue`](#prop-defaultValue)
9-
- [`debounce`](#prop-debounce)
10-
- [`validators`](#prop-validators)
11-
- [`validateOn`](#prop-validateOn)
12-
- [`asyncValidators`](#prop-asyncValidators)
13-
- [`asyncValidateOn`](#prop-asyncValidateOn)
14-
- [`errors`](#prop-errors)
15-
- [`parser`](#prop-parser)
16-
- [`changeAction`](#prop-changeAction)
17-
- [`controlProps`](#prop-controlProps)
18-
- [`component`](#prop-component)
19-
- [`ignore`](#prop-ignore)
20-
- [`disabled`](#prop-disabled)
21-
- [`getRef`](#prop-getRef)
22-
- [`persist`](#prop-persist)
23-
- [`getValue`](#prop-getValue)
24-
- [`isToggle`](#prop-isToggle)
4+
- [`model` (required)](#model-required)
5+
- [`mapProps`](#mapprops)
6+
- [`updateOn`](#updateon)
7+
- [`defaultValue`](#defaultvalue)
8+
- [`validators`](#validators)
9+
- [`debounce`](#debounce)
10+
- [`validateOn`](#validateon)
11+
- [`asyncValidators`](#asyncvalidators)
12+
- [`asyncValidateOn`](#asyncvalidateon)
13+
- [`errors`](#errors)
14+
- [`parser`](#parser--)
15+
- [`changeAction`](#changeaction--)
16+
- [`controlProps`](#controlprops)
17+
- [`component`](#component)
18+
- [`ignore`](#ignore)
19+
- [`disabled`](#disabled)
20+
- [`getRef`](#getref--)
21+
- [`persist`](#persistfalse)
22+
- [`getValue`](#getvalueevent-props--)
23+
- [`isToggle`](#istogglefalse)
24+
- [`withFieldValue`](#withfieldvaluefalse)
2525

2626
## `<Control>`
2727

@@ -76,7 +76,7 @@ export default App; // no need to connect
7676

7777
# Prop Types
7878

79-
## `model="..."` (required) {#prop-model}
79+
## `model="..."` (required)
8080

8181
_(String | Function)_: The string representing the model value in the store.
8282
```jsx
@@ -92,7 +92,7 @@ export default createStore(combineForms({
9292

9393
It can also be a function that returns a string model. See [the documentation on tracking](../guides/tracking.md) for more information.
9494

95-
## `mapProps={{...}}` {#prop-mapProps}
95+
## `mapProps={{...}}`
9696
_(Object | Function)_: A custom mapping from props provided by `Control` to props received by the component. Can be:
9797

9898
- An object, where each value is a function from original props to corresponding value in result props.
@@ -114,7 +114,7 @@ Examples:
114114

115115
See [the documentation on custom controls](../guides/custom-controls.md) for more information.
116116

117-
## `updateOn="..."` {#prop-updateOn}
117+
## `updateOn="..."`
118118
_(String | Array)_: A string/array of strings specifying when the component should dispatch a `change(...)` action, with one of these values:
119119

120120
- `"change"` - will dispatch in `onChange`
@@ -128,13 +128,13 @@ You can also specify `updateOn={['change', 'blur']}` as an array of one or more
128128
### Notes
129129
- Use the `changeAction` prop if you want to dispatch custom actions along with the `actions.change(...)` action.
130130

131-
## `defaultValue="..."` {#prop-defaultValue}
131+
## `defaultValue="..."`
132132
_(Any)_: Sets the default value for the control. `boolean` for checkboxes, `string` for text input/textarea etc.
133133

134134
### Notes
135135
- https://github.com/davidkpiano/react-redux-form/issues/631
136136

137-
## `validators={{...}}` {#prop-validators}
137+
## `validators={{...}}`
138138
_(Object)_: A map where the keys are validation keys, and the values are the corresponding functions that determine the validity of each key, given the model's value.
139139

140140
For example, this control validates that a username exists and is longer than 4 characters:
@@ -162,10 +162,10 @@ const length = (val) => val.length > 8;
162162
/>
163163
```
164164

165-
## `debounce={...}` {#prop-debounce}
165+
## `debounce={...}`
166166
_(Number)_: The time in milliseconds, by which the change action will be debounced.
167167

168-
## `validateOn="..."` {#prop-validateOn}
168+
## `validateOn="..."`
169169
_(String | Array)_: A string/array of strings specifying when validation should occur. By default, validation happens with whatever `updateOn` is set to. The `validateOn` property can have these values:
170170
- `"change"` - validate on the `onChange` event handler
171171
- `"blur"` - validate on the `onBlur` event handler
@@ -175,7 +175,7 @@ _(String | Array)_: A string/array of strings specifying when validation should
175175
- Validation will always occur **on load**; i.e., when the component is mounted. This is to ensure an accurate validation state for a new form.
176176
- To avoid displaying error messages on load (as controls might be invalid), use the `.pristine` property of the control when conditionally showing error messages, or use the `<Errors>` component.
177177

178-
## `asyncValidators={{...}}` {#prop-asyncValidators}
178+
## `asyncValidators={{...}}`
179179
_(Object)_: A map where the keys are validation keys, and the values are the corresponding functions that (asynchronously) determine the validity of each key, given the model's value.
180180

181181
Each async validator function is called with 2 arguments:
@@ -200,13 +200,13 @@ import isAvailable from '../path/to/is-available';
200200
### Notes
201201
- Async validators will run on `blur`, unless you specify otherwise in the `asyncValidateOn="..."` prop.
202202

203-
## `asyncValidateOn="..."` {#prop-asyncValidateOn}
203+
## `asyncValidateOn="..."`
204204
_(String | Array)_: A string/array of strings specifying when async validation should occur. By default, validation happens on `"blur"`. The `asyncValidateOn` property can have these values:
205205
- `"change"` - validate on the `onChange` event handler
206206
- `"blur"` (default) - validate on the `onBlur` event handler
207207
- `"focus"` - validate on the `onFocus` event handler
208208

209-
## `errors={{...}}` {#prop-errors}
209+
## `errors={{...}}`
210210
_(Object)_: A map where the keys are error keys, and the values are the corresponding error validator functions that determine the invalidity of each key, given the model's value.
211211

212212
An **error validator** is a function that returns `true` or a truthy value (such as a string) if invalid, and `false` if valid.
@@ -223,7 +223,7 @@ For example, this control validates that a username exists and is longer than 4
223223
/>
224224
```
225225

226-
## `parser={() => ...}` {#prop-parser}
226+
## `parser={() => ...}`
227227
_(Function)_: A function that _parses_ the view value of the control before it is changed. It takes in one argument:
228228
- `value` - the view value that represents the _next_ model value
229229

@@ -240,7 +240,7 @@ function toAge(value) {
240240
>
241241
```
242242

243-
## `changeAction={() => ...}` {#prop-changeAction}
243+
## `changeAction={() => ...}`
244244
An action creator (function) that specifies which action the `<Control>` component should use when dispatching a change to the model. For example, this action is similar to:
245245

246246
- `actions.change(model, value)` for text input controls
@@ -281,7 +281,7 @@ function changeAndSubmit(model, value) {
281281
- Use `changeAction` to do any other custom actions whenever your value is to change.
282282
- Since `changeAction` expects an action creator and `redux-thunk` is used, you can asynchronously dispatch actions (like the example above).
283283

284-
## `controlProps={{...}}` {#prop-controlProps}
284+
## `controlProps={{...}}`
285285
_(Object)_: A mapping of control-specific props that will be applied directly to the rendered control. In some cases, this can be a safer way of applying props, especially if there are naming conflicts between `<Control>`-specific props (such as `"model"`) and props that need to go on the rendered control (e.g., `<input {...props} />`).
286286

287287
The normal behavior is that any extraneous props on `<Control>` that are not part of `Control.propTypes` (which are documented here) will be given to the rendered input.
@@ -297,7 +297,7 @@ Example:
297297
/>
298298
```
299299

300-
## `component={...}` {#prop-component}
300+
## `component={...}`
301301
_(Function | String | Node)_: A custom component can be passed into the `component={...}` prop, and standard control props and event handlers (such as `onChange`, `onBlur`, `onFocus`, `value`, etc.) will be mapped as expected:
302302

303303
```jsx
@@ -312,7 +312,7 @@ const MyTextInput = (props) => <input className="my-input" {...props} />;
312312
/>
313313
```
314314

315-
## `ignore={[...]}` {#prop-ignore}
315+
## `ignore={[...]}`
316316
_(String | Array)_: The event(s) that you want the `<Control>` to ignore. This can be good for performance and/or for de-cluttering the console log.
317317

318318
For instance, if you don't care whether a `<Control>` is focused or blurred:
@@ -325,7 +325,7 @@ For instance, if you don't care whether a `<Control>` is focused or blurred:
325325
/>
326326
```
327327

328-
## `disabled={...}` {#prop-disabled}
328+
## `disabled={...}`
329329
_(Any)_: The `disabled` prop works just like you'd expect for controls that support the HTML5 `disabled` attribute.
330330

331331
However, in `<Control>`, it can be a boolean, or a function, string, or object as a [Lodash iteratee](https://lodash.com/docs#iteratee).
@@ -348,7 +348,7 @@ For example:
348348

349349
(since: version 1.3.0)
350350

351-
## `getRef={() => ...}` {#prop-getRef}
351+
## `getRef={() => ...}`
352352
_(Function)_: Calls the callback provided to the `getRef` prop with the node instance. Similar to `ref`.
353353

354354
```jsx
@@ -358,7 +358,7 @@ _(Function)_: Calls the callback provided to the `getRef` prop with the node ins
358358
/>
359359
```
360360

361-
## `persist={false}` {#prop-persist}
361+
## `persist={false}`
362362
_(Boolean)_: Signifies that the field state (validation, etc.) should not persist when the component is unmounted. Default: `false`
363363

364364
```jsx
@@ -372,7 +372,7 @@ _(Boolean)_: Signifies that the field state (validation, etc.) should not persis
372372
/>
373373
```
374374

375-
## `getValue={(event, props) => ...}` {#prop-getValue}
375+
## `getValue={(event, props) => ...}`
376376
_(Function)_: Determines the value given the `event` (from `onChange`) and optionally the control component's `props`.
377377

378378
By default, the `getValue` function returns the value by checking if the `event` is a DOM event.
@@ -390,13 +390,12 @@ For `<Control.checkbox />`, the default `getValue` function is:
390390
/>
391391
```
392392

393-
## `isToggle={false}` {#prop-isToggle}
393+
## `isToggle={false}`
394394
_(Boolean)_: Signifies that the control is a toggle (e.g., a checkbox or a radio). If `true`, then some optimizations are made.
395395

396396
Default: `true` for `<Control.radio>` and `<Control.checkbox>`, `false` for all other controls.
397397

398-
## `withFieldValue={false}` {#prop-withFieldValue}
398+
## `withFieldValue={false}`
399399
_(Boolean)_: When `true` the `fieldValue` prop is mapped on to the child component. This prop contains information about the field's state such as its validity and whether it has been touched. This is particularly useful when using a custom component as it allows you to dynamically alter the component based on the field's state.
400400

401401
Default: `false`
402-
{% endraw %}

docs/api/Errors.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% raw %}
21
# Errors Component
32

43
## `<Errors />`
@@ -120,4 +119,3 @@ _(String | Function | Element)_: The `component`, which is the component for eac
120119
- `fieldValue` - the current field state of the `model`
121120
- `children` - the error message (text).
122121
- `component={CustomError}` will wrap the error in a `<CustomError>` component, which will receive the same props as above.
123-
{% endraw %}

0 commit comments

Comments
 (0)