UNPKG

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