sonner 2.0.0-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +156 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1142 -3
- package/dist/index.mjs +1133 -3
- package/dist/styles.css +25 -15
- package/package.json +14 -7
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type ToastTypes = 'normal' | 'action' | 'success' | 'info' | 'warning' | 'error' | 'loading' | 'default';
|
|
4
|
+
type PromiseT<Data = any> = Promise<Data> | (() => Promise<Data>);
|
|
5
|
+
type PromiseTResult<Data = any> = string | React.ReactNode | ((data: Data) => React.ReactNode | string | Promise<React.ReactNode | string>);
|
|
6
|
+
type PromiseExternalToast = Omit<ExternalToast, 'description'>;
|
|
7
|
+
type PromiseData<ToastData = any> = PromiseExternalToast & {
|
|
8
|
+
loading?: string | React.ReactNode;
|
|
9
|
+
success?: PromiseTResult<ToastData>;
|
|
10
|
+
error?: PromiseTResult;
|
|
11
|
+
description?: PromiseTResult;
|
|
12
|
+
finally?: () => void | Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
interface ToastClassnames {
|
|
15
|
+
toast?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
loader?: string;
|
|
19
|
+
closeButton?: string;
|
|
20
|
+
cancelButton?: string;
|
|
21
|
+
actionButton?: string;
|
|
22
|
+
success?: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
info?: string;
|
|
25
|
+
warning?: string;
|
|
26
|
+
loading?: string;
|
|
27
|
+
default?: string;
|
|
28
|
+
content?: string;
|
|
29
|
+
icon?: string;
|
|
30
|
+
}
|
|
31
|
+
interface ToastIcons {
|
|
32
|
+
success?: React.ReactNode;
|
|
33
|
+
info?: React.ReactNode;
|
|
34
|
+
warning?: React.ReactNode;
|
|
35
|
+
error?: React.ReactNode;
|
|
36
|
+
loading?: React.ReactNode;
|
|
37
|
+
close?: React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
interface Action {
|
|
40
|
+
label: React.ReactNode;
|
|
41
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
42
|
+
actionButtonStyle?: React.CSSProperties;
|
|
43
|
+
}
|
|
44
|
+
interface ToastT {
|
|
45
|
+
id: number | string;
|
|
46
|
+
title?: (() => React.ReactNode) | React.ReactNode;
|
|
47
|
+
type?: ToastTypes;
|
|
48
|
+
icon?: React.ReactNode;
|
|
49
|
+
jsx?: React.ReactNode;
|
|
50
|
+
richColors?: boolean;
|
|
51
|
+
invert?: boolean;
|
|
52
|
+
closeButton?: boolean;
|
|
53
|
+
dismissible?: boolean;
|
|
54
|
+
description?: (() => React.ReactNode) | React.ReactNode;
|
|
55
|
+
duration?: number;
|
|
56
|
+
delete?: boolean;
|
|
57
|
+
action?: Action | React.ReactNode;
|
|
58
|
+
cancel?: Action | React.ReactNode;
|
|
59
|
+
onDismiss?: (toast: ToastT) => void;
|
|
60
|
+
onAutoClose?: (toast: ToastT) => void;
|
|
61
|
+
promise?: PromiseT;
|
|
62
|
+
cancelButtonStyle?: React.CSSProperties;
|
|
63
|
+
actionButtonStyle?: React.CSSProperties;
|
|
64
|
+
style?: React.CSSProperties;
|
|
65
|
+
unstyled?: boolean;
|
|
66
|
+
className?: string;
|
|
67
|
+
classNames?: ToastClassnames;
|
|
68
|
+
descriptionClassName?: string;
|
|
69
|
+
position?: Position;
|
|
70
|
+
}
|
|
71
|
+
type Position = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';
|
|
72
|
+
interface ToastOptions {
|
|
73
|
+
className?: string;
|
|
74
|
+
closeButton?: boolean;
|
|
75
|
+
descriptionClassName?: string;
|
|
76
|
+
style?: React.CSSProperties;
|
|
77
|
+
cancelButtonStyle?: React.CSSProperties;
|
|
78
|
+
actionButtonStyle?: React.CSSProperties;
|
|
79
|
+
duration?: number;
|
|
80
|
+
unstyled?: boolean;
|
|
81
|
+
classNames?: ToastClassnames;
|
|
82
|
+
}
|
|
83
|
+
type Offset = {
|
|
84
|
+
top?: string | number;
|
|
85
|
+
right?: string | number;
|
|
86
|
+
bottom?: string | number;
|
|
87
|
+
left?: string | number;
|
|
88
|
+
} | string | number;
|
|
89
|
+
interface ToasterProps {
|
|
90
|
+
invert?: boolean;
|
|
91
|
+
theme?: 'light' | 'dark' | 'system';
|
|
92
|
+
position?: Position;
|
|
93
|
+
hotkey?: string[];
|
|
94
|
+
richColors?: boolean;
|
|
95
|
+
expand?: boolean;
|
|
96
|
+
duration?: number;
|
|
97
|
+
gap?: number;
|
|
98
|
+
visibleToasts?: number;
|
|
99
|
+
closeButton?: boolean;
|
|
100
|
+
toastOptions?: ToastOptions;
|
|
101
|
+
className?: string;
|
|
102
|
+
style?: React.CSSProperties;
|
|
103
|
+
offset?: Offset;
|
|
104
|
+
mobileOffset?: Offset;
|
|
105
|
+
dir?: 'rtl' | 'ltr' | 'auto';
|
|
106
|
+
swipeDirections?: SwipeDirection[];
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated Please use the `icons` prop instead:
|
|
109
|
+
* ```jsx
|
|
110
|
+
* <Toaster
|
|
111
|
+
* icons={{ loading: <LoadingIcon /> }}
|
|
112
|
+
* />
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
loadingIcon?: React.ReactNode;
|
|
116
|
+
icons?: ToastIcons;
|
|
117
|
+
containerAriaLabel?: string;
|
|
118
|
+
pauseWhenPageIsHidden?: boolean;
|
|
119
|
+
}
|
|
120
|
+
type SwipeDirection = 'top' | 'right' | 'bottom' | 'left';
|
|
121
|
+
interface ToastToDismiss {
|
|
122
|
+
id: number | string;
|
|
123
|
+
dismiss: boolean;
|
|
124
|
+
}
|
|
125
|
+
type ExternalToast = Omit<ToastT, 'id' | 'type' | 'title' | 'jsx' | 'delete' | 'promise'> & {
|
|
126
|
+
id?: number | string;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
type titleT = (() => React.ReactNode) | React.ReactNode;
|
|
130
|
+
declare const toast: ((message: titleT, data?: ExternalToast) => string | number) & {
|
|
131
|
+
success: (message: titleT | React.ReactNode, data?: ExternalToast) => string | number;
|
|
132
|
+
info: (message: titleT | React.ReactNode, data?: ExternalToast) => string | number;
|
|
133
|
+
warning: (message: titleT | React.ReactNode, data?: ExternalToast) => string | number;
|
|
134
|
+
error: (message: titleT | React.ReactNode, data?: ExternalToast) => string | number;
|
|
135
|
+
custom: (jsx: (id: number | string) => React.ReactElement, data?: ExternalToast) => string | number;
|
|
136
|
+
message: (message: titleT | React.ReactNode, data?: ExternalToast) => string | number;
|
|
137
|
+
promise: <ToastData>(promise: PromiseT<ToastData>, data?: PromiseData<ToastData>) => (string & {
|
|
138
|
+
unwrap: () => Promise<ToastData>;
|
|
139
|
+
}) | (number & {
|
|
140
|
+
unwrap: () => Promise<ToastData>;
|
|
141
|
+
}) | {
|
|
142
|
+
unwrap: () => Promise<ToastData>;
|
|
143
|
+
};
|
|
144
|
+
dismiss: (id?: number | string) => string | number;
|
|
145
|
+
loading: (message: titleT | React.ReactNode, data?: ExternalToast) => string | number;
|
|
146
|
+
} & {
|
|
147
|
+
getHistory: () => (ToastT | ToastToDismiss)[];
|
|
148
|
+
getToasts: () => (ToastT | ToastToDismiss)[];
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
declare function useSonner(): {
|
|
152
|
+
toasts: ToastT[];
|
|
153
|
+
};
|
|
154
|
+
declare const Toaster: React.ForwardRefExoticComponent<ToasterProps & React.RefAttributes<HTMLElement>>;
|
|
155
|
+
|
|
156
|
+
export { type Action, type ExternalToast, type ToastClassnames, type ToastT, type ToastToDismiss, Toaster, type ToasterProps, toast, useSonner };
|
package/dist/index.d.ts
CHANGED
|
@@ -153,4 +153,4 @@ declare function useSonner(): {
|
|
|
153
153
|
};
|
|
154
154
|
declare const Toaster: React.ForwardRefExoticComponent<ToasterProps & React.RefAttributes<HTMLElement>>;
|
|
155
155
|
|
|
156
|
-
export { Action, ExternalToast, ToastClassnames, ToastT, ToastToDismiss, Toaster, ToasterProps, toast, useSonner };
|
|
156
|
+
export { type Action, type ExternalToast, type ToastClassnames, type ToastT, type ToastToDismiss, Toaster, type ToasterProps, toast, useSonner };
|