Skip to content

Commit 061fa02

Browse files
committed
Add documentation for PF4 select groups
1 parent 288e1d5 commit 061fa02

File tree

2 files changed

+86
-1
lines changed
  • packages/react-renderer-demo/src

2 files changed

+86
-1
lines changed

packages/react-renderer-demo/src/doc-components/examples-texts/pf4/select.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,58 @@ In order to show menu properly in dialogs like modals, you can use `menuIsPortal
66
|---------|----|-----------|
77
|menuIsPortal|`bool`|Append menu to body instead of to select wrapper.See more [here](https://react-select.com/advanced#portaling)|
88

9+
## Groups and dividers
10+
11+
PF4 selects supports grouping options and inserting dividers.
12+
13+
### Group
14+
15+
```jsx
16+
{
17+
label: 'Category name',
18+
options: [ ...options ]
19+
}
20+
```
21+
22+
### Divider
23+
24+
```jsx
25+
{
26+
divider: true
27+
}
28+
```
29+
30+
### Example
31+
32+
```jsx
33+
{
34+
component: 'select',
35+
name: 'select-with-categories',
36+
label: 'With categories',
37+
options: [
38+
{
39+
label: 'Category 1',
40+
options: [
41+
{ label: 'value 1', value: '111' },
42+
{ label: 'value 2', value: '222' }
43+
]
44+
},
45+
{divider: true },
46+
{label: 'independent 1', value: '1112333'},
47+
{divider: true },
48+
{
49+
label: 'Category 2',
50+
options: [
51+
{ label: 'value 3', value: '333' },
52+
{ label: 'value 4', value: '444' }
53+
]
54+
},
55+
{divider: true },
56+
{label: 'independent 2', value: '11111' }
57+
]
58+
}
59+
```
60+
961
## PF4 Async Select
1062

1163
PF4 Select allows to load the options asynchronously.

packages/react-renderer-demo/src/pages/provided-mappers/select.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,42 @@ const basicVariant = { schema, label: 'Basic', value: 'basic' };
3636
const multiVariant = { schema: updateFieldSchema(schema, { isMulti: true }), label: 'Multi', value: 'multi' };
3737
const loadOptionsVariant = { schema: updateFieldSchema(schema, { options: [], loadOptions }), label: 'Load options', value: 'load-options' };
3838

39+
const groupsAndDividersSchema = {
40+
fields: [
41+
{
42+
component: componentTypes.SELECT,
43+
name: 'select-with-categories',
44+
label: 'With categories',
45+
options: [
46+
{
47+
label: 'Category 1',
48+
options: [
49+
{ label: 'value 1', value: '111' },
50+
{ label: 'value 2', value: '222' },
51+
],
52+
},
53+
{ divider: true },
54+
{ label: 'independent 1', value: '1112333' },
55+
{ divider: true },
56+
{
57+
label: 'Category 2',
58+
options: [
59+
{ label: 'value 3', value: '333' },
60+
{ label: 'value 4', value: '444' },
61+
],
62+
},
63+
{ divider: true },
64+
{ label: 'independent 2', value: '11111' },
65+
],
66+
},
67+
],
68+
};
69+
70+
const groupsAndDividersVariant = { schema: groupsAndDividersSchema, label: 'Groups', value: 'groups-dividers' };
71+
3972
const schemaVariants = {
4073
mui: [basicVariant, multiVariant, loadOptionsVariant],
41-
pf4: [basicVariant, multiVariant, loadOptionsVariant],
74+
pf4: [basicVariant, multiVariant, loadOptionsVariant, groupsAndDividersVariant],
4275
blueprint: [basicVariant, multiVariant],
4376
suir: [basicVariant, multiVariant, loadOptionsVariant],
4477
ant: [basicVariant, multiVariant, loadOptionsVariant],

0 commit comments

Comments
 (0)