import { Event } from '../../../base/common/event.js'; import { ThemeIcon } from '../../../base/common/themables.js'; import { IMarkdownString } from '../../../base/common/htmlContent.js'; import Severity from '../../../base/common/severity.js'; export interface IBaseDialogOptions { readonly type?: Severity | DialogType; readonly title?: string; readonly message: string; readonly detail?: string; readonly checkbox?: ICheckbox; /** * Allows to enforce use of custom dialog even in native environments. */ readonly custom?: boolean | ICustomDialogOptions; } export interface IConfirmation extends IBaseDialogOptions { /** * If not provided, defaults to `Yes`. */ readonly primaryButton?: string; /** * If not provided, defaults to `Cancel`. */ readonly cancelButton?: string; } export interface IConfirmationResult extends ICheckboxResult { /** * Will be true if the dialog was confirmed with the primary button pressed. */ readonly confirmed: boolean; } export interface IInput extends IConfirmation { readonly inputs: IInputElement[]; /** * If not provided, defaults to `Ok`. */ readonly primaryButton?: string; } export interface IInputElement { readonly type?: 'text' | 'password'; readonly value?: string; readonly placeholder?: string; } export interface IInputResult extends IConfirmationResult { /** * Values for the input fields as provided by the user or `undefined` if none. */ readonly values?: string[]; } export interface IPromptBaseButton { /** * @returns the result of the prompt button will be returned * as result from the `prompt()` call. */ run(checkbox: ICheckboxResult): T | Promise; } export interface IPromptButton extends IPromptBaseButton { readonly label: string; } export interface IPromptCancelButton extends IPromptBaseButton { /** * The cancel button to show in the prompt. Defaults to * `Cancel` if not provided. */ readonly label?: string; } export interface IPrompt extends IBaseDialogOptions { /** * The buttons to show in the prompt. Defaults to `OK` * if no buttons or cancel button is provided. */ readonly buttons?: IPromptButton[]; /** * The cancel button to show in the prompt. Defaults to * `Cancel` if set to `true`. */ readonly cancelButton?: IPromptCancelButton | true | string; } export interface IPromptWithCustomCancel extends IPrompt { readonly cancelButton: IPromptCancelButton; } export interface IPromptWithDefaultCancel extends IPrompt { readonly cancelButton: true | string; } export interface IPromptResult extends ICheckboxResult { /** * The result of the `IPromptButton` that was pressed or `undefined` if none. */ readonly result?: T; } export interface IPromptResultWithCancel extends IPromptResult { readonly result: T; } export type DialogType = 'none' | 'info' | 'error' | 'question' | 'warning'; export interface ICheckbox { readonly label: string; readonly checked?: boolean; } export interface ICheckboxResult { /** * This will only be defined if the confirmation was created * with the checkbox option defined. */ readonly checkboxChecked?: boolean; } export declare const IDialogService: import("../../instantiation/common/instantiation.js").ServiceIdentifier; export interface ICustomDialogOptions { readonly buttonDetails?: string[]; readonly markdownDetails?: ICustomDialogMarkdown[]; readonly classes?: string[]; readonly icon?: ThemeIcon; readonly disableCloseAction?: boolean; readonly closeOnLinkClick?: boolean; } export interface ICustomDialogMarkdown { readonly markdown: IMarkdownString; readonly classes?: string[]; } /** * A service to bring up modal dialogs. * * Note: use the `INotificationService.prompt()` method for a non-modal way to ask * the user for input. */ export interface IDialogService { readonly _serviceBrand: undefined; /** * An event that fires when a dialog is about to show. */ onWillShowDialog: Event; /** * An event that fires when a dialog did show (closed). */ onDidShowDialog: Event; /** * Ask the user for confirmation with a modal dialog. */ confirm(confirmation: IConfirmation): Promise; /** * Prompt the user with a modal dialog. Provides a bit * more control over the dialog compared to the simpler * `confirm` method. Specifically, allows to show more * than 2 buttons and makes it easier to just show a * message to the user. * * @returns a promise that resolves to the `T` result * from the provided `IPromptButton` or `undefined`. */ prompt(prompt: IPromptWithCustomCancel): Promise>; prompt(prompt: IPromptWithDefaultCancel): Promise>; prompt(prompt: IPrompt): Promise>; /** * Present a modal dialog to the user asking for input. */ input(input: IInput): Promise; /** * Show a modal info dialog. */ info(message: string, detail?: string): Promise; /** * Show a modal warning dialog. */ warn(message: string, detail?: string): Promise; /** * Show a modal error dialog. */ error(message: string, detail?: string): Promise; /** * Present the about dialog to the user. */ about(): Promise; }