UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

61 lines (60 loc) 1.94 kB
/** * @typedef {import('./Dialog').DialogProps} DialogProps */ /** * @typedef ModalBaseProps * @prop {() => void} onCancel - `onCancel` is required for Modals */ /** * @typedef {DialogProps & ModalBaseProps} ModalProps */ /** * A modal dialog. Presents a dialog with an overlay background. Will close * if user clicks/taps outside of it. * * @param {ModalProps} props */ export function Modal({ children, onCancel, ...restProps }: ModalProps): import("preact").JSX.Element; /** * @typedef ConfirmModalBaseProps * @prop {string} message - Main text of the modal message * @prop {string} confirmAction - Label for the "Confirm" button * @prop {() => void} onConfirm - Callback invoked if the user clicks the "Confirm" button * @prop {() => void} onCancel - Callback invoked if the user cancels * * @typedef {Omit<ModalProps, 'buttons' | 'children'> & ConfirmModalBaseProps} ConfirmModalProps */ /** * A modal that emulates a `window.confirm` interface: * request a boolean yes/no confirmation from the user. * * @param {ConfirmModalProps} props */ export function ConfirmModal({ message, confirmAction, onConfirm, onCancel, ...restProps }: ConfirmModalProps): import("preact").JSX.Element; export type DialogProps = import('./Dialog').DialogProps; export type ModalBaseProps = { /** * - `onCancel` is required for Modals */ onCancel: () => void; }; export type ModalProps = DialogProps & ModalBaseProps; export type ConfirmModalBaseProps = { /** * - Main text of the modal message */ message: string; /** * - Label for the "Confirm" button */ confirmAction: string; /** * - Callback invoked if the user clicks the "Confirm" button */ onConfirm: () => void; /** * - Callback invoked if the user cancels */ onCancel: () => void; }; export type ConfirmModalProps = Omit<ModalProps, 'buttons' | 'children'> & ConfirmModalBaseProps;