File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
- import React , { FC , HTMLAttributes } from 'react' ;
1
+ import React , { useContext , FC , HTMLAttributes } from 'react' ;
2
2
import classnames from 'classnames' ;
3
3
import { FormElement } from './FormElement' ;
4
4
@@ -20,6 +20,32 @@ export const FormTypeContext =
20
20
*/
21
21
const IsFormContext = React . createContext < boolean > ( false ) ;
22
22
23
+ /**
24
+ *
25
+ */
26
+ export const FormItem : FC < {
27
+ commonClassNames ?: string ;
28
+ children : ( commonClassName : string ) => JSX . Element ;
29
+ } > = ( { commonClassNames, children } ) => {
30
+ const isForm = useContext ( IsFormContext ) ;
31
+ const type = useContext ( FormTypeContext ) ;
32
+
33
+ if ( ! isForm || type === 'inline' ) {
34
+ return children ( commonClassNames ?? '' ) ;
35
+ }
36
+
37
+ return (
38
+ < div
39
+ className = { classnames ( 'slds-form__item' , commonClassNames ) }
40
+ role = 'listitem'
41
+ >
42
+ < IsFormContext . Provider value = { false } >
43
+ { children ( '' ) }
44
+ </ IsFormContext . Provider >
45
+ </ div >
46
+ ) ;
47
+ } ;
48
+
23
49
/**
24
50
*
25
51
*/
You can’t perform that action at this time.
0 commit comments