UNPKG

@payfit/unity-components

Version:

44 lines (43 loc) • 2.33 kB
import { ComponentPropsWithoutRef, FormEventHandler, ReactNode } from 'react'; import { AIComposerEnterKeyBehavior, AIComposerState } from './AIComposer.context.js'; export interface AIComposerProps extends Omit<ComponentPropsWithoutRef<'form'>, 'children' | 'className' | 'onSubmit' | 'style'> { /** Composes the prompt, optional context, feedback, and action regions. */ children?: ReactNode; /** * Controls how Enter behaves in the prompt field. * @default 'submit' */ enterKeyBehavior?: AIComposerEnterKeyBehavior; /** * Selects the interaction lifecycle and its visual treatment. * @default 'enabled' */ state?: AIComposerState; /** Receives the submit event after the browser default is prevented. */ onSubmit?: FormEventHandler<HTMLFormElement>; /** Stops the active response while the composer is streaming. */ onStop?: () => void; } /** * Gives people one consistent place to write an AI request, add context, and * follow the request lifecycle without leaving the conversation. * * Compose `AIComposerTextArea`, `AIComposerActions`, and any optional * attachment or feedback parts inside the form. Set `state` from the request * lifecycle and pass `onSubmit` to send the prompt. * @param props - Form attributes, composer state, and composable child regions. * @param props.children - Renders the Composer parts in their semantic order. * @param props.enterKeyBehavior - Chooses `submit` for Enter-to-send or * `newline` for Enter-to-add-a-line. * @param props.state - Selects `enabled`, `loading`, `streaming`, or `disabled`. * @param props.onSubmit - Sends a ready prompt after form validation succeeds. * @param props.onStop - Stops an in-progress response during `streaming`. * @see {@link AIComposerProps} for all available props. * @remarks * The root renders a semantic `<form>`; give it an `aria-label` or * `aria-labelledby` when it needs a landmark name. `AIComposerTextArea` * derives whether the prompt contains meaningful text, so consumers do not * need to maintain a separate active state. The streaming submit action calls * `onStop` instead of submitting a new prompt. */ export declare const AIComposer: import('react').ForwardRefExoticComponent<AIComposerProps & import('react').RefAttributes<HTMLFormElement>>;