1 | import * as React from "react";
|
2 | import { AbstractPureComponent, Intent, MaybeElement, Props } from "../../common";
|
3 | import { IconName } from "../icon/icon";
|
4 | import { OverlayLifecycleProps } from "../overlay/overlay";
|
5 | export interface AlertProps extends OverlayLifecycleProps, Props {
|
6 | /**
|
7 | * Whether pressing <kbd>escape</kbd> when focused on the Alert should cancel the alert.
|
8 | * If this prop is enabled, then either `onCancel` or `onClose` must also be defined.
|
9 | *
|
10 | * @default false
|
11 | */
|
12 | canEscapeKeyCancel?: boolean;
|
13 | /**
|
14 | * Whether clicking outside the Alert should cancel the alert.
|
15 | * If this prop is enabled, then either `onCancel` or `onClose` must also be defined.
|
16 | *
|
17 | * @default false
|
18 | */
|
19 | canOutsideClickCancel?: boolean;
|
20 | /**
|
21 | * The text for the cancel button.
|
22 | * If this prop is defined, then either `onCancel` or `onClose` must also be defined.
|
23 | */
|
24 | cancelButtonText?: string;
|
25 | /** Dialog contents. */
|
26 | children?: React.ReactNode;
|
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 | }
|
94 | /**
|
95 | * Alert component.
|
96 | *
|
97 | * @see https://blueprintjs.com/docs/#core/components/alert
|
98 | */
|
99 | export declare class Alert extends AbstractPureComponent<AlertProps> {
|
100 | static defaultProps: AlertProps;
|
101 | static displayName: string;
|
102 | render(): JSX.Element;
|
103 | protected validateProps(props: AlertProps): void;
|
104 | private handleCancel;
|
105 | private handleConfirm;
|
106 | private internalHandleCallbacks;
|
107 | }
|