@@ -2,6 +2,19 @@ import React from 'react';
22import ComponentText from '@docs/components/component-example-text' ;
33import componentTypes from '@data-driven-forms/react-form-renderer/component-types' ;
44import 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>' ) ;
518
619const schema = {
720 fields : [
@@ -19,6 +32,19 @@ const schema = {
1932 ]
2033} ;
2134
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+
2248const variants = [
2349 ...baseFieldProps ,
2450 {
@@ -55,6 +81,6 @@ const variants = [
5581 }
5682] ;
5783
58- const Select = ( ) => < ComponentText schema = { schema } variants = { variants } linkText = "Select" /> ;
84+ const Select = ( ) => < ComponentText schema = { schema } variants = { variants } linkText = "Select" schemaVariants = { schemaVariants } /> ;
5985
6086export default Select ;
0 commit comments