import { useImperativeHandle, type FormHTMLAttributes, useRef, forwardRef, type Ref } from "react";
import { clsn } from "~utils";
import styles from "./form.module.less";

interface FormProps extends FormHTMLAttributes<HTMLFormElement> {

}

function Form({ children, className, ...props }: FormProps, ref: Ref<HTMLFormElement>) {
  const formRef = useRef();

  useImperativeHandle(ref, () => {
    return formRef.current;
  }, []);

  return (
    <form ref={formRef} className={clsn(styles.form, className)} {...props}>
      {children}
    </form>
  );
}

export default forwardRef(Form);
