UNPKG

4.11 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2, Intent, Props, MaybeElement } from "../../common";
3import { IconName } from "../icon/icon";
4import { IOverlayLifecycleProps } from "../overlay/overlay";
5export declare type AlertProps = IAlertProps;
6/** @deprecated use AlertProps */
7export interface IAlertProps extends IOverlayLifecycleProps, Props {
8 /**
9 * Whether pressing <kbd>escape</kbd> when focused on the Alert should cancel the alert.
10 * If this prop is enabled, then either `onCancel` or `onClose` must also be defined.
11 *
12 * @default false
13 */
14 canEscapeKeyCancel?: boolean;
15 /**
16 * Whether clicking outside the Alert should cancel the alert.
17 * If this prop is enabled, then either `onCancel` or `onClose` must also be defined.
18 *
19 * @default false
20 */
21 canOutsideClickCancel?: boolean;
22 /**
23 * The text for the cancel button.
24 * If this prop is defined, then either `onCancel` or `onClose` must also be defined.
25 */
26 cancelButtonText?: string;
27 /**
28 * The text for the confirm (right-most) button.
29 * This button will always appear, and uses the value of the `intent` prop below.
30 *
31 * @default "OK"
32 */
33 confirmButtonText?: string;
34 /** Name of a Blueprint UI icon (or an icon element) to display on the left side. */
35 icon?: IconName | MaybeElement;
36 /**
37 * The intent to be applied to the confirm (right-most) button and the icon (if provided).
38 */
39 intent?: Intent;
40 /**
41 * Toggles the visibility of the alert.
42 * This prop is required because the component is controlled.
43 */
44 isOpen: boolean;
45 /**
46 * If set to `true`, the confirm button will be set to its loading state. The cancel button, if
47 * visible, will be disabled.
48 *
49 * @default false
50 */
51 loading?: boolean;
52 /**
53 * CSS styles to apply to the alert.
54 */
55 style?: React.CSSProperties;
56 /**
57 * Indicates how long (in milliseconds) the overlay's enter/leave transition takes.
58 * This is used by React `CSSTransition` to know when a transition completes and must match
59 * the duration of the animation in CSS. Only set this prop if you override Blueprint's default
60 * transitions with new transitions of a different length.
61 *
62 * @default 300
63 */
64 transitionDuration?: number;
65 /**
66 * The container element into which the overlay renders its contents, when `usePortal` is `true`.
67 * This prop is ignored if `usePortal` is `false`.
68 *
69 * @default document.body
70 */
71 portalContainer?: HTMLElement;
72 /**
73 * Handler invoked when the alert is canceled. Alerts can be **canceled** in the following ways:
74 * - clicking the cancel button (if `cancelButtonText` is defined)
75 * - pressing the escape key (if `canEscapeKeyCancel` is enabled)
76 * - clicking on the overlay backdrop (if `canOutsideClickCancel` is enabled)
77 *
78 * If any of the `cancel` props are defined, then either `onCancel` or `onClose` must be defined.
79 */
80 onCancel?(evt?: React.SyntheticEvent<HTMLElement>): void;
81 /**
82 * Handler invoked when the confirm button is clicked. Alerts can be **confirmed** in the following ways:
83 * - clicking the confirm button
84 * - focusing on the confirm button and pressing `enter` or `space`
85 */
86 onConfirm?(evt?: React.SyntheticEvent<HTMLElement>): void;
87 /**
88 * Handler invoked when the Alert is confirmed or canceled; see `onConfirm` and `onCancel` for more details.
89 * First argument is `true` if confirmed, `false` otherwise.
90 * This is an alternative to defining separate `onConfirm` and `onCancel` handlers.
91 */
92 onClose?(confirmed: boolean, evt?: React.SyntheticEvent<HTMLElement>): void;
93}
94export declare class Alert extends AbstractPureComponent2<AlertProps> {
95 static defaultProps: AlertProps;
96 static displayName: string;
97 render(): JSX.Element;
98 protected validateProps(props: AlertProps): void;
99 private handleCancel;
100 private handleConfirm;
101 private internalHandleCallbacks;
102}