@@ -8,24 +8,27 @@ export * from './inputs';
88 * form element
99 */
1010type FormProps = React . ComponentPropsWithoutRef < 'form' > ;
11+ export const formClassName = 'uncontrolled-form' ;
1112export const Form = ( { children, className, style, ...props } : FormProps ) => {
1213 return (
13- < form className = { `uncontrolled-form ${ className || '' } ` } style = { style } { ...props } >
14+ < form className = { [ formClassName , className ] . join ( ' ' ) . trim ( ) } style = { style } { ...props } >
1415 { children }
1516 </ form >
1617 ) ;
1718} ;
1819
20+ export const formSectionClassName = 'uncontrolled-form-section' ;
1921export const FormSection = ( { className, ...props } : React . ComponentPropsWithoutRef < 'div' > ) => (
20- < div className = { `uncontrolled-form-section ${ className || '' } ` } { ...props } />
22+ < div className = { [ formSectionClassName , className ] . join ( ' ' ) . trim ( ) } { ...props } />
2123) ;
2224
2325type MessagesProps = {
2426 state : FetchState < any , string > ;
2527 className ?: string ;
2628} ;
29+ export const messagesClassName = 'uncontrolled-messages' ;
2730export const Messages = ( { state, className} : MessagesProps ) => stateHasError ( state )
28- ? < div className = { `uncontrolled-messages ${ className || '' } ` } > { state . error } </ div >
31+ ? < div className = { [ messagesClassName , className ] . join ( ' ' ) . trim ( ) } > { state . error } </ div >
2932 : null ;
3033
3134/*
@@ -36,18 +39,22 @@ type ButtonsProps = {
3639 onCancel ?: ( ) => void ;
3740 className ?: string ;
3841} ;
39- export const Buttons = ( props : ButtonsProps ) => (
40- < div className = { `uncontrolled-buttons ${ props . className || '' } ` } >
42+ export const buttonsClassName = 'uncontrolled-buttons' ;
43+ export const Buttons = ( { className, ...props } : ButtonsProps ) => (
44+ < div className = { [ buttonsClassName , className ] . join ( ' ' ) . trim ( ) } >
4145 { 'onCancel' in props ? < Cancel onClick = { props . onCancel } > Cancel</ Cancel > : null }
4246 < Submit />
4347 </ div >
4448) ;
4549
4650// submit button
4751type SubmitButtonProps = React . ComponentPropsWithoutRef < 'input' > ;
48- export const Submit = ( { ...props } : SubmitButtonProps ) =>
49- < input type = "submit" value = "Submit" { ...props } /> ;
52+ export const submitButtonClassName = 'uncontrolled-submit-button' ;
53+ export const Submit = ( { className, ...props } : SubmitButtonProps ) =>
54+ < input className = { [ submitButtonClassName , className ] . join ( ' ' ) . trim ( ) } type = "submit" value = "Submit" { ...props } /> ;
5055
5156// cancel button
5257type CancelButtonProps = React . ComponentPropsWithoutRef < 'button' > ;
53- export const Cancel = ( { ...props } : CancelButtonProps ) => < button type = "button" { ...props } /> ;
58+ export const cancelButtonClassName = 'uncontrolled-cancel-button' ;
59+ export const Cancel = ( { className, ...props } : CancelButtonProps ) =>
60+ < button className = { [ cancelButtonClassName , className ] . join ( ' ' ) . trim ( ) } type = "button" { ...props } /> ;
0 commit comments