11import React from 'react' ;
22import PropTypes from 'prop-types' ;
3+ import clsx from 'clsx' ;
34
45import { Form as CarbonForm , Button as CarbonButton , ButtonSet } from 'carbon-components-react' ;
56
67import FormTemplate from '@data-driven-forms/common/src/form-template' ;
78
9+ import './form-template.scss' ;
10+
811export const Button = ( { label, buttonType, ...props } ) => (
912 < CarbonButton kind = { buttonType === 'submit' ? 'primary' : 'secondary' } { ...props } >
1013 { label }
@@ -16,13 +19,18 @@ Button.propTypes = {
1619 buttonType : PropTypes . string
1720} ;
1821
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+ ) ;
2027
2128ButtonGroup . 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
2331} ;
2432
25- export const Title = ( { children } ) => < h1 > { children } </ h1 > ;
33+ export const Title = ( { children } ) => < h3 > { children } </ h3 > ;
2634
2735Title . propTypes = {
2836 children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
@@ -34,16 +42,19 @@ Description.propTypes = {
3442 children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
3543} ;
3644
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 ) } >
3947 { children }
4048 </ CarbonForm >
4149) ;
4250
4351Form . 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
4554} ;
4655
56+ export const Header = ( props ) => < div className = "ddorg__carbon-form-template-header" { ...props } /> ;
57+
4758const WrappedFormTemplate = ( props ) => (
4859 < FormTemplate
4960 FormWrapper = { Form }
@@ -52,6 +63,7 @@ const WrappedFormTemplate = (props) => (
5263 Title = { Title }
5364 Description = { Description }
5465 buttonOrder = { [ 'cancel' , 'reset' , 'submit' ] }
66+ Header = { Header }
5567 { ...props }
5668 />
5769) ;
0 commit comments