import { cva } from "class-variance-authority";
import { motion } from "motion/react";
import type { ReactNode } from "react";
import { cn } from "@/lib/utils.ts";
import { defaultAnimationStagger } from "@/styles/animations";

export const formVariants = cva(cn("py-2 gap-2 max-w-max-form flex flex-col"));

export const Form = ({
	children,
	id,
	onSubmit,
}: {
	children: ReactNode;
	id?: string;
	onSubmit?: () => void;
}) => {
	return (
		<motion.form
			id={id}
			onSubmit={(e) => {
				e.preventDefault();
				onSubmit?.();
			}}
			{...defaultAnimationStagger}
			className={formVariants()}
		>
			{children}
		</motion.form>
	);
};
