mirror of
https://github.com/bitwarden/clients.git
synced 2026-02-08 09:53:43 +08:00
This PR introduces a generic `DialogService` which can be used by all the clients. This allows us to decouple dialogs from the `PlatformUtilsHelper`. The `DialogService` provides a new method, `openSimpleDialog` which is the new interface for that type of dialogs. This gives us 3 different implementations: - Web: DialogService modern dialogs - Browser: SweetAlert - Desktop: Native electron based
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { SimpleDialogType } from "./simple-dialog-type.enum";
|
|
import { Translation } from "./translation";
|
|
|
|
// Using type lets devs skip optional params w/out having to pass undefined.
|
|
/**
|
|
*
|
|
* @typedef {Object} SimpleDialogOptions - A configuration type for the Simple Dialog component
|
|
*/
|
|
export type SimpleDialogOptions = {
|
|
/**
|
|
* Dialog title.
|
|
*
|
|
* If not localized, pass in a `Translation`. */
|
|
title: string | Translation;
|
|
|
|
/** Dialog content.
|
|
*
|
|
* If not localized, pass in a `Translation`. */
|
|
content: string | Translation;
|
|
|
|
/** Dialog type. It controls default icons and icon colors. */
|
|
type: SimpleDialogType;
|
|
|
|
/** Dialog custom icon class.
|
|
*
|
|
* If not provided, a standard icon will be inferred from type.
|
|
* Note: icon color is enforced based on dialog type. */
|
|
icon?: string;
|
|
|
|
/** Dialog custom accept button text.
|
|
*
|
|
* If not provided, ("yes" | i18n) will be used.
|
|
*
|
|
* If not localized, pass in a `Translation` */
|
|
acceptButtonText?: string | Translation;
|
|
|
|
/**
|
|
* Dialog custom cancel button text.
|
|
*
|
|
* If not provided, ("no" | i18n) will be used.
|
|
*
|
|
* If custom acceptButtonText is passed in, ("cancel" | i18n) will be used.
|
|
*
|
|
* If null is provided, the cancel button will be removed.
|
|
*
|
|
* If not localized, pass in a `Translation` */
|
|
cancelButtonText?: string | Translation;
|
|
|
|
/** Whether or not the user can use escape or clicking the backdrop to close the dialog */
|
|
disableClose?: boolean;
|
|
};
|