Skip to content

Commit 7b37726

Browse files
committed
Migrated docs
1 parent 8fe4c0f commit 7b37726

File tree

3 files changed

+140
-97
lines changed

3 files changed

+140
-97
lines changed

README.md

+2-97
Original file line numberDiff line numberDiff line change
@@ -11,101 +11,6 @@ Mutators for updating array fields in
1111

1212
---
1313

14-
## Installation
14+
## [Getting Started](https://final-form.org/docs/final-form-arrays/getting-started)
1515

16-
```bash
17-
npm install --save final-form-arrays
18-
```
19-
20-
or
21-
22-
```bash
23-
yarn add final-form-arrays
24-
```
25-
26-
## Usage
27-
28-
```js
29-
import { createForm } from 'final-form'
30-
import arrayMutators from 'final-form-arrays'
31-
32-
// Create Form
33-
const form = createForm({
34-
mutators: { ...arrayMutators },
35-
onSubmit
36-
})
37-
38-
// push
39-
form.mutators.push('customers', { firstName: '', lastName: '' })
40-
41-
// pop
42-
const customer = form.mutators.pop('customers')
43-
```
44-
45-
## Table of Contents
46-
47-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
48-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
49-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
50-
51-
- [Mutators](#mutators)
52-
- [`form.mutators.concat(name: string, value: Array<any>) => void`](#formmutatorsconcatname-string-value-arrayany--void)
53-
- [`form.mutators.insert(name: string, index: number, value: any) => undefined`](#formmutatorsinsertname-string-index-number-value-any--undefined)
54-
- [`form.mutators.move(name: string, from: number, to: number) => undefined`](#formmutatorsmovename-string-from-number-to-number--undefined)
55-
- [`form.mutators.pop(name: string) => any`](#formmutatorspopname-string--any)
56-
- [`form.mutators.push(name: string, value: any) => void`](#formmutatorspushname-string-value-any--void)
57-
- [`form.mutators.remove(name: string, index: number) => any`](#formmutatorsremovename-string-index-number--any)
58-
- [`form.mutators.removeBatch(name: string, indexes: Array<number>) => undefined`](#formmutatorsremovebatchname-string-indexes-arraynumber--undefined)
59-
- [`form.mutators.shift(name: string) => any`](#formmutatorsshiftname-string--any)
60-
- [`form.mutators.swap(name: string, indexA: number, indexB: number) => void`](#formmutatorsswapname-string-indexa-number-indexb-number--void)
61-
- [`form.mutators.update(name: string, index: number, value: any) => void`](#formmutatorsupdatename-string-index-number-value-any--void)
62-
- [`form.mutators.unshift(name: string, value: any) => void`](#formmutatorsunshiftname-string-value-any--void)
63-
64-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
65-
66-
## Mutators
67-
68-
### `form.mutators.concat(name: string, value: Array<any>) => void`
69-
70-
Concatenates an array at the end of the array field.
71-
72-
### `form.mutators.insert(name: string, index: number, value: any) => undefined`
73-
74-
Inserts a value into the specified index of the array field.
75-
76-
### `form.mutators.move(name: string, from: number, to: number) => undefined`
77-
78-
Moves a value from one index to another index in the array field.
79-
80-
### `form.mutators.pop(name: string) => any`
81-
82-
Pops a value off the end of an array field. Returns the value.
83-
84-
### `form.mutators.push(name: string, value: any) => void`
85-
86-
Pushes a value onto the end of an array field.
87-
88-
### `form.mutators.remove(name: string, index: number) => any`
89-
90-
Removes a value from the specified index of the array field. Returns the removed
91-
value.
92-
93-
### `form.mutators.removeBatch(name: string, indexes: Array<number>) => undefined`
94-
95-
Removes the values at the specified indexes of the array field.
96-
97-
### `form.mutators.shift(name: string) => any`
98-
99-
Removes a value from the beginning of the array field. Returns the value.
100-
101-
### `form.mutators.swap(name: string, indexA: number, indexB: number) => void`
102-
103-
Swaps the position of two values in the array field.
104-
105-
### `form.mutators.update(name: string, index: number, value: any) => void`
106-
107-
Updates a value of the specified index of the array field.
108-
109-
### `form.mutators.unshift(name: string, value: any) => void`
110-
111-
Inserts a value onto the beginning of the array field.
16+
## [API](https://final-form.org/docs/final-form-arrays/api)

docs/api.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# This documentation is meant to be read on [final-form.org](https://final-form.org/docs/final-form-arrays/api). Links may not work on Github.com.
2+
3+
# API
4+
5+
This library provides the following Final Form [mutators](/docs/final-form/types/Mutator). They are intended to mimic the array mutations available [`Array.prototype`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype) in JavaScript.
6+
7+
The `name` argument always refers to the field to be mutated.
8+
9+
### `form.mutators.concat`
10+
11+
```ts
12+
(name: string, value: Array<any>) => void
13+
```
14+
15+
Concatenates an array at the end of the field array.
16+
17+
### `form.mutators.insert`
18+
19+
```ts
20+
(name: string, index: number, value: any) => void`
21+
```
22+
23+
Inserts a value into the specified index of the field array.
24+
25+
### `form.mutators.move`
26+
27+
```ts
28+
(name: string, from: number, to: number) => void
29+
```
30+
31+
Moves a value from one index to another index in the field array.
32+
33+
### `form.mutators.pop`
34+
35+
<!-- prettier-ignore -->
36+
```ts
37+
(name: string) => any
38+
```
39+
40+
Pops a value off the end of an field array. Returns the value.
41+
42+
### `form.mutators.push`
43+
44+
```ts
45+
(name: string, value: any) => void
46+
```
47+
48+
Pushes a value onto the end of an field array.
49+
50+
### `form.mutators.remove`
51+
52+
<!-- prettier-ignore -->
53+
```ts
54+
(name: string, index: number) => any
55+
```
56+
57+
Removes a value from the specified index of the field array. Returns the removed value.
58+
59+
### `form.mutators.removeBatch`
60+
61+
```ts
62+
(name: string, indexes: Array<number>) => void
63+
```
64+
65+
Removes the values at the specified indexes of the field array.
66+
67+
### `form.mutators.shift`
68+
69+
<!-- prettier-ignore -->
70+
```ts
71+
(name: string) => any
72+
```
73+
74+
Removes a value from the beginning of the field array. Returns the value.
75+
76+
### `form.mutators.swap`
77+
78+
```ts
79+
(name: string, indexA: number, indexB: number) => void
80+
```
81+
82+
Swaps the position of two values in the field array.
83+
84+
### `form.mutators.unshift`
85+
86+
```ts
87+
(name: string, value: any) => void
88+
```
89+
90+
Inserts a value onto the beginning of the field array.
91+
92+
### `form.mutators.update`
93+
94+
```ts
95+
(name: string, index: number, value: any) => void
96+
```
97+
98+
Updates a value of the specified index of the field array.

docs/getting-started.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This documentation is meant to be read on [final-form.org](https://final-form.org/docs/final-form-arrays/getting-started). Links may not work on Github.com.
2+
3+
# Getting Started
4+
5+
This library provides field array management functionality as a plugin [mutator](/docs/final-form/types/Mutator) to Final Form.
6+
7+
## Installation
8+
9+
```bash
10+
npm install --save final-form final-form-arrays
11+
```
12+
13+
or
14+
15+
```bash
16+
yarn add final-form final-form-arrays
17+
```
18+
19+
## Usage
20+
21+
```js
22+
import { createForm } from 'final-form'
23+
import arrayMutators from 'final-form-arrays'
24+
25+
// Create Form
26+
const form = createForm({
27+
mutators: { ...arrayMutators },
28+
onSubmit
29+
})
30+
31+
// push
32+
form.mutators.push('customers', { firstName: '', lastName: '' })
33+
34+
// pop
35+
const customer = form.mutators.pop('customers')
36+
```
37+
38+
## Mutators
39+
40+
Check out the [API](api) to see all the mutators provided.

0 commit comments

Comments
 (0)