1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
+ import clsx from 'clsx' ;
3
4
4
5
import { Form as CarbonForm , Button as CarbonButton , ButtonSet } from 'carbon-components-react' ;
5
6
6
7
import FormTemplate from '@data-driven-forms/common/src/form-template' ;
7
8
9
+ import './form-template.scss' ;
10
+
8
11
export const Button = ( { label, buttonType, ...props } ) => (
9
12
< CarbonButton kind = { buttonType === 'submit' ? 'primary' : 'secondary' } { ...props } >
10
13
{ label }
@@ -16,13 +19,18 @@ Button.propTypes = {
16
19
buttonType : PropTypes . string
17
20
} ;
18
21
19
- export const ButtonGroup = ( { children, ...props } ) => < ButtonSet { ...props } > { children } </ ButtonSet > ;
22
+ export const ButtonGroup = ( { children, className, ...props } ) => (
23
+ < ButtonSet { ...props } className = { clsx ( 'ddorg__carbon-form-template-buttons' , className ) } >
24
+ { children }
25
+ </ ButtonSet >
26
+ ) ;
20
27
21
28
ButtonGroup . propTypes = {
22
- children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
29
+ children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] ) ,
30
+ className : PropTypes . string
23
31
} ;
24
32
25
- export const Title = ( { children } ) => < h1 > { children } </ h1 > ;
33
+ export const Title = ( { children } ) => < h3 > { children } </ h3 > ;
26
34
27
35
Title . propTypes = {
28
36
children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
@@ -34,16 +42,19 @@ Description.propTypes = {
34
42
children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
35
43
} ;
36
44
37
- export const Form = ( { children, ...props } ) => (
38
- < CarbonForm noValidate { ...props } >
45
+ export const Form = ( { children, className , ...props } ) => (
46
+ < CarbonForm noValidate { ...props } className = { clsx ( 'ddorg__carbon-form-template-form' , className ) } >
39
47
{ children }
40
48
</ CarbonForm >
41
49
) ;
42
50
43
51
Form . propTypes = {
44
- children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
52
+ children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] ) ,
53
+ className : PropTypes . string
45
54
} ;
46
55
56
+ export const Header = ( props ) => < div className = "ddorg__carbon-form-template-header" { ...props } /> ;
57
+
47
58
const WrappedFormTemplate = ( props ) => (
48
59
< FormTemplate
49
60
FormWrapper = { Form }
@@ -52,6 +63,7 @@ const WrappedFormTemplate = (props) => (
52
63
Title = { Title }
53
64
Description = { Description }
54
65
buttonOrder = { [ 'cancel' , 'reset' , 'submit' ] }
66
+ Header = { Header }
55
67
{ ...props }
56
68
/>
57
69
) ;
0 commit comments