"use client"; import { composeEventHandlers } from "@radix-ui/primitive"; import { Primitive } from "../../utils/Primitive"; import { type ComponentRef, type FormEvent, forwardRef, type ComponentPropsWithoutRef, } from "react"; import { useComposerSend } from "./ComposerSend"; export namespace ComposerPrimitiveRoot { export type Element = ComponentRef; /** * Props for the ComposerPrimitive.Root component. * Accepts all standard form element props. */ export type Props = ComponentPropsWithoutRef; } /** * The root form container for message composition. * * This component provides a form wrapper that handles message submission when the form * is submitted (e.g., via Enter key or submit button). It automatically prevents the * default form submission and triggers the composer's send functionality. * * @example * ```tsx * * * Send * * ``` */ export const ComposerPrimitiveRoot = forwardRef< ComposerPrimitiveRoot.Element, ComposerPrimitiveRoot.Props >(({ onSubmit, ...rest }, forwardedRef) => { const send = useComposerSend(); const handleSubmit = (e: FormEvent) => { e.preventDefault(); if (!send) return; send(); }; return ( ); }); ComposerPrimitiveRoot.displayName = "ComposerPrimitive.Root";