2019-12-06 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import classnames from 'classnames';
|
2022-02-07 09:34:30 +00:00
|
|
|
import type { FormEvent } from 'react';
|
|
|
|
|
|
|
|
interface FormProps {
|
|
|
|
className: string;
|
|
|
|
children?: React.ReactChildren;
|
|
|
|
onSubmit: ( event: FormEvent ) => void;
|
|
|
|
}
|
2019-12-06 13:18:55 +00:00
|
|
|
|
2020-09-07 15:43:05 +00:00
|
|
|
const Form = ( {
|
2020-05-22 14:51:38 +00:00
|
|
|
className,
|
|
|
|
children,
|
|
|
|
onSubmit = ( event ) => void event,
|
2022-02-07 09:34:30 +00:00
|
|
|
}: FormProps ): JSX.Element => {
|
|
|
|
const formOnSubmit = ( event: FormEvent ) => {
|
2020-05-22 14:51:38 +00:00
|
|
|
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
|
|
|
export default Form;
|