@@ -2,6 +2,19 @@ import React from 'react';
2
2
import ComponentText from '@docs/components/component-example-text' ;
3
3
import componentTypes from '@data-driven-forms/react-form-renderer/component-types' ;
4
4
import baseFieldProps from '../../helpers/base-field-props' ;
5
+ import updateFieldSchema from '../../helpers/update-field-schema' ;
6
+
7
+ const loadOptions = `<FUNCTION () =>
8
+ new Promise((res) =>
9
+ setTimeout(
10
+ () =>
11
+ res([
12
+ { value: 'first-option', label: 'First async option' },
13
+ { value: 'second-option', label: 'Second async option' }
14
+ ]),
15
+ 2500
16
+ )
17
+ ) FUNCTION>` . replace ( / \n / g, '<NEWLINE>' ) ;
5
18
6
19
const schema = {
7
20
fields : [
@@ -19,6 +32,19 @@ const schema = {
19
32
]
20
33
} ;
21
34
35
+ const basicVariant = { schema, label : 'Basic' , value : 'basic' } ;
36
+ const multiVariant = { schema : updateFieldSchema ( schema , { isMulti : true } ) , label : 'Multi' , value : 'multi' } ;
37
+ const loadOptionsVariant = { schema : updateFieldSchema ( schema , { options : [ ] , loadOptions } ) , label : 'Load options' , value : 'load-options' } ;
38
+
39
+ const schemaVariants = {
40
+ mui : [ basicVariant , multiVariant , loadOptionsVariant ] ,
41
+ pf4 : [ basicVariant , multiVariant , loadOptionsVariant ] ,
42
+ blueprint : [ basicVariant , multiVariant ] ,
43
+ suir : [ basicVariant , multiVariant , loadOptionsVariant ] ,
44
+ ant : [ basicVariant , multiVariant , loadOptionsVariant ] ,
45
+ carbon : [ basicVariant , multiVariant , loadOptionsVariant ]
46
+ } ;
47
+
22
48
const variants = [
23
49
...baseFieldProps ,
24
50
{
@@ -55,6 +81,6 @@ const variants = [
55
81
}
56
82
] ;
57
83
58
- const Select = ( ) => < ComponentText schema = { schema } variants = { variants } linkText = "Select" /> ;
84
+ const Select = ( ) => < ComponentText schema = { schema } variants = { variants } linkText = "Select" schemaVariants = { schemaVariants } /> ;
59
85
60
86
export default Select ;
0 commit comments