1 | import * as React from 'react';
|
2 | import {StyletronComponent} from 'styletron-react';
|
3 | import {Override} from '../overrides';
|
4 |
|
5 | export interface KIND {
|
6 | info: 'info';
|
7 | positive: 'positive';
|
8 | warning: 'warning';
|
9 | negative: 'negative';
|
10 | }
|
11 | export interface PLACEMENT {
|
12 | topLeft: 'topLeft';
|
13 | top: 'top';
|
14 | topRight: 'topRight';
|
15 | bottomRight: 'bottomRight';
|
16 | bottom: 'bottom';
|
17 | bottomLeft: 'bottomLeft';
|
18 | }
|
19 | export interface TYPE {
|
20 | inline: 'inline';
|
21 | toast: 'toast';
|
22 | }
|
23 |
|
24 | export interface IToaster {
|
25 | getRef: () => React.Ref<typeof ToasterContainer>;
|
26 | show: (children: React.ReactNode, props: Readonly<ToastProps>) => React.Key;
|
27 | info: (children: React.ReactNode, props: Readonly<ToastProps>) => React.Key;
|
28 | positive: (
|
29 | children: React.ReactNode,
|
30 | props: Readonly<ToastProps>,
|
31 | ) => React.Key;
|
32 | warning: (
|
33 | children: React.ReactNode,
|
34 | props: Readonly<ToastProps>,
|
35 | ) => React.Key;
|
36 | negative: (
|
37 | children: React.ReactNode,
|
38 | props: Readonly<ToastProps>,
|
39 | ) => React.Key;
|
40 | update: (key: React.Key, props: Readonly<ToastProps>) => void;
|
41 | clear: (key: React.Key) => void;
|
42 | }
|
43 |
|
44 | export const toaster: IToaster;
|
45 |
|
46 | export interface ToasterContainerState {
|
47 | isMounted: boolean;
|
48 | toasts: Readonly<ToastProps>;
|
49 | }
|
50 | export interface ToasterSharedStylePropsArg {
|
51 | $placement?: PLACEMENT[keyof PLACEMENT];
|
52 | }
|
53 | export interface ToasterOverrides {
|
54 | Root?: Override<ToasterSharedStylePropsArg>;
|
55 | ToastBody?: Override<SharedStylePropsArg>;
|
56 | ToastCloseIcon?: Override<SharedStylePropsArg>;
|
57 | }
|
58 | export interface ToasterProps {
|
59 | overrides?: ToasterOverrides;
|
60 | placement?: PLACEMENT[keyof PLACEMENT];
|
61 | usePortal?: boolean;
|
62 | autoHideDuration?: number;
|
63 | }
|
64 | export class ToasterContainer extends React.Component<
|
65 | Readonly<ToasterProps>,
|
66 | ToasterContainerState
|
67 | > {
|
68 | getToastProps(props: ToastProps): Readonly<ToastProps> & {key: React.Key};
|
69 | show(props: ToastProps): React.Key;
|
70 | update(key: React.Key, props: ToastProps): void;
|
71 | dismiss(key: React.Key): void;
|
72 | clearAll(): void;
|
73 | clear(key: React.Key): void;
|
74 | internalOnClose(key: React.Key): void;
|
75 | getOnCloseHandler(key: React.Key, onClose?: () => any): () => any;
|
76 | renderToast(toastProps: ToastProps & {key: React.Key}): React.ReactNode;
|
77 | getSharedProps(): {$placement: PLACEMENT[keyof PLACEMENT]};
|
78 | }
|
79 |
|
80 | export interface SharedStylePropsArg {
|
81 | $kind?: KIND[keyof KIND];
|
82 | $type?: TYPE[keyof TYPE];
|
83 | $closeable?: boolean;
|
84 | $isRendered?: boolean;
|
85 | $isVisible?: boolean;
|
86 | }
|
87 |
|
88 | export interface ToastPrivateState {
|
89 | isVisible: boolean;
|
90 | isRendered: boolean;
|
91 | }
|
92 |
|
93 | export interface ToastOverrides {
|
94 | Body?: Override<SharedStylePropsArg>;
|
95 | CloseIcon?: Override<SharedStylePropsArg>;
|
96 | InnerContainer?: Override<SharedStylePropsArg>;
|
97 | }
|
98 | export interface ToastProps {
|
99 | autoHideDuration?: number;
|
100 | autoFocus?: Boolean;
|
101 | children?:
|
102 | | ((args: {dismiss: () => void}) => React.ReactNode)
|
103 | | React.ReactNode;
|
104 | closeable?: boolean;
|
105 | kind?: KIND[keyof KIND];
|
106 | notificationType?: TYPE[keyof TYPE];
|
107 | onClose?: () => any;
|
108 | onBlur?: (e: Event) => any;
|
109 | onFocus?: (e: Event) => any;
|
110 | onMouseEnter?: (e: Event) => any;
|
111 | onMouseLeave?: (e: Event) => any;
|
112 | 'data-baseweb'?: string;
|
113 | overrides?: ToastOverrides;
|
114 | key?: React.Key;
|
115 | }
|
116 |
|
117 | export class Toast extends React.Component<ToastProps, ToastPrivateState> {
|
118 | startTimeout(): void;
|
119 | clearTimeout(): void;
|
120 | animateIn(): void;
|
121 | animateOut(): void;
|
122 | dismiss(): void;
|
123 | onFocus(e: Event): void;
|
124 | onMouseEnter(e: Event): void;
|
125 | onBlur(e: Event): void;
|
126 | onMouseLeave(e: Event): void;
|
127 | getSharedProps(): Readonly<SharedStylePropsArg>;
|
128 | }
|
129 |
|
130 | export const Root: StyletronComponent<any>;
|
131 | export const Body: StyletronComponent<any>;
|
132 | export const CloseIconSvg: StyletronComponent<any>;
|
133 |
|
134 | export const KIND: KIND;
|
135 | export const PLACEMENT: PLACEMENT;
|
136 | export const TYPE: TYPE;
|