"use client"; import { type FormHTMLAttributes, type ReactElement, type Ref } from "react"; const noop = (): void => { // do nothing }; export interface FormProps extends FormHTMLAttributes { ref?: Ref; /** * Boolean if the form should no longer prevent default submit behavior. If * you enable this prop you should honestly just use a `
` element * instead * * @defaultValue `false` */ disablePreventDefault?: boolean; } /** * **Client Component** * * This is probably one of the least useful components available as it doesn't * do much styling or logic. All this form component will do is add basic flex * behavior and prevent the default form submit behavior. * * @see {@link https://react-md.dev/components/form | Form Demos} */ export function Form(props: FormProps): ReactElement { const { ref, children, onSubmit = noop, disablePreventDefault = false, ...remaining } = props; return ( { if (!disablePreventDefault) { event.preventDefault(); } onSubmit(event); }} ref={ref} > {children}
); }