2019-12-06 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2020-09-07 15:43:05 +00:00
|
|
|
const Form = ( {
|
2020-05-22 14:51:38 +00:00
|
|
|
className,
|
|
|
|
children,
|
|
|
|
onSubmit = ( event ) => void event,
|
|
|
|
} ) => {
|
|
|
|
const formOnSubmit = ( event ) => {
|
|
|
|
event.preventDefault();
|
|
|
|
onSubmit( event );
|
|
|
|
};
|
2020-08-31 10:17:42 +00:00
|
|
|
|
2019-12-06 13:18:55 +00:00
|
|
|
return (
|
2020-05-22 14:51:38 +00:00
|
|
|
<form
|
2020-08-31 10:17:42 +00:00
|
|
|
className={ classnames( 'wc-block-components-form', className ) }
|
2020-05-22 14:51:38 +00:00
|
|
|
onSubmit={ formOnSubmit }
|
|
|
|
>
|
2019-12-06 13:18:55 +00:00
|
|
|
{ children }
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-09-07 15:43:05 +00:00
|
|
|
Form.propTypes = {
|
2019-12-06 13:18:55 +00:00
|
|
|
className: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
2020-05-22 14:51:38 +00:00
|
|
|
onSubmit: PropTypes.func,
|
2019-12-06 13:18:55 +00:00
|
|
|
};
|
|
|
|
|
2020-09-07 15:43:05 +00:00
|
|
|
export default Form;
|