@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
26 lines (25 loc) • 939 B
TypeScript
import type { ComponentChildren } from 'preact';
export type ConfirmModalProps = {
title?: string;
message: ComponentChildren;
confirmAction?: string;
cancelAction?: string;
/**
* Determines which of the two buttons should be initially focused.
* Defaults to 'cancel'
*/
initialFocus?: 'cancel' | 'confirm';
};
/**
* Show the user a prompt asking them to confirm an action.
*
* This is like an async version of `window.confirm` except that:
*
* - It can be used inside iframes (browsers are starting to prevent this for
* the native `window.confirm` dialog)
* - The visual style of the dialog matches the Hypothesis design system
*
* @return - Promise that resolves with `true` if the user confirmed the action
* or `false` if they canceled it.
*/
export declare function confirm({ title, message, confirmAction, cancelAction, initialFocus, }: ConfirmModalProps): Promise<boolean>;