Skip to content

Commit e90488e

Browse files
rvsiaHyperkid123
authored andcommitted
Add docs for missing components
1 parent ebac721 commit e90488e

File tree

6 files changed

+125
-3
lines changed

6 files changed

+125
-3
lines changed

packages/blueprint-component-mapper/src/files/field-array.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ FieldArray.propTypes = {
131131
AddButtonProps: PropTypes.object,
132132
RemoveButtonProps: PropTypes.object,
133133
ArrayItemProps: PropTypes.object,
134+
FormGroupProps: PropTypes.object,
134135
FieldArrayProps: PropTypes.object,
135136
noItemsMessage: PropTypes.node,
136137
validateOnMount: PropTypes.bool,
137138
helperText: PropTypes.node,
138139
isRequired: PropTypes.bool,
139-
FormGroupProps: PropTypes.object,
140140
maxItems: PropTypes.number,
141141
minItems: PropTypes.number
142142
};

packages/blueprint-component-mapper/src/tests/components.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import FormTemplate from '../files/form-template';
66
import componentMapper from '../files/component-mapper';
77
import { validatorTypes } from '@data-driven-forms/react-form-renderer';
88
import FormGroupWrapper from '../files/form-group';
9-
import Wizard from '../files/wizard';
109
import DualListSelect from '../files/dual-list-select';
11-
import FieldArray from '../files/field-array';
1210

1311
describe('formFields generated tests', () => {
1412
const RendererWrapper = ({ schema = { fields: [] }, ...props }) => (
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Blueprint component mapper provides an experimental implementation of field array.
2+
3+
**Props**
4+
5+
|Prop|Type|Description|
6+
|:---|:--:|----------:|
7+
|label|`node`|Label of the array.|
8+
|description|`node`|Description of the array.|
9+
|fields|`array`|A group of fields, which are being added to the array.|
10+
|defaultItem|`any`|Default item which is inserted into a newly created fields group. If you have nested names, don't forget you need to insert an object!|
11+
|minItems|`number`|Remove button is disabled, if the length of the array is equal or smaller.|
12+
|maxItems|`number`|Add button is disabled, if the length of the array is equal or bigger.|
13+
|noItemsMessage|`node`|A message which is shown, when there are no items in the array.|
14+
|buttonLabels|`object`|`{add: 'ADD', remove: 'REMOVE'}` sets labels of buttons.|
15+
|AddContainerProps|`object`|Props passed to the div wrapping the add button.|
16+
|AddButtonProps|`object`|Props passed to the add button.|
17+
|RemoveButtonProps|`object`|Props passed to the remove button.|
18+
|ArrayItemProps|`object`|Props passed to the div wrapping each field item.|
19+
|FormGroupProps|`object`|Props passed to the form group component.|
20+
|FieldArrayProps|`object`|Props passed to the root div.|
21+
22+
**Naming**
23+
24+
Fields can contain names, then the value will be handled as array of objects.
25+
26+
```jsx
27+
const fields = [
28+
{ name: 'name', ... },
29+
{ name: 'lastname', ... }
30+
]
31+
32+
[
33+
{ name: value1.name, lastname: value1.lastname },
34+
{ name: value2.name, lastname: value2.lastname },
35+
...
36+
]
37+
```
38+
39+
Or you can put a single field with no name. In this case, values are stored as a simple array.
40+
41+
```jsx
42+
const fields = [
43+
{ component: 'text-field' }
44+
]
45+
46+
[ value1, value2, ... ]
47+
```
48+
49+
**Custom component**
50+
51+
To implement a custom component, please take a look [here](/renderer/dynamic-fields).
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
This a custom component. OnSubmit will send only values from visited steps.
2+
3+
**Props**
4+
5+
|Prop|Type|Default|Description|
6+
|-------------|-------------|-------------|-------------|
7+
|buttonLabels|object of nodes | see below | Labels for buttons |
8+
|WizardProps | object | {} | Props passed to the root div |
9+
|ButtonToolbarProps | object | {} | Props passed to the div wrapping buttons |
10+
|DirectionButtonProps | object | {} | Props passed to the div wrapping back/next buttons |
11+
|CancelButtonProps| object | {} | Props passed to the cancel button |
12+
|BackButtonProps| object | {} | Props passed to the back button |
13+
|NextButtonProps| object | {} | Props passed to the next button |
14+
|SubmitButtonProps| object | {} | Props passed to the submit button |
15+
16+
**Default buttonLabels**
17+
18+
```jsx
19+
{
20+
cancel: 'Cancel',
21+
back: 'Back',
22+
next: 'Next',
23+
submit: 'Submit',
24+
}
25+
```
26+
27+
You can rewrite only selection of them, e.g.
28+
29+
```jsx
30+
{
31+
submit: 'Deploy',
32+
}
33+
```
34+
35+
(Others will stay default)
36+
37+
**Docs for steps**
38+
39+
| Props | Type | Description |
40+
| ------------- | ------------- | ------------- |
41+
| name | string, number | Name of the step |
42+
| nextStep | object/stepKey of next step/function | See below |
43+
| fields | array | As usual |
44+
45+
- nextStep can be name of the next step
46+
- or you can branch the way by using of object:
47+
48+
```jsx
49+
nextStep: {
50+
when: 'source-type', // name of field, where deciding value is stored
51+
stepMapper: {
52+
aws: 'aws', // value: 'name' of next step
53+
google: 'google',
54+
...
55+
},
56+
},
57+
```
58+
59+
- another option is to use custom function. The custom function receives as the first argument an object with values and the function has to return a `name` in string.
60+
61+
```jsx
62+
nextStep: ({ values }) => (values.aws === '123' &&& values.password === 'secret') ? 'secretStep' : 'genericStep'
63+
```

packages/react-renderer-demo/src/doc-components/field-array.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import MuiFieldArray from './examples-texts/mui/mui-field-array.md';
44
import Pf4FieldArray from './examples-texts/pf4/pf4-field-array.md';
55
import Pf3FieldArray from './examples-texts/pf3/pf3-field-array.md';
66
import SuirFieldArray from './examples-texts/suir/suir-field-array.md';
7+
import BlueprintFieldArray from './examples-texts/blueprint/blueprint-field-array.md';
78
import GenericMuiComponent from '../helpers/generic-mui-component';
89

910
const FieldArray = ({ activeMapper }) => {
@@ -23,6 +24,10 @@ const FieldArray = ({ activeMapper }) => {
2324
return <SuirFieldArray />;
2425
}
2526

27+
if (activeMapper === 'blueprint') {
28+
return <BlueprintFieldArray />;
29+
}
30+
2631
return <GenericMuiComponent activeMapper={activeMapper} component="field-array" />;
2732
};
2833

packages/react-renderer-demo/src/doc-components/wizard.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import MuiWizard from './examples-texts/mui/mui-wizard.md';
44
import Pf4Wizard from './examples-texts/pf4/pf4-wizard.md';
55
import Pf3Wizard from './examples-texts/pf3/pf3-wizard.md';
66
import SuirWizard from './examples-texts/suir/suir-wizard.md';
7+
import BlueprintWizard from './examples-texts/blueprint/blueprint-wizard.md';
78
import GenericMuiComponent from '../helpers/generic-mui-component';
89

910
const Wizard = ({ activeMapper }) => {
@@ -23,6 +24,10 @@ const Wizard = ({ activeMapper }) => {
2324
return <SuirWizard />;
2425
}
2526

27+
if (activeMapper === 'blueprint') {
28+
return <BlueprintWizard />;
29+
}
30+
2631
return <GenericMuiComponent activeMapper={activeMapper} component="wizard" />;
2732
};
2833

0 commit comments

Comments
 (0)