Dialog.ts (729B)
1 /** 2 * @license 3 * Copyright 2017 Google Inc. 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 import {Dialog} from '../api/Dialog.js'; 8 9 import type {UserPrompt} from './core/UserPrompt.js'; 10 11 export class BidiDialog extends Dialog { 12 static from(prompt: UserPrompt): BidiDialog { 13 return new BidiDialog(prompt); 14 } 15 16 #prompt: UserPrompt; 17 private constructor(prompt: UserPrompt) { 18 super(prompt.info.type, prompt.info.message, prompt.info.defaultValue); 19 this.#prompt = prompt; 20 this.handled = prompt.handled; 21 } 22 23 override async handle(options: { 24 accept: boolean; 25 text?: string; 26 }): Promise<void> { 27 await this.#prompt.handle({ 28 accept: options.accept, 29 userText: options.text, 30 }); 31 } 32 }