Skip to content

Commit f09a379

Browse files
authored
Merge pull request #168 from rvsia/async-select-docs
Add AsyncSelect docs
2 parents 91bdf11 + 2854247 commit f09a379

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

packages/react-renderer-demo/src/common/examples-definitions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import GenericComponentText from './examples-texts/generic-mui-component';
33
import TabsText from './examples-texts/tabs';
44
import CustomComponentText from './examples-texts/custom-component';
55
import WizardText from './examples-texts/wizard';
6+
import SelectText from './examples-texts/select';
67

78
export const baseExamples = [{
89
component: componentTypes.TEXT_FIELD,
@@ -120,7 +121,7 @@ export const baseExamples = [{
120121
{
121122
component: componentTypes.SELECT_COMPONENT,
122123
linkText: 'Select',
123-
ContentText: GenericComponentText,
124+
ContentText: SelectText,
124125
canBeRequired: true,
125126
value: { fields: [{
126127
component: componentTypes.SELECT_COMPONENT,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import GenericComponentText from './generic-mui-component';
3+
import Pf3Select from 'docs/components/pf3-select.md';
4+
import Pf4Select from 'docs/components/pf4-select.md';
5+
6+
export default ({ activeMapper }) => activeMapper === 'pf3' ? <Pf3Select /> : activeMapper === 'pf4' ? <Pf4Select /> : <GenericComponentText />;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
### Async Select
2+
3+
PF3 Select allows to load the options asynchronously.
4+
5+
6+
|prop name|type|description|
7+
|---------|----|-----------|
8+
|loadOptions|`func`|A function returning `Promise`, only on mount.|
9+
|loadingMessage|`string`|A message shown during the loading.|
10+
11+
#### loadOptions example
12+
13+
Currently now, PF3 select supports only loading on mounting.
14+
15+
```jsx
16+
const asyncLoadOptions = () => new Promise(resolve => setTimeout(() => resolve(options), 2000));
17+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### Async Select
2+
3+
PF4 Select allows to load the options asynchronously.
4+
5+
6+
|prop name|type|description|
7+
|---------|----|-----------|
8+
|loadOptions|`func`|A function returning `Promise`: `(searchValue) => new Promise`|
9+
|loadingMessage|`node`|A message shown during the initial loading.|
10+
|updatingMessage|`node`|A message shown during the loading|
11+
12+
#### loadOptions example
13+
14+
`loadOptions` receives a search input text as an argument.
15+
16+
```jsx
17+
const asyncLoadOptions = (searchValue) => new Promise(resolve => setTimeout(() => {
18+
if (searchValue && searchValue.trim() !== '') {
19+
return resolve(asyncOptions.filter(({ label }) => label.toLocaleLowerCase().includes(searchValue.trim().toLocaleLowerCase())));
20+
}
21+
22+
return resolve(options);
23+
}, 2000));
24+
```

0 commit comments

Comments
 (0)