1 | import * as React from "react";
|
2 | import { AbstractPureComponent2, Position } from "../../common";
|
3 | import { Props } from "../../common/props";
|
4 | import { ToastProps } from "./toast";
|
5 | export declare type IToastOptions = ToastProps & {
|
6 | key: string;
|
7 | };
|
8 | export declare type ToasterPosition = typeof Position.TOP | typeof Position.TOP_LEFT | typeof Position.TOP_RIGHT | typeof Position.BOTTOM | typeof Position.BOTTOM_LEFT | typeof Position.BOTTOM_RIGHT;
|
9 | /** @deprecated use ToasterInstance */
|
10 | export declare type IToaster = ToasterInstance;
|
11 | /** Public API methods available on a `<Toaster>` component instance. */
|
12 | export interface ToasterInstance {
|
13 | /**
|
14 | * Shows a new toast to the user, or updates an existing toast corresponding to the provided key (optional).
|
15 | *
|
16 | * Returns the unique key of the toast.
|
17 | */
|
18 | show(props: ToastProps, key?: string): string;
|
19 | /** Dismiss the given toast instantly. */
|
20 | dismiss(key: string): void;
|
21 | /** Dismiss all toasts instantly. */
|
22 | clear(): void;
|
23 | /** Returns the props for all current toasts. */
|
24 | getToasts(): IToastOptions[];
|
25 | }
|
26 | /**
|
27 | * Props supported by the `<Toaster>` component.
|
28 | * These props can be passed as an argument to the static `Toaster.create(props?, container?)` method.
|
29 | */
|
30 | export interface IToasterProps extends Props {
|
31 | /**
|
32 | * Whether a toast should acquire application focus when it first opens.
|
33 | * This is disabled by default so that toasts do not interrupt the user's flow.
|
34 | * Note that `enforceFocus` is always disabled for `Toaster`s.
|
35 | *
|
36 | * @default false
|
37 | */
|
38 | autoFocus?: boolean;
|
39 | /**
|
40 | * Whether pressing the `esc` key should clear all active toasts.
|
41 | *
|
42 | * @default true
|
43 | */
|
44 | canEscapeKeyClear?: boolean;
|
45 | /** Optional toast elements. */
|
46 | children?: React.ReactNode;
|
47 | /**
|
48 | * Whether the toaster should be rendered into a new element attached to `document.body`.
|
49 | * If `false`, then positioning will be relative to the parent element.
|
50 | *
|
51 | * This prop is ignored by `Toaster.create()` as that method always appends a new element
|
52 | * to the container.
|
53 | *
|
54 | * @default true
|
55 | */
|
56 | usePortal?: boolean;
|
57 | /**
|
58 | * Position of `Toaster` within its container.
|
59 | *
|
60 | * @default Position.TOP
|
61 | */
|
62 | position?: ToasterPosition;
|
63 | /**
|
64 | * The maximum number of active toasts that can be displayed at once.
|
65 | *
|
66 | * When the limit is about to be exceeded, the oldest active toast is removed.
|
67 | *
|
68 | * @default undefined
|
69 | */
|
70 | maxToasts?: number;
|
71 | }
|
72 | export interface IToasterState {
|
73 | toasts: IToastOptions[];
|
74 | }
|
75 | /**
|
76 | * Toaster component.
|
77 | *
|
78 | * @see https://blueprintjs.com/docs/#core/components/toast.toaster
|
79 | */
|
80 | export declare class Toaster extends AbstractPureComponent2<IToasterProps, IToasterState> implements ToasterInstance {
|
81 | static displayName: string;
|
82 | static defaultProps: IToasterProps;
|
83 | /**
|
84 | * Create a new `Toaster` instance that can be shared around your application.
|
85 | * The `Toaster` will be rendered into a new element appended to the given container.
|
86 | */
|
87 | static create(props?: IToasterProps, container?: HTMLElement): ToasterInstance;
|
88 | state: IToasterState;
|
89 | private toastId;
|
90 | show(props: ToastProps, key?: string): string;
|
91 | dismiss(key: string, timeoutExpired?: boolean): void;
|
92 | clear(): void;
|
93 | getToasts(): IToastOptions[];
|
94 | render(): JSX.Element;
|
95 | protected validateProps({ maxToasts }: IToasterProps): void;
|
96 | private isNewToastKey;
|
97 | private dismissIfAtLimit;
|
98 | private renderToast;
|
99 | private createToastOptions;
|
100 | private getPositionClasses;
|
101 | private getDismissHandler;
|
102 | private handleClose;
|
103 | }
|
104 | export declare const OverlayToaster: typeof Toaster;
|
105 | export declare type OverlayToasterProps = IToasterProps;
|