react-native-sooner 1.0.0
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/LICENSE +20 -0
- package/README.md +376 -0
- package/lib/module/constants.js +40 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/context.js +25 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/easings.js +9 -0
- package/lib/module/easings.js.map +1 -0
- package/lib/module/gestures.js +119 -0
- package/lib/module/gestures.js.map +1 -0
- package/lib/module/hooks.js +9 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/icons.js +332 -0
- package/lib/module/icons.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/state.js +200 -0
- package/lib/module/state.js.map +1 -0
- package/lib/module/theme.js +189 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/toast.js +362 -0
- package/lib/module/toast.js.map +1 -0
- package/lib/module/toaster.js +198 -0
- package/lib/module/toaster.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/use-app-state.js +13 -0
- package/lib/module/use-app-state.js.map +1 -0
- package/lib/module/use-pauseable-timer.js +18 -0
- package/lib/module/use-pauseable-timer.js.map +1 -0
- package/lib/module/use-toast-state.js +37 -0
- package/lib/module/use-toast-state.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/constants.d.ts +32 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/context.d.ts +20 -0
- package/lib/typescript/src/context.d.ts.map +1 -0
- package/lib/typescript/src/easings.d.ts +6 -0
- package/lib/typescript/src/easings.d.ts.map +1 -0
- package/lib/typescript/src/gestures.d.ts +17 -0
- package/lib/typescript/src/gestures.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +5 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/icons.d.ts +15 -0
- package/lib/typescript/src/icons.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/state.d.ts +66 -0
- package/lib/typescript/src/state.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +163 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/toast.d.ts +3 -0
- package/lib/typescript/src/toast.d.ts.map +1 -0
- package/lib/typescript/src/toaster.d.ts +3 -0
- package/lib/typescript/src/toaster.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +264 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/use-app-state.d.ts +3 -0
- package/lib/typescript/src/use-app-state.d.ts.map +1 -0
- package/lib/typescript/src/use-pauseable-timer.d.ts +2 -0
- package/lib/typescript/src/use-pauseable-timer.d.ts.map +1 -0
- package/lib/typescript/src/use-toast-state.d.ts +7 -0
- package/lib/typescript/src/use-toast-state.d.ts.map +1 -0
- package/package.json +152 -0
- package/src/constants.ts +44 -0
- package/src/context.tsx +38 -0
- package/src/easings.ts +7 -0
- package/src/gestures.tsx +135 -0
- package/src/hooks.ts +3 -0
- package/src/icons.tsx +227 -0
- package/src/index.tsx +48 -0
- package/src/state.ts +262 -0
- package/src/theme.ts +170 -0
- package/src/toast.tsx +429 -0
- package/src/toaster.tsx +221 -0
- package/src/types.ts +311 -0
- package/src/use-app-state.ts +15 -0
- package/src/use-pauseable-timer.ts +24 -0
- package/src/use-toast-state.ts +43 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useMemo } from "react";
|
|
4
|
+
import { AccessibilityInfo, Platform, StyleSheet, View } from "react-native";
|
|
5
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
6
|
+
import { ANIMATION_DEFAULTS, toastDefaults } from "./constants.js";
|
|
7
|
+
import { ToastState } from "./state.js";
|
|
8
|
+
import { resolveTheme } from "./theme.js";
|
|
9
|
+
import { Toast } from "./toast.js";
|
|
10
|
+
import { useToastState } from "./use-toast-state.js";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function getContainerStyle(position, offset) {
|
|
13
|
+
const isTop = position.startsWith("top");
|
|
14
|
+
const isBottom = position.startsWith("bottom");
|
|
15
|
+
const style = {
|
|
16
|
+
position: "absolute",
|
|
17
|
+
left: offset.left,
|
|
18
|
+
right: offset.right,
|
|
19
|
+
flexDirection: "column"
|
|
20
|
+
};
|
|
21
|
+
if (isTop) {
|
|
22
|
+
style.top = offset.top;
|
|
23
|
+
} else if (isBottom) {
|
|
24
|
+
style.bottom = offset.bottom;
|
|
25
|
+
style.flexDirection = "column-reverse";
|
|
26
|
+
}
|
|
27
|
+
if (position.includes("left")) {
|
|
28
|
+
style.alignItems = "flex-start";
|
|
29
|
+
} else if (position.includes("right")) {
|
|
30
|
+
style.alignItems = "flex-end";
|
|
31
|
+
} else {
|
|
32
|
+
style.alignItems = "center";
|
|
33
|
+
}
|
|
34
|
+
return style;
|
|
35
|
+
}
|
|
36
|
+
function announceForAccessibility(toast) {
|
|
37
|
+
if (toast.accessibility?.announceToScreenReader === false) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const message = toast.accessibility?.accessibilityLabel ?? (typeof toast.title === "string" ? toast.title : "Notification");
|
|
41
|
+
if (Platform.OS === "ios" || Platform.OS === "android") {
|
|
42
|
+
AccessibilityInfo.announceForAccessibility(message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function Toaster({
|
|
46
|
+
position = toastDefaults.position,
|
|
47
|
+
theme = toastDefaults.theme,
|
|
48
|
+
duration = toastDefaults.duration,
|
|
49
|
+
gap = toastDefaults.gap,
|
|
50
|
+
offset: customOffset,
|
|
51
|
+
swipeToDismiss = toastDefaults.swipeToDismiss,
|
|
52
|
+
swipeDirection = toastDefaults.swipeDirection,
|
|
53
|
+
pauseOnAppBackground = toastDefaults.pauseOnAppBackground,
|
|
54
|
+
visibleToasts = toastDefaults.visibleToasts,
|
|
55
|
+
icons,
|
|
56
|
+
toastStyles,
|
|
57
|
+
containerStyle,
|
|
58
|
+
richColors = toastDefaults.richColors,
|
|
59
|
+
closeButton = toastDefaults.closeButton,
|
|
60
|
+
toasterId,
|
|
61
|
+
animation,
|
|
62
|
+
hapticFeedback = toastDefaults.hapticFeedback
|
|
63
|
+
}) {
|
|
64
|
+
const insets = useSafeAreaInsets();
|
|
65
|
+
const {
|
|
66
|
+
toasts
|
|
67
|
+
} = useToastState();
|
|
68
|
+
const resolvedTheme = resolveTheme(theme);
|
|
69
|
+
|
|
70
|
+
// Merge animation config with defaults
|
|
71
|
+
const mergedAnimation = useMemo(() => ({
|
|
72
|
+
...ANIMATION_DEFAULTS,
|
|
73
|
+
...animation
|
|
74
|
+
}), [animation]);
|
|
75
|
+
const offset = useMemo(() => {
|
|
76
|
+
const base = {
|
|
77
|
+
...toastDefaults.offset,
|
|
78
|
+
...customOffset
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
top: base.top + insets.top,
|
|
82
|
+
bottom: base.bottom + insets.bottom,
|
|
83
|
+
left: base.left + insets.left,
|
|
84
|
+
right: base.right + insets.right
|
|
85
|
+
};
|
|
86
|
+
}, [customOffset, insets]);
|
|
87
|
+
const normalizedSwipeDirection = useMemo(() => {
|
|
88
|
+
return Array.isArray(swipeDirection) ? swipeDirection : [swipeDirection];
|
|
89
|
+
}, [swipeDirection]);
|
|
90
|
+
|
|
91
|
+
// Filter toasts by toasterId if provided
|
|
92
|
+
const filteredToasts = useMemo(() => {
|
|
93
|
+
if (!toasterId) {
|
|
94
|
+
return toasts;
|
|
95
|
+
}
|
|
96
|
+
// Only show toasts that match this toasterId or have no toasterId set
|
|
97
|
+
return toasts.filter(t => t.toasterId === toasterId || t.toasterId === undefined);
|
|
98
|
+
}, [toasts, toasterId]);
|
|
99
|
+
|
|
100
|
+
// Sort toasts: newest first for top position, oldest first for bottom
|
|
101
|
+
// This ensures newest toast appears at the edge (top or bottom)
|
|
102
|
+
const sortedToasts = useMemo(() => {
|
|
103
|
+
const sorted = [...filteredToasts].sort((a, b) => b.createdAt - a.createdAt);
|
|
104
|
+
// For top: newest first (appears at top, older ones below)
|
|
105
|
+
// For bottom: reverse so newest appears at bottom edge
|
|
106
|
+
return position.startsWith("bottom") ? sorted.reverse() : sorted;
|
|
107
|
+
}, [filteredToasts, position]);
|
|
108
|
+
|
|
109
|
+
// Enforce visibleToasts limit - show only the most recent N toasts
|
|
110
|
+
// Important toasts are always shown
|
|
111
|
+
const visibleToastList = useMemo(() => {
|
|
112
|
+
if (visibleToasts <= 0) {
|
|
113
|
+
return sortedToasts;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Separate important and regular toasts
|
|
117
|
+
const important = sortedToasts.filter(t => t.important);
|
|
118
|
+
const regular = sortedToasts.filter(t => !t.important);
|
|
119
|
+
|
|
120
|
+
// Show all important toasts plus fill remaining slots with regular toasts
|
|
121
|
+
const remainingSlots = Math.max(0, visibleToasts - important.length);
|
|
122
|
+
const visibleRegular = regular.slice(0, remainingSlots);
|
|
123
|
+
|
|
124
|
+
// Combine and maintain sort order
|
|
125
|
+
const combined = [...important, ...visibleRegular];
|
|
126
|
+
return combined.sort((a, b) => {
|
|
127
|
+
const aIndex = sortedToasts.indexOf(a);
|
|
128
|
+
const bIndex = sortedToasts.indexOf(b);
|
|
129
|
+
return aIndex - bIndex;
|
|
130
|
+
});
|
|
131
|
+
}, [sortedToasts, visibleToasts]);
|
|
132
|
+
const handleDismiss = useCallback(toastId => {
|
|
133
|
+
const toast = toasts.find(t => t.id === toastId);
|
|
134
|
+
if (toast) {
|
|
135
|
+
toast.onDismiss?.(toast);
|
|
136
|
+
}
|
|
137
|
+
ToastState.dismiss(toastId);
|
|
138
|
+
}, [toasts]);
|
|
139
|
+
|
|
140
|
+
// Announce new toasts for accessibility
|
|
141
|
+
const announcedRef = React.useRef(new Set());
|
|
142
|
+
React.useEffect(() => {
|
|
143
|
+
for (const toast of visibleToastList) {
|
|
144
|
+
if (!announcedRef.current.has(toast.id)) {
|
|
145
|
+
announcedRef.current.add(toast.id);
|
|
146
|
+
announceForAccessibility(toast);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Clean up old IDs
|
|
150
|
+
const currentIds = new Set(visibleToastList.map(t => t.id));
|
|
151
|
+
announcedRef.current.forEach(id => {
|
|
152
|
+
if (!currentIds.has(id)) {
|
|
153
|
+
announcedRef.current.delete(id);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}, [visibleToastList]);
|
|
157
|
+
if (visibleToastList.length === 0) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const positionStyle = getContainerStyle(position, offset);
|
|
161
|
+
|
|
162
|
+
// Build container style using spread
|
|
163
|
+
const finalContainerStyle = {
|
|
164
|
+
...styles.container,
|
|
165
|
+
...positionStyle,
|
|
166
|
+
...containerStyle
|
|
167
|
+
};
|
|
168
|
+
return /*#__PURE__*/_jsx(View, {
|
|
169
|
+
style: finalContainerStyle,
|
|
170
|
+
pointerEvents: "box-none",
|
|
171
|
+
accessible: true,
|
|
172
|
+
accessibilityLabel: "Notifications",
|
|
173
|
+
children: visibleToastList.map(toast => /*#__PURE__*/_jsx(Toast, {
|
|
174
|
+
toast: toast,
|
|
175
|
+
position: position,
|
|
176
|
+
gap: gap,
|
|
177
|
+
swipeToDismiss: swipeToDismiss,
|
|
178
|
+
swipeDirection: normalizedSwipeDirection,
|
|
179
|
+
theme: resolvedTheme,
|
|
180
|
+
richColors: richColors,
|
|
181
|
+
closeButton: closeButton,
|
|
182
|
+
icons: icons,
|
|
183
|
+
defaultStyles: toastStyles,
|
|
184
|
+
defaultAnimation: mergedAnimation,
|
|
185
|
+
onDismiss: handleDismiss,
|
|
186
|
+
duration: duration,
|
|
187
|
+
pauseOnAppBackground: pauseOnAppBackground,
|
|
188
|
+
hapticFeedback: hapticFeedback
|
|
189
|
+
}, toast.id))
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const styles = StyleSheet.create({
|
|
193
|
+
container: {
|
|
194
|
+
zIndex: 9999,
|
|
195
|
+
pointerEvents: "box-none"
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
//# sourceMappingURL=toaster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMemo","AccessibilityInfo","Platform","StyleSheet","View","useSafeAreaInsets","ANIMATION_DEFAULTS","toastDefaults","ToastState","resolveTheme","Toast","useToastState","jsx","_jsx","getContainerStyle","position","offset","isTop","startsWith","isBottom","style","left","right","flexDirection","top","bottom","includes","alignItems","announceForAccessibility","toast","accessibility","announceToScreenReader","message","accessibilityLabel","title","OS","Toaster","theme","duration","gap","customOffset","swipeToDismiss","swipeDirection","pauseOnAppBackground","visibleToasts","icons","toastStyles","containerStyle","richColors","closeButton","toasterId","animation","hapticFeedback","insets","toasts","resolvedTheme","mergedAnimation","base","normalizedSwipeDirection","Array","isArray","filteredToasts","filter","t","undefined","sortedToasts","sorted","sort","a","b","createdAt","reverse","visibleToastList","important","regular","remainingSlots","Math","max","length","visibleRegular","slice","combined","aIndex","indexOf","bIndex","handleDismiss","toastId","find","id","onDismiss","dismiss","announcedRef","useRef","Set","useEffect","current","has","add","currentIds","map","forEach","delete","positionStyle","finalContainerStyle","styles","container","pointerEvents","accessible","children","defaultStyles","defaultAnimation","create","zIndex"],"sourceRoot":"..\\..\\src","sources":["toaster.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,iBAAiB,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAwB,cAAc;AAC5F,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,gBAAa;AAC/D,SAASC,UAAU,QAAQ,YAAS;AACpC,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QAAQ,EAAEA,QAAS;MACnBwB,GAAG,EAAEA,GAAI;MACTE,cAAc,EAAEA,cAAe;MAC/BC,cAAc,EAAEgB,wBAAyB;MACzCrB,KAAK,EAAEkB,aAAc;MACrBP,UAAU,EAAEA,UAAW;MACvBC,WAAW,EAAEA,WAAY;MACzBJ,KAAK,EAAEA,KAAM;MACbgE,aAAa,EAAE/D,WAAY;MAC3BgE,gBAAgB,EAAEtD,eAAgB;MAClCiC,SAAS,EAAEJ,aAAc;MACzB/C,QAAQ,EAAEA,QAAS;MACnBK,oBAAoB,EAAEA,oBAAqB;MAC3CS,cAAc,EAAEA;IAAe,GAf1BvB,KAAK,CAAC2D,EAgBZ,CACF;EAAC,CACE,CAAC;AAEX;AAEA,MAAMgB,MAAM,GAAGrG,UAAU,CAAC4G,MAAM,CAAC;EAC/BN,SAAS,EAAE;IACTO,MAAM,EAAE,IAAI;IACZN,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"..\\..\\src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { AppState } from "react-native";
|
|
5
|
+
export function useAppState() {
|
|
6
|
+
const [appState, setAppState] = useState(AppState.currentState);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const subscription = AppState.addEventListener("change", setAppState);
|
|
9
|
+
return () => subscription.remove();
|
|
10
|
+
}, []);
|
|
11
|
+
return appState;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=use-app-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useState","AppState","useAppState","appState","setAppState","currentState","subscription","addEventListener","remove"],"sourceRoot":"..\\..\\src","sources":["use-app-state.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAA6B,cAAc;AAE5D,OAAO,SAASC,WAAWA,CAAA,EAAmB;EAC5C,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGJ,QAAQ,CACtCC,QAAQ,CAACI,YACX,CAAC;EAEDN,SAAS,CAAC,MAAM;IACd,MAAMO,YAAY,GAAGL,QAAQ,CAACM,gBAAgB,CAAC,QAAQ,EAAEH,WAAW,CAAC;IACrE,OAAO,MAAME,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { useAppState } from "./use-app-state.js";
|
|
5
|
+
export function usePauseableTimer(callback, duration, enabled, pauseOnBackground) {
|
|
6
|
+
const appState = useAppState();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!enabled || duration <= 0 || duration === Number.POSITIVE_INFINITY) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (pauseOnBackground && appState !== "active") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const timer = setTimeout(callback, duration);
|
|
15
|
+
return () => clearTimeout(timer);
|
|
16
|
+
}, [callback, duration, enabled, pauseOnBackground, appState]);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=use-pauseable-timer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useAppState","usePauseableTimer","callback","duration","enabled","pauseOnBackground","appState","Number","POSITIVE_INFINITY","timer","setTimeout","clearTimeout"],"sourceRoot":"..\\..\\src","sources":["use-pauseable-timer.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,WAAW,QAAQ,oBAAiB;AAE7C,OAAO,SAASC,iBAAiBA,CAC/BC,QAAoB,EACpBC,QAAgB,EAChBC,OAAgB,EAChBC,iBAA0B,EACpB;EACN,MAAMC,QAAQ,GAAGN,WAAW,CAAC,CAAC;EAE9BD,SAAS,CAAC,MAAM;IACd,IAAI,CAACK,OAAO,IAAID,QAAQ,IAAI,CAAC,IAAIA,QAAQ,KAAKI,MAAM,CAACC,iBAAiB,EAAE;MACtE;IACF;IAEA,IAAIH,iBAAiB,IAAIC,QAAQ,KAAK,QAAQ,EAAE;MAC9C;IACF;IAEA,MAAMG,KAAK,GAAGC,UAAU,CAACR,QAAQ,EAAEC,QAAQ,CAAC;IAC5C,OAAO,MAAMQ,YAAY,CAACF,KAAK,CAAC;EAClC,CAAC,EAAE,CAACP,QAAQ,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,iBAAiB,EAAEC,QAAQ,CAAC,CAAC;AAChE","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ToastState } from "./state.js";
|
|
5
|
+
export function useToastState() {
|
|
6
|
+
const [toasts, setToasts] = useState(() => ToastState.getToasts());
|
|
7
|
+
const toastsRef = useRef(toasts);
|
|
8
|
+
toastsRef.current = toasts;
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const unsubscribeCreate = ToastState.subscribe(() => {
|
|
11
|
+
setToasts(ToastState.getToasts());
|
|
12
|
+
});
|
|
13
|
+
const unsubscribeDismiss = ToastState.subscribeToDismiss(() => {
|
|
14
|
+
setToasts(ToastState.getToasts());
|
|
15
|
+
});
|
|
16
|
+
const unsubscribeUpdate = ToastState.subscribeToUpdate(() => {
|
|
17
|
+
setToasts(ToastState.getToasts());
|
|
18
|
+
});
|
|
19
|
+
return () => {
|
|
20
|
+
unsubscribeCreate();
|
|
21
|
+
unsubscribeDismiss();
|
|
22
|
+
unsubscribeUpdate();
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
const getToast = useCallback(id => {
|
|
26
|
+
return toastsRef.current.find(t => t.id === id);
|
|
27
|
+
}, []);
|
|
28
|
+
const isActive = useCallback(id => {
|
|
29
|
+
return toastsRef.current.some(t => t.id === id);
|
|
30
|
+
}, []);
|
|
31
|
+
return {
|
|
32
|
+
toasts,
|
|
33
|
+
getToast,
|
|
34
|
+
isActive
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=use-toast-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useState","ToastState","useToastState","toasts","setToasts","getToasts","toastsRef","current","unsubscribeCreate","subscribe","unsubscribeDismiss","subscribeToDismiss","unsubscribeUpdate","subscribeToUpdate","getToast","id","find","t","isActive","some"],"sourceRoot":"..\\..\\src","sources":["use-toast-state.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChE,SAASC,UAAU,QAAQ,YAAS;AAGpC,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC9B,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGJ,QAAQ,CAAW,MAAMC,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;EAC5E,MAAMC,SAAS,GAAGP,MAAM,CAACI,MAAM,CAAC;EAChCG,SAAS,CAACC,OAAO,GAAGJ,MAAM;EAE1BL,SAAS,CAAC,MAAM;IACd,MAAMU,iBAAiB,GAAGP,UAAU,CAACQ,SAAS,CAAC,MAAM;MACnDL,SAAS,CAACH,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,MAAMK,kBAAkB,GAAGT,UAAU,CAACU,kBAAkB,CAAC,MAAM;MAC7DP,SAAS,CAACH,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,MAAMO,iBAAiB,GAAGX,UAAU,CAACY,iBAAiB,CAAC,MAAM;MAC3DT,SAAS,CAACH,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,MAAM;MACXG,iBAAiB,CAAC,CAAC;MACnBE,kBAAkB,CAAC,CAAC;MACpBE,iBAAiB,CAAC,CAAC;IACrB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAME,QAAQ,GAAGjB,WAAW,CAAEkB,EAAmB,IAAK;IACpD,OAAOT,SAAS,CAACC,OAAO,CAACS,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACF,EAAE,KAAKA,EAAE,CAAC;EACnD,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMG,QAAQ,GAAGrB,WAAW,CAAEkB,EAAmB,IAAK;IACpD,OAAOT,SAAS,CAACC,OAAO,CAACY,IAAI,CAAEF,CAAC,IAAKA,CAAC,CAACF,EAAE,KAAKA,EAAE,CAAC;EACnD,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACLZ,MAAM;IACNW,QAAQ;IACRI;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AnimationConfig, Position, SwipeDirection, Theme } from "./types";
|
|
2
|
+
export declare const ANIMATION_DEFAULTS: Required<AnimationConfig>;
|
|
3
|
+
export declare const ENTRY_OFFSET = 40;
|
|
4
|
+
export declare const SWIPE_THRESHOLD = 60;
|
|
5
|
+
export declare const VELOCITY_THRESHOLD = 500;
|
|
6
|
+
export declare const DAMPING_FACTOR = 0.5;
|
|
7
|
+
export declare const SWIPE_EXIT_DISTANCE = 300;
|
|
8
|
+
export declare const SNAP_BACK_DURATION = 150;
|
|
9
|
+
export declare const DEFAULT_ICON_SIZE = 20;
|
|
10
|
+
export declare const DISMISSED_CACHE_MAX_SIZE = 100;
|
|
11
|
+
export declare const DISMISSED_CACHE_CLEANUP_THRESHOLD = 50;
|
|
12
|
+
export declare const toastDefaults: {
|
|
13
|
+
readonly duration: 4000;
|
|
14
|
+
readonly position: Position;
|
|
15
|
+
readonly gap: 12;
|
|
16
|
+
readonly offset: {
|
|
17
|
+
readonly top: 52;
|
|
18
|
+
readonly bottom: 52;
|
|
19
|
+
readonly left: 16;
|
|
20
|
+
readonly right: 16;
|
|
21
|
+
};
|
|
22
|
+
readonly swipeToDismiss: true;
|
|
23
|
+
readonly swipeDirection: SwipeDirection[];
|
|
24
|
+
readonly theme: Theme;
|
|
25
|
+
readonly richColors: false;
|
|
26
|
+
readonly closeButton: false;
|
|
27
|
+
readonly dismissible: true;
|
|
28
|
+
readonly pauseOnAppBackground: true;
|
|
29
|
+
readonly visibleToasts: 3;
|
|
30
|
+
readonly hapticFeedback: false;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,eAAe,CAO/C,CAAC;AAEX,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD,eAAO,MAAM,aAAa;;uBAEE,QAAQ;;;;;;;;;6BASG,cAAc,EAAE;oBAClC,KAAK;;;;;;;CAOhB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Position, SwipeDirection, ToastIcons, ToastStyles } from "./types";
|
|
3
|
+
export interface ToasterContextValue {
|
|
4
|
+
position: Position;
|
|
5
|
+
theme: "light" | "dark";
|
|
6
|
+
gap: number;
|
|
7
|
+
swipeToDismiss: boolean;
|
|
8
|
+
swipeDirection: SwipeDirection[];
|
|
9
|
+
richColors: boolean;
|
|
10
|
+
closeButton: boolean;
|
|
11
|
+
icons?: ToastIcons;
|
|
12
|
+
toastStyles?: ToastStyles;
|
|
13
|
+
}
|
|
14
|
+
export declare function ToasterProvider({ children, value, }: {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
value: ToasterContextValue;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function useToasterContext(): ToasterContextValue;
|
|
19
|
+
export declare function useToasterContextOptional(): ToasterContextValue | null;
|
|
20
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEjF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAID,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,mBAAmB,CAAC;CAC5B,2CAEA;AAED,wBAAgB,iBAAiB,IAAI,mBAAmB,CAMvD;AAED,wBAAgB,yBAAyB,IAAI,mBAAmB,GAAG,IAAI,CAEtE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const easeOutQuad: import("react-native-reanimated").EasingFunctionFactory;
|
|
2
|
+
export declare const easeOutCubic: import("react-native-reanimated").EasingFunctionFactory;
|
|
3
|
+
export declare const easeInOutCubic: import("react-native-reanimated").EasingFunctionFactory;
|
|
4
|
+
export declare const easeOutCirc: import("react-native-reanimated").EasingFunctionFactory;
|
|
5
|
+
export declare const easeOutExpo: import("react-native-reanimated").EasingFunctionFactory;
|
|
6
|
+
//# sourceMappingURL=easings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easings.d.ts","sourceRoot":"","sources":["../../../src/easings.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,yDAAwC,CAAC;AACjE,eAAO,MAAM,YAAY,yDAAuC,CAAC;AACjE,eAAO,MAAM,cAAc,yDAAwC,CAAC;AACpE,eAAO,MAAM,WAAW,yDAAuC,CAAC;AAChE,eAAO,MAAM,WAAW,yDAAkC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ViewStyle } from "react-native";
|
|
3
|
+
import type { SwipeDirection } from "./types";
|
|
4
|
+
export interface SwipeHandlerProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
swipeDirection: SwipeDirection[];
|
|
8
|
+
onDismiss: () => void;
|
|
9
|
+
style?: ViewStyle;
|
|
10
|
+
}
|
|
11
|
+
export declare function SwipeHandler({ children, enabled, swipeDirection, onDismiss, style, }: SwipeHandlerProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function useSwipeGesture(enabled: boolean, swipeDirection: SwipeDirection[], onDismiss: () => void): {
|
|
13
|
+
gesture: import("react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture").PanGesture;
|
|
14
|
+
translateX: import("react-native-reanimated").SharedValue<number>;
|
|
15
|
+
opacity: import("react-native-reanimated").SharedValue<number>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=gestures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestures.d.ts","sourceRoot":"","sources":["../../../src/gestures.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAS9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,OAAO,EACP,cAAc,EACd,SAAS,EACT,KAAK,GACN,EAAE,iBAAiB,2CA4DnB;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAAE,EAChC,SAAS,EAAE,MAAM,IAAI;;;;EA2CtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ToastType } from "./types";
|
|
3
|
+
interface IconProps {
|
|
4
|
+
size?: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function SuccessIcon({ size, color }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ErrorIcon({ size, color }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function WarningIcon({ size, color }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function InfoIcon({ size, color }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function LoadingIcon({ size, color }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function CloseIcon({ size, color }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function getIcon(type: ToastType, color?: string): React.ReactNode;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../src/icons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAgBzC,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,wBAAgB,WAAW,CAAC,EAAE,IAAmB,EAAE,KAAiB,EAAE,EAAE,SAAS,2CAqBhF;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAmB,EAAE,KAAiB,EAAE,EAAE,SAAS,2CAqB9E;AAED,wBAAgB,WAAW,CAAC,EAAE,IAAmB,EAAE,KAAiB,EAAE,EAAE,SAAS,2CA0BhF;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAmB,EAAE,KAAiB,EAAE,EAAE,SAAS,2CAsB7E;AAED,wBAAgB,WAAW,CAAC,EAAE,IAAmB,EAAE,KAAiB,EAAE,EAAE,SAAS,2CAEhF;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAS,EAAE,KAAiB,EAAE,EAAE,SAAS,2CAoBpE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAexE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Toaster } from "./toaster";
|
|
2
|
+
export { Toast } from "./toast";
|
|
3
|
+
export { toast, ToastState } from "./state";
|
|
4
|
+
export { useSooner, useToastState, useAppState, usePauseableTimer } from "./hooks";
|
|
5
|
+
export { ToasterProvider, useToasterContext, useToasterContextOptional } from "./context";
|
|
6
|
+
export type { AccessibilityConfig, Action, AnimationConfig, ExternalToast, HeightT, Position, PromiseData, ResolvedTheme, SwipeDirection, Theme, ToasterProps, ToastIcons, ToastProps, ToastStyles, ToastT, ToastType, UpdateToastOptions, } from "./types";
|
|
7
|
+
export { CloseIcon, ErrorIcon, InfoIcon, LoadingIcon, SuccessIcon, WarningIcon, getIcon, } from "./icons";
|
|
8
|
+
export { colors, richColors, getToastColors, getIconColor, resolveTheme, baseStyles } from "./theme";
|
|
9
|
+
export { ANIMATION_DEFAULTS, ENTRY_OFFSET, SWIPE_THRESHOLD, VELOCITY_THRESHOLD, toastDefaults, } from "./constants";
|
|
10
|
+
export { easeOutQuad, easeOutCubic, easeInOutCubic, easeOutCirc, easeOutExpo } from "./easings";
|
|
11
|
+
export { SwipeHandler, useSwipeGesture } from "./gestures";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE1F,YAAY,EACV,mBAAmB,EACnB,MAAM,EACN,eAAe,EACf,aAAa,EACb,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,KAAK,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErG,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ExternalToast, PromiseData, ToastDismissSubscriber, ToastStateSubscriber, ToastT, ToastType, ToastUpdateSubscriber, UpdateToastOptions } from "./types";
|
|
3
|
+
declare class ToastStateManager {
|
|
4
|
+
private toasts;
|
|
5
|
+
private subscribers;
|
|
6
|
+
private dismissSubscribers;
|
|
7
|
+
private updateSubscribers;
|
|
8
|
+
private dismissedToasts;
|
|
9
|
+
subscribe(callback: ToastStateSubscriber): () => void;
|
|
10
|
+
subscribeToDismiss(callback: ToastDismissSubscriber): () => void;
|
|
11
|
+
subscribeToUpdate(callback: ToastUpdateSubscriber): () => void;
|
|
12
|
+
private publish;
|
|
13
|
+
private publishDismiss;
|
|
14
|
+
private publishUpdate;
|
|
15
|
+
private cleanupDismissedCache;
|
|
16
|
+
create(title: string | ReactNode, type?: ToastType, options?: ExternalToast): string | number;
|
|
17
|
+
update(toastId: string | number, options: UpdateToastOptions): boolean;
|
|
18
|
+
dismiss(toastId?: string | number): void;
|
|
19
|
+
getToasts(): ToastT[];
|
|
20
|
+
getToast(toastId: string | number): ToastT | undefined;
|
|
21
|
+
isActive(toastId: string | number): boolean;
|
|
22
|
+
promise<T>(promise: Promise<T> | (() => Promise<T>), data: PromiseData<T>, options?: ExternalToast): Promise<T>;
|
|
23
|
+
clearDismissedHistory(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const ToastState: ToastStateManager;
|
|
26
|
+
/**
|
|
27
|
+
* Main toast API
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Basic usage
|
|
31
|
+
* toast('Hello World');
|
|
32
|
+
*
|
|
33
|
+
* // With variants
|
|
34
|
+
* toast.success('Success!');
|
|
35
|
+
* toast.error('Error!');
|
|
36
|
+
*
|
|
37
|
+
* // With options
|
|
38
|
+
* toast('Message', { duration: 5000 });
|
|
39
|
+
*
|
|
40
|
+
* // Update existing toast
|
|
41
|
+
* const id = toast.loading('Loading...');
|
|
42
|
+
* toast.update(id, { title: 'Done!', type: 'success' });
|
|
43
|
+
*
|
|
44
|
+
* // Promise toast
|
|
45
|
+
* toast.promise(fetchData(), {
|
|
46
|
+
* loading: 'Loading...',
|
|
47
|
+
* success: 'Loaded!',
|
|
48
|
+
* error: 'Failed',
|
|
49
|
+
* });
|
|
50
|
+
*/
|
|
51
|
+
export declare const toast: ((title: string | ReactNode, options?: ExternalToast) => string | number) & {
|
|
52
|
+
success: (title: string | ReactNode, options?: ExternalToast) => string | number;
|
|
53
|
+
error: (title: string | ReactNode, options?: ExternalToast) => string | number;
|
|
54
|
+
warning: (title: string | ReactNode, options?: ExternalToast) => string | number;
|
|
55
|
+
info: (title: string | ReactNode, options?: ExternalToast) => string | number;
|
|
56
|
+
loading: (title: string | ReactNode, options?: ExternalToast) => string | number;
|
|
57
|
+
promise: <T>(promise: Promise<T> | (() => Promise<T>), data: PromiseData<T>, options?: ExternalToast) => Promise<T>;
|
|
58
|
+
update: (toastId: string | number, options: UpdateToastOptions) => boolean;
|
|
59
|
+
dismiss: (toastId?: string | number) => void;
|
|
60
|
+
getToasts: () => ToastT[];
|
|
61
|
+
getToast: (toastId: string | number) => ToastT | undefined;
|
|
62
|
+
isActive: (toastId: string | number) => boolean;
|
|
63
|
+
custom: (title: string | ReactNode, options?: ExternalToast) => string | number;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,EACN,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AASjB,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,kBAAkB,CAA0C;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,eAAe,CAA2C;IAElE,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI;IAKrD,kBAAkB,CAAC,Q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