Skip to content

Commit 7bca6b7

Browse files
authored
Merge pull request #209 from rvsia/next-docs
Make nextdocs consistent with master
2 parents 8702668 + 3fca6f4 commit 7bca6b7

File tree

19 files changed

+112
-41
lines changed

19 files changed

+112
-41
lines changed

packages/react-renderer-demo/src/app/pages/component-example.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,22 @@ class ComponentExample extends Component {
260260
);
261261
}
262262

263+
if (component === 'textarea'){
264+
return (
265+
<Grid item xs={ 12 } key={ name }>
266+
<TextField
267+
id={ name }
268+
label={ title }
269+
value={ this.state.variants[index].value || '' }
270+
onChange={ ({ target: { value }}) => this.handleExampleVariantChange(value, index) }
271+
margin="normal"
272+
fullWidth
273+
multiline
274+
/>
275+
</Grid>
276+
);
277+
}
278+
263279
return (
264280
<Grid item xs={ 12 } key={ name }>
265281
<FormGroup >

packages/react-renderer-demo/src/app/pages/renderer/component-api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Grid from '@material-ui/core/Grid'
2-
import Link from 'next/link';
2+
import RouterLink from 'next/link';
3+
import Link from '@material-ui/core/Link';
34

45
import ListOfContents from '../../src/helpers/list-of-contents';
56
import ExampleLink from '@docs/components/common/example-link';
@@ -52,7 +53,7 @@ All those components provides a shared group of props:
5253
|isRequired|boolean|Is the field required?|
5354
|isDisabled|boolean|Is the field disabled?|
5455
|isReadOnly|boolean|Is the field readOnly?|
55-
|initialValue|custom|There are two ways how to set initial values in the form: you can use either the <Link href="/renderer/renderer-api"><a>initialValues</a></Link> prop for the whole form or you can set the value in the schema for each field separately. For more information, please see [here](https://final-form.org/docs/react-final-form/types/FieldProps#initialvalue).|
56+
|initialValue|custom|There are two ways how to set initial values in the form: you can use either the <RouterLink href="/renderer/renderer-api"><Link>initialValues</Link></RouterLink> prop for the whole form or you can set the value in the schema for each field separately. For more information, please see [here](https://final-form.org/docs/react-final-form/types/FieldProps#initialvalue).|
5657

5758
#### Text field
5859

packages/react-renderer-demo/src/app/pages/renderer/component-mapping.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,13 @@ import { layoutComponents } from '@data-driven-forms/react-form-renderer';
3333
const layoutComponents = {
3434
[layoutComponents.FORM_WRAPPER]: 'FormWrapper',
3535
[layoutComponents.BUTTON]: 'Button',
36-
[layoutComponents.COL]: 'Col',
37-
[layoutComponents.FORM_GROUP]: 'FormGroup',
3836
[layoutComponents.BUTTON_GROUP]: 'ButtonGroup',
39-
[layoutComponents.ICON]: 'Icon',
40-
[layoutComponents.ARRAY_FIELD_WRAPPER]: 'ArrayFieldWrapper',
41-
[layoutComponents.HELP_BLOCK]: 'HelpBlock',
4237
[layoutComponents.TITLE]: 'Title',
4338
[layoutComponents.DESCRIPTION]: 'Description',
4439
}
4540
```
4641

47-
Required components are: `FORM_WRAPPER`, `BUTTON`, `COL`, `FORM_GROUP` and `BUTTON_GROUP`. The rest is used only if you use certain
42+
Required components are: `FORM_WRAPPER`, `BUTTON` and `BUTTON_GROUP`. The rest is used only if you use certain
4843
components in your schema.
4944

5045
Check the example below to see a simple implementation of layout components.
@@ -58,11 +53,6 @@ Check the example below to see a simple implementation of layout components.
5853
|----|----|-----------|-----|------------|
5954
|children|node|Content of the form||Based on form schema|
6055

61-
#### Col
62-
|Prop|Type|Description|Value|Customizable|
63-
|----|----|-----------|-----|------------|
64-
|children|node|Wrapper around form field||Based on form schema|
65-
6656
#### Button
6757
|Prop|Type|Description|Value|Customizable|
6858
|----|----|-----------|-----|------------|
@@ -75,14 +65,15 @@ Check the example below to see a simple implementation of layout components.
7565
|----|----|-----------|-----|------------|
7666
|children|node|Wrapper around form buttons||No|
7767

78-
#### FormGroup
79-
|Prop|Type|Description|Value|Customizable|
80-
|----|----|-----------|-----|------------|
81-
|children|node|Form field group||Based on form schema|
82-
83-
#### Icon, Array Field Wrapper, Help Block
84-
TO DO when array field docs are done
68+
#### Title
69+
|Prop|Type|Description|Customizable|
70+
|----|----|-----------|------------|
71+
|children|node|Form title|no|
8572

73+
#### Description
74+
|Prop|Type|Description|Customizable|
75+
|----|----|-----------|------------|
76+
|children|node|Form description|no|
8677

8778
## Creating formFieldsMapper
8879

@@ -106,6 +97,7 @@ const componentTypes = {
10697
[componentTypes.SWITCH]: 'switch-field',
10798
[componentTypes.TEXTAREA]: 'textarea-field',
10899
[componentTypes.SELECT]: 'select-field',
100+
[componentTypes.PLAIN_TEXT]: 'plain-text',
109101
}
110102
```
111103

packages/react-renderer-demo/src/app/pages/renderer/data-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ListOfContents from '../../src/helpers/list-of-contents';
99
## Introduction
1010

1111
You can specify a type of a component by providing `dataType`, which will automatically validates the component value.
12-
Because almost everything in html inputs is outputed as a string, adding the `dataType` props will also cast the value to given type.
12+
Because almost everything in HTML inputs is outputed as a string, adding the `dataType` props will also cast the value to given type.
1313

1414
### Available dataTypes
1515

packages/react-renderer-demo/src/app/pages/renderer/development-setup.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ cd packages/pf3-component-mapper
3434
yarn start
3535
```
3636

37+
#### Run documentation
38+
39+
The documentation is a server-side rendered React application based on [NextJS framework](https://nextjs.org/).
40+
41+
```console
42+
cd packages/react-renderer-demo
43+
yarn dev
44+
```
45+
3746
#### How to clean?
3847

3948
```console

packages/react-renderer-demo/src/app/src/docs-components/field-array.md renamed to packages/react-renderer-demo/src/app/pages/renderer/field-array.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import NavLink from 'next/link';
1+
import RouterLink from 'next/link';
2+
import Link from '@material-ui/core/Link';
3+
24
import RawComponent from '@docs/raw-component';
35

46
### Field Array Provider
57

6-
Simillarly to <NavLink href='/renderer/field-provider'><a>FieldProvider</a></NavLink> Data driven forms provide an option how to inlude <a href='https://github.com/final-form/react-final-form-arrays'>React Final Form Arrays</a> in your form.
8+
Simillarly to <RouterLink href='/renderer/field-provider'><Link>FieldProvider</Link></RouterLink> Data driven forms provide an option how to inlude <a href='https://github.com/final-form/react-final-form-arrays'>React Final Form Arrays</a> in your form.
79

810
<b>Please visit their documentation to learn about functionality.</b>
911

@@ -49,7 +51,7 @@ You don't need to name the nested components, then the values are saved as an ar
4951

5052
### Validators
5153

52-
You can use user a few provided validators (you can also use your <NavLink href='/renderer/validators'><a>own</a></NavLink>.)
54+
You can use user a few provided validators (you can also use your <RouterLink href='/renderer/validators'><Link>own</Link></RouterLink>.)
5355

5456
```jsx
5557
MIN_ITEMS_VALIDATOR: ({threshold})

packages/react-renderer-demo/src/app/pages/renderer/field-provider.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Link from 'next/link';
1+
import RouterNav from 'next/link';
2+
import Link from '@material-ui/core/Link';
23

34
### Field Provider
45
import Grid from '@material-ui/core/Grid'
@@ -22,11 +23,11 @@ which adds additional methods that will help you to control your form state.
2223
### Accessing FieldProvider
2324

2425
To use Fieldprovider, you first need to register a component to your component mapper.
25-
You can read more about that in <Link href="/renderer/component-mapping"><a>Component mapping</a></Link>.
26+
You can read more about that in <RouterNav href="/renderer/component-mapping"><Link>Component mapping</Link></RouterNav>.
2627

2728
Each component will receive FieldProvider as a prop. Be aware that pre-defined component types are
2829
automatically wrapped in FieldProvider. This is done to make it easier to create component mappers for
29-
standard form components. List of standard components is available <Link href="/renderer/component-api"><a>here</a></Link>.
30+
standard form components. List of standard components is available <RouterNav href="/renderer/component-api"><Link>here</Link></RouterNav>.
3031

3132
### Using FieldProvider
3233

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import RawComponent from '@docs/raw-component';
22

3-
## React form renderer
3+
### React form renderer
44

55
React form renderer is a component designed for ManageIQ and
6-
Insights projects that takes json form definitions
6+
Insights projects that takes JSON form definitions
77
and renders them into react components.
8-
It uses [React final form](https://github.com/final-form/react-final-form) for the form state management.
8+
It uses [React Final Form](https://github.com/final-form/react-final-form) for the form state management.
99
It is highly recommended to check their documentations first to fully understand how
10-
the [data-driven-forms](https://github.com/data-driven-forms/react-forms) libraries work.
10+
the [Data Driven Dorms](https://github.com/data-driven-forms/react-forms) libraries work.
1111

1212
<RawComponent source="get-started/get-started" />
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
### Installation
2+
13
```console
24
npm install --save @data-driven-forms/react-form-renderer
35
```
46
or
57
```console
68
yarn add @data-driven-forms/react-form-renderer
7-
```
8-
-
9-
### Links to NPM
10-
- a) [React form renderer](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer)
11-
- b) [Patternfly 3 mapper](https://www.npmjs.com/package/@data-driven-forms/pf3-component-mapper)
12-
- c) [Patternfly 4 mapper](https://www.npmjs.com/package/@data-driven-forms/pf4-component-mapper)
13-
- d) [MaterialUI mapper](https://www.npmjs.com/package/@data-driven-forms/mui-component-mapper)
9+
```

packages/react-renderer-demo/src/app/pages/renderer/renderer-api.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Form Renderer provides a lot of customization via props.
3232
|<RouterLink href="/renderer/unmounting"><Link>clearOnUnmount</Link></RouterLink>|bool|Will clear values of unmounted components. You can also set this to specific component in the form schema.|false|
3333
|canReset|bool|Show/hide reset button.|false|
3434
|onReset|func|A reset callback. You don't need to manually clear the form values!||
35-
|onCancel|func|A cancel callback.||
35+
|onCancel|func|A cancel callback, which receives `values` as the first argument.||
3636
|onStateUpdate|func|A function which will be called with every form update, i.e. `({ values }) => setValues(values)`||
3737
|disableSubmit|array of strings|You can specify a form attributes (see [here](https://final-form.org/docs/final-form/types/FormState)) which will make the submit button disabled. |[ ]|
3838
|initialValues|object|An object of fields names as keys and values as their values.||
@@ -42,6 +42,30 @@ Form Renderer provides a lot of customization via props.
4242
|uiSchema|object|Use when you need to use mozilla schema.|{ }|
4343
|<RouterLink href="/renderer/validators"><Link>validate</Link></RouterLink>|func|A function which receives all form values and returns an object with errors.||
4444

45+
### Schema
46+
47+
The root object of the schema represents the <RouterLink href="/renderer/component-mapping#formwrapper"><Link>Form</Link></RouterLink> component, which accepts only these three props:
48+
49+
|Prop|Type|Description|
50+
|----|:--:|----------:|
51+
|label, title|node|<RouterLink href="/renderer/component-mapping#title"><Link>Title</Link></RouterLink> of the form. Optional.|
52+
|description|node|<RouterLink href="/renderer/component-mapping#description"><Link>Description</Link></RouterLink> of the form. Optional.|
53+
|fields|array of objects|<RouterLink href="/renderer/component-api"><Link>Components</Link></RouterLink> of the form. Required!|
54+
55+
#### Example
56+
57+
```javascript
58+
schema = {
59+
title: 'Your name',
60+
description: 'Add your name',
61+
fields: [{
62+
name: 'userName',
63+
label: 'Your name is',
64+
component: componentTypes.TEXT_FIELD,
65+
}]
66+
};
67+
```
68+
4569
</Grid>
4670
<Grid item xs={false} md={2}>
4771
<ListOfContents file="renderer/renderer-api" />

0 commit comments

Comments
 (0)