import * as react from 'react'; import { d as PromptAreaProps, b as PromptAreaHandle, S as Segment, f as TriggerConfig, C as ChipSegment, A as ActiveTrigger, i as TriggerSuggestion } from '../types-DNPPaAex.js'; export { a as ChipStyle, P as PromptAreaFile, c as PromptAreaImage, T as TextSegment, e as TriggerActivateContext, g as TriggerMode, h as TriggerPosition } from '../types-DNPPaAex.js'; export { CallbackTriggerOptions, CommandTriggerOptions, HashtagTriggerOptions, MarkdownToken, MentionTriggerOptions, callbackTrigger, chip, commandTrigger, detectActiveTrigger, getChips, getChipsByTrigger, hasChips, hashtagTrigger, isSegmentsEmpty, isValidTriggerPosition, mentionTrigger, mergeAdjacentTextSegments, parseInlineMarkdown, plainTextToSegments, resolveChip, resolveTriggersInSegments, segmentsEqual, segmentsToPlainText, text } from '../helpers/index.js'; /** * PromptArea - A lightweight rich text input with trigger support. * * Uses contentEditable to support inline chips (immutable pills) for * mentions, commands, and other triggered tokens. Each trigger character * can be configured to show a dropdown or fire a callback. * * @example * ```tsx * const [segments, setSegments] = useState([]) * * * ``` */ declare function PromptArea({ value, onChange, triggers, placeholder, className, disabled, markdown, markdownHeadings, normalizeBullets, onSubmit, onEscape, onChipClick, onChipAdd, onChipDelete, onLinkClick, onPaste, onUndo, onRedo, minHeight, maxHeight, autoFocus, autoGrow, 'aria-label': ariaLabel, 'data-test-id': dataTestId, images, imagePosition, onImagePaste, onImageRemove, onImageClick, files, filePosition, onFileRemove, onFileClick, onKeyDown, onBlur, onRawPaste, submitOnEnter, spellCheck, maxLength, 'aria-describedby': ariaDescribedBy, ref, }: PromptAreaProps & { ref?: React.Ref; }): react.JSX.Element; type UsePromptAreaOptions = { value: Segment[]; onChange: (segments: Segment[]) => void; triggers?: TriggerConfig[]; disabled?: boolean; onSubmit?: (segments: Segment[]) => void; onEscape?: () => void; onChipClick?: (chip: ChipSegment) => void; onChipAdd?: (chip: ChipSegment) => void; onChipDelete?: (chip: ChipSegment) => void; onLinkClick?: (url: string) => void; onPaste?: (data: { segments: Segment[]; source: 'internal' | 'external'; }) => void; onRawPaste?: (e: React.ClipboardEvent) => void; onUndo?: (segments: Segment[]) => void; onRedo?: (segments: Segment[]) => void; onImagePaste?: (file: File) => void; markdown?: boolean; markdownHeadings?: boolean; normalizeBullets?: boolean; submitOnEnter?: boolean; maxLength?: number; }; type UsePromptAreaReturn = { editorRef: React.RefObject; activeTrigger: ActiveTrigger | null; suggestions: TriggerSuggestion[]; suggestionsLoading: boolean; suggestionsError: string | null; selectedSuggestionIndex: number; handleInput: () => void; handleKeyDown: (e: React.KeyboardEvent) => void; handleClick: (e: React.MouseEvent) => void; handleMouseDown: (e: React.MouseEvent) => void; selectSuggestion: (suggestion: TriggerSuggestion) => void; dismissTrigger: () => void; handle: PromptAreaHandle; triggerRect: DOMRect | null; eventHandlers: { onPaste: (e: React.ClipboardEvent) => void; onCopy: (e: React.ClipboardEvent) => void; onCut: (e: React.ClipboardEvent) => void; onDrop: (e: React.DragEvent) => void; onDragOver: (e: React.DragEvent) => void; onCompositionStart: () => void; onCompositionEnd: () => void; onBlur: () => void; }; }; declare function usePromptArea({ value, onChange, triggers, disabled, onSubmit, onEscape, onChipClick, onChipAdd, onChipDelete, onLinkClick, onPaste, onRawPaste, onUndo, onRedo, onImagePaste, markdown: markdownEnabled, markdownHeadings: headingsEnabled, normalizeBullets, submitOnEnter, maxLength, }: UsePromptAreaOptions): UsePromptAreaReturn; /** * Convenience hook that wires up all the boilerplate state for a PromptArea. * * Instead of manually managing `useState`, `useRef`, * and computing derived values, call `usePromptAreaState()` once and spread * `bind` into your ``. * * @example * ```tsx * function ChatInput() { * const { bind, plainText, isEmpty, chips, clear, focus } = usePromptAreaState() * * return ( * { * sendMessage(plainText) * clear() * }} * /> * ) * } * ``` */ type UsePromptAreaStateOptions = { /** Initial segment value. Defaults to `[]`. */ initialValue?: Segment[]; }; type PromptAreaBind = { /** Ref to attach to PromptArea — gives access to imperative methods. */ ref: React.RefObject; /** Current segment array — pass as `value` prop. */ value: Segment[]; /** Setter — pass as `onChange` prop. */ onChange: (segments: Segment[]) => void; }; type PromptAreaState = { /** Props to spread directly onto ``. Contains ref, value, and onChange. */ bind: PromptAreaBind; /** Derived plain text representation of the current value. */ plainText: string; /** `true` when the value is empty or whitespace-only. */ isEmpty: boolean; /** `true` when the value contains at least one chip. */ hasChips: boolean; /** All chip segments in the current value. */ chips: ChipSegment[]; /** Clear all content (both state and the editor DOM). */ clear: () => void; /** Focus the editor. */ focus: () => void; /** Blur the editor. */ blur: () => void; /** Insert a chip at the current cursor position. */ insertChip: (chip: Omit) => void; }; declare function usePromptAreaState(options?: UsePromptAreaStateOptions): PromptAreaState; /** * Hook that toggles a PromptArea between its markdown and plain-text variants. * * PromptArea's `markdown` prop controls whether inline markdown (bold, italic, * URLs, and list bullets) is rendered and whether typed list markers normalize * to `•`. Flipping it at runtime is non-destructive: the segment value is kept, * only its rendering changes (bullets convert `•` ↔ `-` when `normalizeBullets` * is on). This hook owns that boolean as a named "mode" and hands you a `toggle` * plus a `markdown` value ready to spread onto the component. * * @example * ```tsx * function Composer() { * const { bind } = usePromptAreaState() * const { markdown, mode, toggle } = useMarkdownMode() * * return ( * <> * * * * ) * } * ``` */ /** * The two rendering variants of a PromptArea. * - `'markdown'`: inline markdown is decorated and list markers normalize to `•`. * - `'plain'`: raw source text is shown verbatim with no decoration. */ type PromptAreaMode = 'markdown' | 'plain'; /** Returns the other mode. Pure — handy for building custom toggles. */ declare function oppositeMode(mode: PromptAreaMode): PromptAreaMode; type UseMarkdownModeOptions = { /** Starting mode for the uncontrolled hook. Defaults to `'markdown'`. */ initialMode?: PromptAreaMode; /** * Controlled mode. When provided, the hook mirrors this value and never owns * its own state — drive changes through `onModeChange`. */ mode?: PromptAreaMode; /** Called with the next mode whenever `toggle`/`setMode` change it. */ onModeChange?: (mode: PromptAreaMode) => void; }; type MarkdownModeState = { /** The active mode. */ mode: PromptAreaMode; /** `true` in markdown mode — spread onto ``. */ markdown: boolean; /** `true` in plain-text mode (the inverse of `markdown`). */ isPlainText: boolean; /** Switch to an explicit mode. No-op if already in it. */ setMode: (mode: PromptAreaMode) => void; /** Flip between markdown and plain text. */ toggle: () => void; }; declare function useMarkdownMode(options?: UseMarkdownModeOptions): MarkdownModeState; export { ActiveTrigger, ChipSegment, type MarkdownModeState, PromptArea, type PromptAreaBind, PromptAreaHandle, type PromptAreaMode, PromptAreaProps, type PromptAreaState, Segment, TriggerConfig, TriggerSuggestion, type UseMarkdownModeOptions, type UsePromptAreaStateOptions, oppositeMode, useMarkdownMode, usePromptArea, usePromptAreaState };