import { ReactNode } from 'react'; /** * `single` uses radio semantics; `multi` uses checkboxes and narrows the value * and callback types accordingly. */ export type AgentPromptSelectionMode = "single" | "multi"; /** * Semantic question level, independent of visual size. Starts at `h2` because * the prompt is never the page title. */ export type AgentPromptHeadingLevel = "h2" | "h3" | "h4" | "h5" | "h6"; export type AgentPromptOption = { /** Stable selection value and React key. */ value: string; /** Display content; accepts emoji and inline markup. */ label: ReactNode; /** Makes this row inert without disabling the prompt's other controls. */ isDisabled?: boolean; }; /** * Multi-step position when `total` is greater than 1. First shows Next; middle * shows Back/Next; last shows Back/Send. */ export type AgentPromptStep = { /** 1-based index of the current step. */ current: number; /** Denominator for the header count; the last step replaces Next with Send. */ total: number; }; /** Props shared by both selection modes. */ type AgentPromptCommonProps = { /** Rendered as the heading and used to name the options group. */ question: string; /** Rendered in order as radio or checkbox rows. */ options: AgentPromptOption[]; /** * Controlled "Something else…" text. In single mode a selected row wins but * text is retained; in multi mode Send/Next appends it to checked values. */ otherValue?: string; /** * Updates free text. Providing it shows the row by default. */ onOtherChange?: (value: string) => void; /** Free-text placeholder. Defaults to localized "Something else…". */ otherPlaceholder?: string; /** * Overrides free-text row visibility. Defaults to whether * {@link onOtherChange} exists; `true` without a handler warns in development. */ allowOther?: boolean; /** * Adds a header count and Back/Next/Send stepper when `total` is greater than * 1. Omit, or pass `total: 1`, for one Send action. */ step?: AgentPromptStep; /** Close remains available while the prompt is disabled. */ onClose: () => void; /** * Shown on non-first stepper steps; skips answer validation. Omit to leave * Back enabled but inert. */ onBack?: () => void; /** * Overrides the localized empty-answer error. */ emptyErrorMessage?: string; /** Defaults to `"h2"`. See {@link AgentPromptHeadingLevel}. */ headingLevel?: AgentPromptHeadingLevel; /** Makes every control except Close inert. */ disabled?: boolean; className?: string; }; /** Single-select form: one option value (or none). The default mode. */ export type AgentPromptSingleProps = AgentPromptCommonProps & { /** Selects radio semantics. Defaults to `single`. */ selectionMode?: "single"; /** Selected option value; `null` leaves the radio rows unselected. */ value: string | null; /** Reports the next option value; selecting free text reports `null`. */ onChange: (value: string | null) => void; /** * Commits the selected value or verbatim nonblank free text. Empty submission * shows the error instead of calling this. Without it, Send validates but * does not emit. */ onSend?: (answer: string | null) => void; /** * Commits the same resolved answer for Next. Without it, Next validates but * does not advance. */ onNext?: (answer: string | null) => void; }; /** Multi-select form: a set of option values. */ export type AgentPromptMultiProps = AgentPromptCommonProps & { /** Selects checkbox semantics. */ selectionMode: "multi"; /** Selected option values; free text remains separate in `otherValue`. */ value: string[]; /** Reports checked option values without appending free text. */ onChange: (value: string[]) => void; /** * Commits checked values with nonblank free text appended. Empty submission * shows the error instead of calling this. Without it, Send validates but * does not emit. */ onSend?: (answer: string[]) => void; /** * Commits the same resolved array for Next. Without it, Next validates but * does not advance. */ onNext?: (answer: string[]) => void; }; /** * Single- or multi-select clarifying prompt with optional free text. */ export type AgentPromptProps = AgentPromptSingleProps | AgentPromptMultiProps; export {};