import type { ThreadPendingUserInput } from "@t3tools/client-runtime/state/thread-requests"; import { isPendingUserInputOptionSelected, type PendingUserInputDraftAnswer } from "@t3tools/client-runtime/state/pending-user-input"; import { colors } from "./theme.ts"; /** * The web composer's pending-input panel: header with progress, the question, * and its options with digit shortcuts. The composer below takes a typed answer. */ export function QuestionPanel(props: { readonly request: ThreadPendingUserInput; readonly index: number; readonly draft: PendingUserInputDraftAnswer | undefined; }) { const { request, index, draft } = props; const question = request.questions[index]; if (!question) return null; const total = request.questions.length; return ( {question.header} {total > 1 ? `${index + 1}/${total}` : ""} {question.question} {question.options.slice(0, 9).map((option, optionIndex) => { const selected = isPendingUserInputOptionSelected(question, draft, option.value ?? option.label); const mark = question.multiSelect ? (selected ? "☑" : "☐") : selected ? "●" : "○"; return ( {`${optionIndex + 1} ${mark} `} {option.label} {option.description ? ` ${option.description}` : ""} ); })} ); }