react-native-earl-toastify 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE +21 -0
  3. package/README.md +513 -0
  4. package/dist/Toast.d.ts +12 -0
  5. package/dist/Toast.d.ts.map +1 -0
  6. package/dist/Toast.js +143 -0
  7. package/dist/Toast.js.map +1 -0
  8. package/dist/ToastContainer.d.ts +12 -0
  9. package/dist/ToastContainer.d.ts.map +1 -0
  10. package/dist/ToastContainer.js +46 -0
  11. package/dist/ToastContainer.js.map +1 -0
  12. package/dist/ToastProvider.d.ts +22 -0
  13. package/dist/ToastProvider.d.ts.map +1 -0
  14. package/dist/ToastProvider.js +163 -0
  15. package/dist/ToastProvider.js.map +1 -0
  16. package/dist/animations.d.ts +54 -0
  17. package/dist/animations.d.ts.map +1 -0
  18. package/dist/animations.js +118 -0
  19. package/dist/animations.js.map +1 -0
  20. package/dist/icons.d.ts +12 -0
  21. package/dist/icons.d.ts.map +1 -0
  22. package/dist/icons.js +110 -0
  23. package/dist/icons.js.map +1 -0
  24. package/dist/index.d.ts +10 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +14 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/styles.d.ts +63 -0
  29. package/dist/styles.d.ts.map +1 -0
  30. package/dist/styles.js +182 -0
  31. package/dist/styles.js.map +1 -0
  32. package/dist/types.d.ts +100 -0
  33. package/dist/types.d.ts.map +1 -0
  34. package/dist/types.js +2 -0
  35. package/dist/types.js.map +1 -0
  36. package/dist/useToast.d.ts +40 -0
  37. package/dist/useToast.d.ts.map +1 -0
  38. package/dist/useToast.js +48 -0
  39. package/dist/useToast.js.map +1 -0
  40. package/dist/useToastAnimation.d.ts +24 -0
  41. package/dist/useToastAnimation.d.ts.map +1 -0
  42. package/dist/useToastAnimation.js +59 -0
  43. package/dist/useToastAnimation.js.map +1 -0
  44. package/package.json +58 -0
  45. package/src/Toast.tsx +250 -0
  46. package/src/ToastContainer.tsx +70 -0
  47. package/src/ToastProvider.tsx +271 -0
  48. package/src/animations.ts +161 -0
  49. package/src/icons.tsx +152 -0
  50. package/src/index.ts +41 -0
  51. package/src/styles.ts +208 -0
  52. package/src/types.ts +157 -0
  53. package/src/useToast.ts +53 -0
  54. package/src/useToastAnimation.ts +108 -0
package/dist/icons.js ADDED
@@ -0,0 +1,110 @@
1
+ import React from "react";
2
+ import { View, Text, StyleSheet } from "react-native";
3
+ /**
4
+ * Simple SVG-like icons using View and Text components
5
+ * These are minimal default icons - users can replace with any icon library
6
+ */
7
+ const SuccessIcon = ({ color, size }) => (<View style={[
8
+ styles.iconCircle,
9
+ { width: size, height: size, borderColor: color },
10
+ ]}>
11
+ <Text style={[styles.iconText, { color, fontSize: size * 0.6 }]}>
12
+
13
+ </Text>
14
+ </View>);
15
+ const WarningIcon = ({ color, size }) => (<View style={[styles.iconTriangle, { borderBottomColor: color }]}>
16
+ <Text style={[styles.warningText, { fontSize: size * 0.5 }]}>!</Text>
17
+ </View>);
18
+ const ErrorIcon = ({ color, size }) => (<View style={[
19
+ styles.iconCircle,
20
+ {
21
+ width: size,
22
+ height: size,
23
+ borderColor: color,
24
+ backgroundColor: color,
25
+ },
26
+ ]}>
27
+ <Text style={[
28
+ styles.iconText,
29
+ { color: "#FFFFFF", fontSize: size * 0.6 },
30
+ ]}>
31
+
32
+ </Text>
33
+ </View>);
34
+ const InfoIcon = ({ color, size }) => (<View style={[
35
+ styles.iconCircle,
36
+ { width: size, height: size, borderColor: color },
37
+ ]}>
38
+ <Text style={[
39
+ styles.iconText,
40
+ { color, fontSize: size * 0.6, fontWeight: "bold" },
41
+ ]}>
42
+ i
43
+ </Text>
44
+ </View>);
45
+ const DefaultIcon = ({ color, size }) => (<View style={[
46
+ styles.iconCircle,
47
+ { width: size, height: size, borderColor: color },
48
+ ]}>
49
+ <Text style={[styles.iconText, { color, fontSize: size * 0.5 }]}>
50
+
51
+ </Text>
52
+ </View>);
53
+ const CloseIcon = ({ color, size }) => (<View style={{
54
+ width: size,
55
+ height: size,
56
+ alignItems: "center",
57
+ justifyContent: "center",
58
+ }}>
59
+ <Text style={{
60
+ color,
61
+ fontSize: size,
62
+ lineHeight: size,
63
+ fontWeight: "300",
64
+ }}>
65
+ ×
66
+ </Text>
67
+ </View>);
68
+ /**
69
+ * Default icons for each toast type
70
+ */
71
+ export const DefaultIcons = {
72
+ success: SuccessIcon,
73
+ warning: WarningIcon,
74
+ error: ErrorIcon,
75
+ info: InfoIcon,
76
+ default: DefaultIcon,
77
+ custom: DefaultIcon,
78
+ close: CloseIcon,
79
+ };
80
+ const styles = StyleSheet.create({
81
+ iconCircle: {
82
+ borderWidth: 2,
83
+ borderRadius: 999,
84
+ alignItems: "center",
85
+ justifyContent: "center",
86
+ },
87
+ iconText: {
88
+ textAlign: "center",
89
+ includeFontPadding: false,
90
+ textAlignVertical: "center",
91
+ },
92
+ iconTriangle: {
93
+ width: 0,
94
+ height: 0,
95
+ borderLeftWidth: 10,
96
+ borderRightWidth: 10,
97
+ borderBottomWidth: 18,
98
+ borderLeftColor: "transparent",
99
+ borderRightColor: "transparent",
100
+ alignItems: "center",
101
+ justifyContent: "flex-end",
102
+ },
103
+ warningText: {
104
+ color: "#FFFFFF",
105
+ fontWeight: "bold",
106
+ position: "absolute",
107
+ bottom: -16,
108
+ },
109
+ });
110
+ //# sourceMappingURL=icons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQtD;;;GAGG;AAEH,MAAM,WAAW,GAAwB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAC7D,CAAC,IAAI,CACJ,KAAK,CAAC,CAA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U,EAAE,IAAI;QAChB,UAAU,EAAE,KAAK;KACjB,CAAC,CAEF;;EACD,EAAE,IAAI,CACP;CAAA,EAAE,IAAI,CAAC,CACP,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAqD;IAC7E,OAAO,EAAE,WAAW;IACpB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,SAAS;CAChB,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAChC,UAAU,EAAE;QACX,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,GAAG;QACjB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACxB;IACD,QAAQ,EAAE;QACT,SAAS,EAAE,QAAQ;QACnB,kBAAkB,EAAE,KAAK;QACzB,iBAAiB,EAAE,QAAQ;KAC3B;IACD,YAAY,EAAE;QACb,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,eAAe,EAAE,EAAE;QACnB,gBAAgB,EAAE,EAAE;QACpB,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,aAAa;QAC9B,gBAAgB,EAAE,aAAa;QAC/B,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,UAAU;KAC1B;IACD,WAAW,EAAE;QACZ,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,EAAE;KACX;CACD,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { ToastProvider } from "./ToastProvider";
2
+ export { useToast } from "./useToast";
3
+ export { Toast } from "./Toast";
4
+ export { ToastContainer } from "./ToastContainer";
5
+ export type { ToastType, ToastAnimation, ToastPosition, ToastConfig, Toast as ToastData, ToastContextValue, ToastProviderConfig, } from "./types";
6
+ export { TOAST_COLORS, getToastColors, baseToastStyle, getPositionalStyle, getContainerStyle, } from "./styles";
7
+ export { getInitialAnimatedValues, getFinalAnimatedValues, getExitAnimatedValues, createEnterAnimation, createExitAnimation, DEFAULT_ANIMATION_CONFIG, } from "./animations";
8
+ export { useToastAnimation } from "./useToastAnimation";
9
+ export { DefaultIcons } from "./icons";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,YAAY,EACX,SAAS,EACT,cAAc,EACd,aAAa,EACb,WAAW,EACX,KAAK,IAAI,SAAS,EAClB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,YAAY,EACZ,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // Main exports
2
+ export { ToastProvider } from "./ToastProvider";
3
+ export { useToast } from "./useToast";
4
+ export { Toast } from "./Toast";
5
+ export { ToastContainer } from "./ToastContainer";
6
+ // Styles (for customization)
7
+ export { TOAST_COLORS, getToastColors, baseToastStyle, getPositionalStyle, getContainerStyle, } from "./styles";
8
+ // Animation utilities (for advanced customization)
9
+ export { getInitialAnimatedValues, getFinalAnimatedValues, getExitAnimatedValues, createEnterAnimation, createExitAnimation, DEFAULT_ANIMATION_CONFIG, } from "./animations";
10
+ // Animation hook
11
+ export { useToastAnimation } from "./useToastAnimation";
12
+ // Icons (for reference or custom implementations)
13
+ export { DefaultIcons } from "./icons";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAalD,6BAA6B;AAC7B,OAAO,EACN,YAAY,EACZ,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,UAAU,CAAC;AAElB,mDAAmD;AACnD,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACxB,MAAM,cAAc,CAAC;AAEtB,iBAAiB;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,kDAAkD;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { ViewStyle, TextStyle } from "react-native";
2
+ import { ToastType, ToastPosition } from "./types";
3
+ /**
4
+ * Color configuration for each toast type
5
+ * All colors meet WCAG 2.1 AA contrast requirements (4.5:1 minimum)
6
+ */
7
+ export interface ToastColors {
8
+ background: string;
9
+ text: string;
10
+ icon: string;
11
+ border: string;
12
+ }
13
+ /**
14
+ * Toast type color schemes - accessible and visually distinct
15
+ */
16
+ export declare const TOAST_COLORS: Record<ToastType, ToastColors>;
17
+ /**
18
+ * Get colors for a specific toast type
19
+ */
20
+ export declare const getToastColors: (type: ToastType) => ToastColors;
21
+ /**
22
+ * Base toast container styles
23
+ */
24
+ export declare const baseToastStyle: ViewStyle;
25
+ /**
26
+ * Get toast style based on position
27
+ * Top/Bottom: Full width, no rounded corners
28
+ * Center: Rounded corners with margin
29
+ */
30
+ export declare const getPositionalStyle: (position: ToastPosition) => ViewStyle;
31
+ /**
32
+ * Container positioning styles
33
+ */
34
+ export declare const getContainerStyle: (position: ToastPosition) => ViewStyle;
35
+ /**
36
+ * Toast title text style (primary text, larger)
37
+ */
38
+ export declare const titleStyle: TextStyle;
39
+ /**
40
+ * Toast description text style (secondary text, smaller)
41
+ */
42
+ export declare const descriptionStyle: TextStyle;
43
+ /**
44
+ * Toast message text style (when no title, used as main text)
45
+ */
46
+ export declare const messageStyle: TextStyle;
47
+ /**
48
+ * Text container style for title + description
49
+ */
50
+ export declare const textContainerStyle: ViewStyle;
51
+ /**
52
+ * Toast icon container style
53
+ */
54
+ export declare const iconContainerStyle: ViewStyle;
55
+ /**
56
+ * Close button style
57
+ */
58
+ export declare const closeButtonStyle: ViewStyle;
59
+ /**
60
+ * Safe area padding for different positions
61
+ */
62
+ export declare const getSafeAreaPadding: (position: ToastPosition) => ViewStyle;
63
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAqCvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,KAAG,WAEhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,SAY5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,aAAa,KAAG,SAa5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,aAAa,KAAG,SAiC3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,SAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAM9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,SAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAEhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAMhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAI9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,aAAa,KAAG,SAS5D,CAAC"}
package/dist/styles.js ADDED
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Toast type color schemes - accessible and visually distinct
3
+ */
4
+ export const TOAST_COLORS = {
5
+ success: {
6
+ background: "#ECFDF5",
7
+ text: "#065F46",
8
+ icon: "#10B981",
9
+ border: "#10B981",
10
+ },
11
+ warning: {
12
+ background: "#FFFBEB",
13
+ text: "#92400E",
14
+ icon: "#F59E0B",
15
+ border: "#F59E0B",
16
+ },
17
+ error: {
18
+ background: "#FEF2F2",
19
+ text: "#991B1B",
20
+ icon: "#EF4444",
21
+ border: "#EF4444",
22
+ },
23
+ info: {
24
+ background: "#EFF6FF",
25
+ text: "#1E40AF",
26
+ icon: "#3B82F6",
27
+ border: "#3B82F6",
28
+ },
29
+ default: {
30
+ background: "#F9FAFB",
31
+ text: "#374151",
32
+ icon: "#6B7280",
33
+ border: "#D1D5DB",
34
+ },
35
+ custom: {
36
+ background: "#F9FAFB",
37
+ text: "#374151",
38
+ icon: "#6B7280",
39
+ border: "#D1D5DB",
40
+ },
41
+ };
42
+ /**
43
+ * Get colors for a specific toast type
44
+ */
45
+ export const getToastColors = (type) => {
46
+ return TOAST_COLORS[type] || TOAST_COLORS.default;
47
+ };
48
+ /**
49
+ * Base toast container styles
50
+ */
51
+ export const baseToastStyle = {
52
+ flexDirection: "row",
53
+ alignItems: "center",
54
+ paddingVertical: 14,
55
+ paddingHorizontal: 16,
56
+ minHeight: 52,
57
+ borderLeftWidth: 4,
58
+ shadowColor: "#000",
59
+ shadowOffset: { width: 0, height: 2 },
60
+ shadowOpacity: 0.1,
61
+ shadowRadius: 8,
62
+ elevation: 5,
63
+ };
64
+ /**
65
+ * Get toast style based on position
66
+ * Top/Bottom: Full width, no rounded corners
67
+ * Center: Rounded corners with margin
68
+ */
69
+ export const getPositionalStyle = (position) => {
70
+ if (position === "center") {
71
+ return {
72
+ marginHorizontal: 16,
73
+ borderRadius: 12,
74
+ };
75
+ }
76
+ // Top or bottom - full width, no rounded corners
77
+ return {
78
+ marginHorizontal: 0,
79
+ borderRadius: 0,
80
+ };
81
+ };
82
+ /**
83
+ * Container positioning styles
84
+ */
85
+ export const getContainerStyle = (position) => {
86
+ const baseContainer = {
87
+ position: "absolute",
88
+ left: 0,
89
+ right: 0,
90
+ zIndex: 9999,
91
+ elevation: 9999,
92
+ };
93
+ switch (position) {
94
+ case "top":
95
+ return {
96
+ ...baseContainer,
97
+ top: 0,
98
+ };
99
+ case "bottom":
100
+ return {
101
+ ...baseContainer,
102
+ bottom: 0,
103
+ };
104
+ case "center":
105
+ return {
106
+ ...baseContainer,
107
+ top: 0,
108
+ bottom: 0,
109
+ justifyContent: "center",
110
+ };
111
+ default:
112
+ return {
113
+ ...baseContainer,
114
+ top: 0,
115
+ };
116
+ }
117
+ };
118
+ /**
119
+ * Toast title text style (primary text, larger)
120
+ */
121
+ export const titleStyle = {
122
+ fontSize: 15,
123
+ fontWeight: "600",
124
+ lineHeight: 20,
125
+ };
126
+ /**
127
+ * Toast description text style (secondary text, smaller)
128
+ */
129
+ export const descriptionStyle = {
130
+ fontSize: 13,
131
+ fontWeight: "400",
132
+ lineHeight: 18,
133
+ marginTop: 2,
134
+ opacity: 0.85,
135
+ };
136
+ /**
137
+ * Toast message text style (when no title, used as main text)
138
+ */
139
+ export const messageStyle = {
140
+ fontSize: 15,
141
+ fontWeight: "500",
142
+ flex: 1,
143
+ lineHeight: 20,
144
+ };
145
+ /**
146
+ * Text container style for title + description
147
+ */
148
+ export const textContainerStyle = {
149
+ flex: 1,
150
+ };
151
+ /**
152
+ * Toast icon container style
153
+ */
154
+ export const iconContainerStyle = {
155
+ marginRight: 12,
156
+ width: 24,
157
+ height: 24,
158
+ alignItems: "center",
159
+ justifyContent: "center",
160
+ };
161
+ /**
162
+ * Close button style
163
+ */
164
+ export const closeButtonStyle = {
165
+ marginLeft: 12,
166
+ padding: 4,
167
+ borderRadius: 4,
168
+ };
169
+ /**
170
+ * Safe area padding for different positions
171
+ */
172
+ export const getSafeAreaPadding = (position) => {
173
+ switch (position) {
174
+ case "top":
175
+ return { paddingTop: 50 }; // Account for status bar
176
+ case "bottom":
177
+ return { paddingBottom: 34 }; // Account for home indicator
178
+ default:
179
+ return {};
180
+ }
181
+ };
182
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmC;IAC3D,OAAO,EAAE;QACR,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KACjB;IACD,OAAO,EAAE;QACR,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,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F;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC5C,IAAI,EAAE,CAAC;CACP,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC5C,WAAW,EAAE,EAAE;IACf,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAc;IAC1C,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,CAAC;IACV,YAAY,EAAE,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAuB,EAAa,EAAE;IACxE,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,KAAK;YACT,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,yBAAyB;QACrD,KAAK,QAAQ;YACZ,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC,6BAA6B;QAC5D;YACC,OAAO,EAAE,CAAC;IACZ,CAAC;AACF,CAAC,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { ReactNode } from "react";
2
+ import { ViewStyle, TextStyle } from "react-native";
3
+ /**
4
+ * Toast type determines the color scheme and default icon
5
+ */
6
+ export type ToastType = "success" | "warning" | "error" | "default" | "info" | "custom";
7
+ /**
8
+ * Animation type for toast enter/exit
9
+ */
10
+ export type ToastAnimation = "fade" | "up" | "down" | "left" | "right" | "none";
11
+ /**
12
+ * Position of the toast on screen
13
+ */
14
+ export type ToastPosition = "top" | "bottom" | "center";
15
+ /**
16
+ * Configuration options for a toast notification
17
+ */
18
+ export interface ToastConfig {
19
+ /** Title to display in the toast (primary text, larger) */
20
+ title?: string;
21
+ /** Message/description to display in the toast (secondary text, smaller) */
22
+ message: string;
23
+ /** Type of toast - determines color scheme */
24
+ type?: ToastType;
25
+ /** Position on screen */
26
+ position?: ToastPosition;
27
+ /** Duration in milliseconds before auto-dismiss (0 = no auto-dismiss) */
28
+ duration?: number;
29
+ /** Animation type for entering */
30
+ animationIn?: ToastAnimation;
31
+ /** Animation type for exiting */
32
+ animationOut?: ToastAnimation;
33
+ /** Animation duration in milliseconds */
34
+ animationDuration?: number;
35
+ /** Whether toast can be dismissed by tapping */
36
+ dismissable?: boolean;
37
+ /** Custom icon element (e.g., from react-native-lucide) */
38
+ icon?: ReactNode;
39
+ /** Hide the default icon */
40
+ hideIcon?: boolean;
41
+ /** Custom background color (for 'custom' type) */
42
+ backgroundColor?: string;
43
+ /** Custom text color (for 'custom' type) */
44
+ textColor?: string;
45
+ /** Custom border color (for 'custom' type) */
46
+ borderColor?: string;
47
+ /** Custom container style */
48
+ style?: ViewStyle;
49
+ /** Custom text style */
50
+ textStyle?: TextStyle;
51
+ /** Callback when toast is shown */
52
+ onShow?: () => void;
53
+ /** Callback when toast is hidden */
54
+ onHide?: () => void;
55
+ /** Callback when toast is pressed */
56
+ onPress?: () => void;
57
+ }
58
+ /**
59
+ * Internal toast data with unique ID
60
+ */
61
+ export interface Toast extends ToastConfig {
62
+ id: string;
63
+ }
64
+ /**
65
+ * Toast context value for useToast hook
66
+ */
67
+ export interface ToastContextValue {
68
+ /** Show a toast with configuration */
69
+ show: (config: ToastConfig) => string;
70
+ /** Show a success toast - can be (message) or (title, description) */
71
+ success: (titleOrMessage: string, descriptionOrConfig?: string | Partial<ToastConfig>, config?: Partial<ToastConfig>) => string;
72
+ /** Show a warning toast - can be (message) or (title, description) */
73
+ warning: (titleOrMessage: string, descriptionOrConfig?: string | Partial<ToastConfig>, config?: Partial<ToastConfig>) => string;
74
+ /** Show an error toast - can be (message) or (title, description) */
75
+ error: (titleOrMessage: string, descriptionOrConfig?: string | Partial<ToastConfig>, config?: Partial<ToastConfig>) => string;
76
+ /** Show an info toast - can be (message) or (title, description) */
77
+ info: (titleOrMessage: string, descriptionOrConfig?: string | Partial<ToastConfig>, config?: Partial<ToastConfig>) => string;
78
+ /** Hide a specific toast by ID */
79
+ hide: (id: string) => void;
80
+ /** Hide all toasts */
81
+ hideAll: () => void;
82
+ }
83
+ /**
84
+ * Global configuration for ToastProvider
85
+ */
86
+ export interface ToastProviderConfig {
87
+ /** Default position for all toasts */
88
+ defaultPosition?: ToastPosition;
89
+ /** Default duration for all toasts */
90
+ defaultDuration?: number;
91
+ /** Default animation in */
92
+ defaultAnimationIn?: ToastAnimation;
93
+ /** Default animation out */
94
+ defaultAnimationOut?: ToastAnimation;
95
+ /** Default animation duration */
96
+ defaultAnimationDuration?: number;
97
+ /** Maximum number of toasts visible at once */
98
+ maxToasts?: number;
99
+ }
100
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,SAAS,GAClB,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,MAAM,GACN,QAAQ,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAEhB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC;IAEzB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,M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M,GAAG,OAAO,CAAC,WAAW,CAAC,EACnD,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KACzB,MAAM,CAAC;IAEZ,qEAAqE;IACrE,KAAK,EAAE,CACN,cAAc,EAAE,MAAM,EACtB,mBAAmB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,EACnD,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KACzB,MAAM,CAAC;IAEZ,oEAAoE;IACpE,IAAI,EAAE,CACL,cAAc,EAAE,MAAM,EACtB,mBAAmB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,EACnD,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KACzB,MAAM,CAAC;IAEZ,kCAAkC;IAClC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAE3B,sBAAsB;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,sCAAsC;IACtC,eAAe,CAAC,EAAE,aAAa,CAAC;IAEhC,sCAAsC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAEpC,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,cAAc,CAAC;IAErC,iCAAiC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ import { ToastContextValue } from "./types";
2
+ /**
3
+ * Hook to access toast functions
4
+ *
5
+ * @returns Toast context with show, success, warning, error, info, hide, and hideAll methods
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * const toast = useToast();
10
+ *
11
+ * // Show different toast types
12
+ * toast.success('Operation completed!');
13
+ * toast.error('Something went wrong');
14
+ * toast.warning('Please check your input');
15
+ * toast.info('New update available');
16
+ *
17
+ * // Show with custom configuration
18
+ * toast.show({
19
+ * message: 'Custom toast',
20
+ * type: 'custom',
21
+ * backgroundColor: '#8B5CF6',
22
+ * textColor: '#FFFFFF',
23
+ * position: 'bottom',
24
+ * duration: 5000,
25
+ * animationIn: 'up',
26
+ * animationOut: 'down',
27
+ * });
28
+ *
29
+ * // Hide specific toast
30
+ * const id = toast.success('Saving...');
31
+ * toast.hide(id);
32
+ *
33
+ * // Hide all toasts
34
+ * toast.hideAll();
35
+ * ```
36
+ *
37
+ * @throws Error if used outside of ToastProvider
38
+ */
39
+ export declare const useToast: () => ToastContextValue;
40
+ //# sourceMappingURL=useToast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToast.d.ts","sourceRoot":"","sources":["../src/useToast.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,QAAQ,QAAO,iBAW3B,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { useContext } from "react";
2
+ import { ToastContext } from "./ToastProvider";
3
+ /**
4
+ * Hook to access toast functions
5
+ *
6
+ * @returns Toast context with show, success, warning, error, info, hide, and hideAll methods
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const toast = useToast();
11
+ *
12
+ * // Show different toast types
13
+ * toast.success('Operation completed!');
14
+ * toast.error('Something went wrong');
15
+ * toast.warning('Please check your input');
16
+ * toast.info('New update available');
17
+ *
18
+ * // Show with custom configuration
19
+ * toast.show({
20
+ * message: 'Custom toast',
21
+ * type: 'custom',
22
+ * backgroundColor: '#8B5CF6',
23
+ * textColor: '#FFFFFF',
24
+ * position: 'bottom',
25
+ * duration: 5000,
26
+ * animationIn: 'up',
27
+ * animationOut: 'down',
28
+ * });
29
+ *
30
+ * // Hide specific toast
31
+ * const id = toast.success('Saving...');
32
+ * toast.hide(id);
33
+ *
34
+ * // Hide all toasts
35
+ * toast.hideAll();
36
+ * ```
37
+ *
38
+ * @throws Error if used outside of ToastProvider
39
+ */
40
+ export const useToast = () => {
41
+ const context = useContext(ToastContext);
42
+ if (!context) {
43
+ throw new Error("useToast must be used within a ToastProvider. " +
44
+ "Wrap your app with <ToastProvider> to use toast notifications.");
45
+ }
46
+ return context;
47
+ };
48
+ //# sourceMappingURL=useToast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToast.js","sourceRoot":"","sources":["../src/useToast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAsB,EAAE;IAC/C,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACd,gDAAgD;YAC/C,gEAAgE,CACjE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Animated } from "react-native";
2
+ import { ToastAnimation, ToastPosition } from "./types";
3
+ type TransformStyle = {
4
+ translateX: Animated.Value;
5
+ } | {
6
+ translateY: Animated.Value;
7
+ };
8
+ /**
9
+ * Hook return type
10
+ */
11
+ export interface UseToastAnimationReturn {
12
+ animatedStyle: {
13
+ opacity: Animated.Value;
14
+ transform: TransformStyle[];
15
+ };
16
+ startEnterAnimation: () => void;
17
+ startExitAnimation: (callback?: () => void) => void;
18
+ }
19
+ /**
20
+ * Custom hook for managing toast animations
21
+ */
22
+ export declare const useToastAnimation: (animationIn: ToastAnimation, animationOut: ToastAnimation, position: ToastPosition, animationDuration?: number) => UseToastAnimationReturn;
23
+ export {};
24
+ //# sourceMappingURL=useToastAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToastAnimation.d.ts","sourceRoot":"","sources":["../src/useToastAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAQxD,KAAK,cAAc,GAChB;IAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAA;CAAE,GAC9B;IAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAA;CAAE,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,aAAa,EAAE;QACd,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;QACxB,SAAS,EAAE,cAAc,EAAE,CAAC;KAC5B,CAAC;IACF,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACpD;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC7B,aAAa,cAAc,EAC3B,cAAc,cAAc,EAC5B,UAAU,aAAa,EACvB,oBAAmB,MAA0C,KAC3D,uBAyEF,CAAC"}