summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/packages/puppeteer-core/src/bidi/Dialog.ts
blob: 1774a29f6b249a05eba009a05f50d8a230390917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * @license
 * Copyright 2017 Google Inc.
 * SPDX-License-Identifier: Apache-2.0
 */

import {Dialog} from '../api/Dialog.js';

import type {UserPrompt} from './core/UserPrompt.js';

export class BidiDialog extends Dialog {
  static from(prompt: UserPrompt): BidiDialog {
    return new BidiDialog(prompt);
  }

  #prompt: UserPrompt;
  private constructor(prompt: UserPrompt) {
    super(prompt.info.type, prompt.info.message, prompt.info.defaultValue);
    this.#prompt = prompt;
  }

  override async handle(options: {
    accept: boolean;
    text?: string;
  }): Promise<void> {
    await this.#prompt.handle({
      accept: options.accept,
      userText: options.text,
    });
  }
}