Skip to content

Commit d2dbdb8

Browse files
committed
Fixed docs
1 parent 919fd1e commit d2dbdb8

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,23 @@ const undecorate = decorator(form)
6363

6464
## API
6565

66-
### `createDecorator
66+
### `createDecorator: (...calculations: Calculation[]): Decorator`
6767

68-
### `form.mutators.setFieldData(name: string, values: Object) => void`
68+
A function that takes a set of calculations and returns a 🏁 Final Form
69+
[`Decorator`](https://github.com/final-form/final-form#decorator-form-formapi--unsubscribe).
6970

70-
Merges the values provided into the `data` value for the specified field
71+
## Types
72+
73+
### `Calculation: { field: FieldPattern, updates: Updates }`
74+
75+
A calculation to perform
76+
77+
### `FieldName: string`
78+
79+
### `FieldPattern: FieldName | RegExp`
80+
81+
A pattern to match a field with.
82+
83+
### `Updates: { [FieldName]: (value: any, allValues: Object) => any }`
84+
85+
Updates to make on other fields.

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"name": "final-form-calculate",
33
"version": "1.0.0",
4-
"description": "Mutator for setting arbitrary metadata on fields in 🏁 Final Form",
4+
"description":
5+
"Decorator for calculating field values based on other field values in 🏁 Final Form",
56
"main": "dist/final-form-calculate.cjs.js",
67
"jsnext:main": "dist/final-form-calculate.es.js",
78
"module": "dist/final-form-calculate.es.js",
8-
"files": [
9-
"dist"
10-
],
9+
"files": ["dist"],
1110
"scripts": {
1211
"start": "nps",
1312
"test": "nps test",
1413
"precommit": "lint-staged && npm start validate"
1514
},
16-
"author": "Erik Rasmussen <[email protected]> (http://github.com/erikras)",
15+
"author":
16+
"Erik Rasmussen <[email protected]> (http://github.com/erikras)",
1717
"license": "MIT",
1818
"repository": {
1919
"type": "git",
@@ -61,10 +61,7 @@
6161
"final-form": "^1.3.0"
6262
},
6363
"lint-staged": {
64-
"*.{js,json,md,css}": [
65-
"prettier --write",
66-
"git add"
67-
]
64+
"*.{js,json,md,css}": ["prettier --write", "git add"]
6865
},
6966
"bundlesize": [
7067
{

src/decorator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// @flow
22
import type { Decorator, FormApi } from 'final-form'
3-
import type { Calculations, Updates } from './types'
3+
import type { Calculation, Updates } from './types'
44
import { getIn } from 'final-form'
55

6-
const createDecorator = (...calculations: Calculations): Decorator => (
6+
const createDecorator = (...calculations: Calculation[]): Decorator => (
77
form: FormApi
88
) => {
99
let previousValues = {}

src/types.js.flow

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ export type Updates = {
55
[FieldName]: (value: any, allValues: Object) => any
66
}
77

8-
type Calculation = {
8+
export type Calculation = {
99
field: FieldPattern,
1010
updates: Updates
1111
}
12-
export type Calculations = Calculation[]

0 commit comments

Comments
 (0)