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.
Files changed (80) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +376 -0
  3. package/lib/module/constants.js +40 -0
  4. package/lib/module/constants.js.map +1 -0
  5. package/lib/module/context.js +25 -0
  6. package/lib/module/context.js.map +1 -0
  7. package/lib/module/easings.js +9 -0
  8. package/lib/module/easings.js.map +1 -0
  9. package/lib/module/gestures.js +119 -0
  10. package/lib/module/gestures.js.map +1 -0
  11. package/lib/module/hooks.js +9 -0
  12. package/lib/module/hooks.js.map +1 -0
  13. package/lib/module/icons.js +332 -0
  14. package/lib/module/icons.js.map +1 -0
  15. package/lib/module/index.js +13 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/module/state.js +200 -0
  19. package/lib/module/state.js.map +1 -0
  20. package/lib/module/theme.js +189 -0
  21. package/lib/module/theme.js.map +1 -0
  22. package/lib/module/toast.js +362 -0
  23. package/lib/module/toast.js.map +1 -0
  24. package/lib/module/toaster.js +198 -0
  25. package/lib/module/toaster.js.map +1 -0
  26. package/lib/module/types.js +4 -0
  27. package/lib/module/types.js.map +1 -0
  28. package/lib/module/use-app-state.js +13 -0
  29. package/lib/module/use-app-state.js.map +1 -0
  30. package/lib/module/use-pauseable-timer.js +18 -0
  31. package/lib/module/use-pauseable-timer.js.map +1 -0
  32. package/lib/module/use-toast-state.js +37 -0
  33. package/lib/module/use-toast-state.js.map +1 -0
  34. package/lib/typescript/package.json +1 -0
  35. package/lib/typescript/src/constants.d.ts +32 -0
  36. package/lib/typescript/src/constants.d.ts.map +1 -0
  37. package/lib/typescript/src/context.d.ts +20 -0
  38. package/lib/typescript/src/context.d.ts.map +1 -0
  39. package/lib/typescript/src/easings.d.ts +6 -0
  40. package/lib/typescript/src/easings.d.ts.map +1 -0
  41. package/lib/typescript/src/gestures.d.ts +17 -0
  42. package/lib/typescript/src/gestures.d.ts.map +1 -0
  43. package/lib/typescript/src/hooks.d.ts +5 -0
  44. package/lib/typescript/src/hooks.d.ts.map +1 -0
  45. package/lib/typescript/src/icons.d.ts +15 -0
  46. package/lib/typescript/src/icons.d.ts.map +1 -0
  47. package/lib/typescript/src/index.d.ts +12 -0
  48. package/lib/typescript/src/index.d.ts.map +1 -0
  49. package/lib/typescript/src/state.d.ts +66 -0
  50. package/lib/typescript/src/state.d.ts.map +1 -0
  51. package/lib/typescript/src/theme.d.ts +163 -0
  52. package/lib/typescript/src/theme.d.ts.map +1 -0
  53. package/lib/typescript/src/toast.d.ts +3 -0
  54. package/lib/typescript/src/toast.d.ts.map +1 -0
  55. package/lib/typescript/src/toaster.d.ts +3 -0
  56. package/lib/typescript/src/toaster.d.ts.map +1 -0
  57. package/lib/typescript/src/types.d.ts +264 -0
  58. package/lib/typescript/src/types.d.ts.map +1 -0
  59. package/lib/typescript/src/use-app-state.d.ts +3 -0
  60. package/lib/typescript/src/use-app-state.d.ts.map +1 -0
  61. package/lib/typescript/src/use-pauseable-timer.d.ts +2 -0
  62. package/lib/typescript/src/use-pauseable-timer.d.ts.map +1 -0
  63. package/lib/typescript/src/use-toast-state.d.ts +7 -0
  64. package/lib/typescript/src/use-toast-state.d.ts.map +1 -0
  65. package/package.json +152 -0
  66. package/src/constants.ts +44 -0
  67. package/src/context.tsx +38 -0
  68. package/src/easings.ts +7 -0
  69. package/src/gestures.tsx +135 -0
  70. package/src/hooks.ts +3 -0
  71. package/src/icons.tsx +227 -0
  72. package/src/index.tsx +48 -0
  73. package/src/state.ts +262 -0
  74. package/src/theme.ts +170 -0
  75. package/src/toast.tsx +429 -0
  76. package/src/toaster.tsx +221 -0
  77. package/src/types.ts +311 -0
  78. package/src/use-app-state.ts +15 -0
  79. package/src/use-pauseable-timer.ts +24 -0
  80. package/src/use-toast-state.ts +43 -0
@@ -0,0 +1,163 @@
1
+ import type { Theme, ToastType } from "./types";
2
+ export declare function resolveTheme(theme: Theme): "light" | "dark";
3
+ export declare const colors: {
4
+ readonly light: {
5
+ readonly background: "#ffffff";
6
+ readonly foreground: "#0f172a";
7
+ readonly description: "#64748b";
8
+ readonly border: "#e2e8f0";
9
+ readonly success: "#22c55e";
10
+ readonly error: "#ef4444";
11
+ readonly warning: "#f59e0b";
12
+ readonly info: "#3b82f6";
13
+ readonly loading: "#6b7280";
14
+ };
15
+ readonly dark: {
16
+ readonly background: "#1e293b";
17
+ readonly foreground: "#f8fafc";
18
+ readonly description: "#94a3b8";
19
+ readonly border: "#334155";
20
+ readonly success: "#4ade80";
21
+ readonly error: "#f87171";
22
+ readonly warning: "#fbbf24";
23
+ readonly info: "#60a5fa";
24
+ readonly loading: "#9ca3af";
25
+ };
26
+ };
27
+ export declare const richColors: {
28
+ readonly light: {
29
+ readonly success: {
30
+ readonly background: "#dcfce7";
31
+ readonly foreground: "#166534";
32
+ readonly border: "#bbf7d0";
33
+ };
34
+ readonly error: {
35
+ readonly background: "#fee2e2";
36
+ readonly foreground: "#991b1b";
37
+ readonly border: "#fecaca";
38
+ };
39
+ readonly warning: {
40
+ readonly background: "#fef3c7";
41
+ readonly foreground: "#92400e";
42
+ readonly border: "#fde68a";
43
+ };
44
+ readonly info: {
45
+ readonly background: "#dbeafe";
46
+ readonly foreground: "#1e40af";
47
+ readonly border: "#bfdbfe";
48
+ };
49
+ };
50
+ readonly dark: {
51
+ readonly success: {
52
+ readonly background: "#166534";
53
+ readonly foreground: "#dcfce7";
54
+ readonly border: "#22c55e";
55
+ };
56
+ readonly error: {
57
+ readonly background: "#991b1b";
58
+ readonly foreground: "#fee2e2";
59
+ readonly border: "#ef4444";
60
+ };
61
+ readonly warning: {
62
+ readonly background: "#92400e";
63
+ readonly foreground: "#fef3c7";
64
+ readonly border: "#f59e0b";
65
+ };
66
+ readonly info: {
67
+ readonly background: "#1e40af";
68
+ readonly foreground: "#dbeafe";
69
+ readonly border: "#3b82f6";
70
+ };
71
+ };
72
+ };
73
+ export declare function getIconColor(type: ToastType, theme: "light" | "dark", rich: boolean): string;
74
+ export declare function getToastColors(type: ToastType, theme: "light" | "dark", rich: boolean): {
75
+ background: "#dcfce7" | "#166534" | "#fee2e2" | "#991b1b" | "#fef3c7" | "#92400e" | "#dbeafe" | "#1e40af";
76
+ foreground: "#dcfce7" | "#166534" | "#fee2e2" | "#991b1b" | "#fef3c7" | "#92400e" | "#dbeafe" | "#1e40af";
77
+ description: "#dcfce7" | "#166534" | "#fee2e2" | "#991b1b" | "#fef3c7" | "#92400e" | "#dbeafe" | "#1e40af";
78
+ border: "#22c55e" | "#ef4444" | "#f59e0b" | "#3b82f6" | "#bbf7d0" | "#fecaca" | "#fde68a" | "#bfdbfe";
79
+ } | {
80
+ background: "#ffffff" | "#1e293b";
81
+ foreground: "#0f172a" | "#f8fafc";
82
+ description: "#64748b" | "#94a3b8";
83
+ border: "#e2e8f0" | "#334155";
84
+ };
85
+ export declare const baseStyles: {
86
+ container: {
87
+ flexDirection: "row";
88
+ alignItems: "center";
89
+ paddingHorizontal: number;
90
+ paddingVertical: number;
91
+ borderRadius: number;
92
+ borderWidth: number;
93
+ shadowColor: string;
94
+ shadowOffset: {
95
+ width: number;
96
+ height: number;
97
+ };
98
+ shadowOpacity: number;
99
+ shadowRadius: number;
100
+ elevation: number;
101
+ minHeight: number;
102
+ maxWidth: "100%";
103
+ };
104
+ content: {
105
+ flex: number;
106
+ marginLeft: number;
107
+ };
108
+ contentNoIcon: {
109
+ marginLeft: number;
110
+ };
111
+ title: {
112
+ fontSize: number;
113
+ fontWeight: "500";
114
+ lineHeight: number;
115
+ };
116
+ description: {
117
+ fontSize: number;
118
+ lineHeight: number;
119
+ marginTop: number;
120
+ };
121
+ actionsContainer: {
122
+ flexDirection: "row";
123
+ alignItems: "center";
124
+ marginLeft: number;
125
+ gap: number;
126
+ };
127
+ actionButton: {
128
+ paddingHorizontal: number;
129
+ paddingVertical: number;
130
+ borderRadius: number;
131
+ backgroundColor: string;
132
+ };
133
+ actionButtonText: {
134
+ fontSize: number;
135
+ fontWeight: "500";
136
+ color: string;
137
+ };
138
+ cancelButton: {
139
+ paddingHorizontal: number;
140
+ paddingVertical: number;
141
+ borderRadius: number;
142
+ backgroundColor: string;
143
+ borderWidth: number;
144
+ borderColor: string;
145
+ };
146
+ cancelButtonText: {
147
+ fontSize: number;
148
+ fontWeight: "500";
149
+ color: string;
150
+ };
151
+ closeButton: {
152
+ marginLeft: number;
153
+ padding: number;
154
+ borderRadius: number;
155
+ };
156
+ iconContainer: {
157
+ width: number;
158
+ height: number;
159
+ justifyContent: "center";
160
+ alignItems: "center";
161
+ };
162
+ };
163
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAM3D;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;CAuBT,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAab,CAAC;AAEX,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,IAAI,EAAE,OAAO,GACZ,MAAM,CAWR;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,OAAO,GAAG,MAAM,EACvB,IAAI,EAAE,OAAO;;;;;;;;;;EAsBd;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0ErB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ToastProps } from "./types";
2
+ export declare function Toast({ toast, position, gap, swipeToDismiss, swipeDirection, theme, richColors, closeButton, icons, defaultStyles, defaultAnimation, onDismiss, duration, pauseOnAppBackground, hapticFeedback, }: ToastProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=toast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../src/toast.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAA+B,UAAU,EAAqB,MAAM,SAAS,CAAC;AA8J1F,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,GAAG,EACH,cAAc,EACd,cAAc,EACd,KAAK,EACL,UAAU,EACV,WAAW,EACX,KAAK,EACL,aAAa,EACb,gBAAqC,EACrC,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,cAAsB,GACvB,EAAE,UAAU,2CAwOZ"}
@@ -0,0 +1,3 @@
1
+ import type { ToasterProps } from "./types";
2
+ export declare function Toaster({ position, theme, duration, gap, offset: customOffset, swipeToDismiss, swipeDirection, pauseOnAppBackground, visibleToasts, icons, toastStyles, containerStyle, richColors, closeButton, toasterId, animation, hapticFeedback, }: ToasterProps): import("react/jsx-runtime").JSX.Element | null;
3
+ //# sourceMappingURL=toaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toaster.d.ts","sourceRoot":"","sources":["../../../src/toaster.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAA6C,YAAY,EAAU,MAAM,SAAS,CAAC;AAoD/F,wBAAgB,OAAO,CAAC,EACtB,QAAiC,EACjC,KAA2B,EAC3B,QAAiC,EACjC,GAAuB,EACvB,MAAM,EAAE,YAAY,EACpB,cAA6C,EAC7C,cAA6C,EAC7C,oBAAyD,EACzD,aAA2C,EAC3C,KAAK,EACL,WAAW,EACX,cAAc,EACd,UAAqC,EACrC,WAAuC,EACvC,SAAS,EACT,SAAS,EACT,cAA6C,GAC9C,EAAE,YAAY,kDAwId"}
@@ -0,0 +1,264 @@
1
+ import type { ReactNode } from "react";
2
+ import type { AccessibilityRole, StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ /**
4
+ * Toast variant types
5
+ */
6
+ export type ToastType = "default" | "success" | "error" | "warning" | "info" | "loading";
7
+ /**
8
+ * Position of the toast on screen
9
+ */
10
+ export type Position = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
11
+ /**
12
+ * Swipe direction to dismiss
13
+ */
14
+ export type SwipeDirection = "left" | "right" | "up" | "down";
15
+ /**
16
+ * Theme options
17
+ */
18
+ export type Theme = "light" | "dark" | "system";
19
+ /**
20
+ * Resolved theme (without system)
21
+ */
22
+ export type ResolvedTheme = "light" | "dark";
23
+ /**
24
+ * Action button configuration
25
+ */
26
+ export interface Action {
27
+ label: string;
28
+ onClick: (toast: ToastT) => void;
29
+ style?: StyleProp<ViewStyle>;
30
+ textStyle?: StyleProp<TextStyle>;
31
+ }
32
+ /**
33
+ * Promise data for toast.promise()
34
+ */
35
+ export interface PromiseData<T = unknown> {
36
+ loading: string | ReactNode;
37
+ success: string | ReactNode | ((data: T) => string | ReactNode);
38
+ error: string | ReactNode | ((error: unknown) => string | ReactNode);
39
+ finally?: () => void;
40
+ }
41
+ /**
42
+ * Custom icons for toast types
43
+ */
44
+ export interface ToastIcons {
45
+ success?: ReactNode;
46
+ error?: ReactNode;
47
+ warning?: ReactNode;
48
+ info?: ReactNode;
49
+ loading?: ReactNode;
50
+ }
51
+ /**
52
+ * Custom styles for toast parts
53
+ */
54
+ export interface ToastStyles {
55
+ container?: StyleProp<ViewStyle>;
56
+ content?: StyleProp<ViewStyle>;
57
+ title?: StyleProp<TextStyle>;
58
+ description?: StyleProp<TextStyle>;
59
+ actionButton?: StyleProp<ViewStyle>;
60
+ actionButtonText?: StyleProp<TextStyle>;
61
+ cancelButton?: StyleProp<ViewStyle>;
62
+ cancelButtonText?: StyleProp<TextStyle>;
63
+ closeButton?: StyleProp<ViewStyle>;
64
+ }
65
+ /**
66
+ * Animation configuration
67
+ */
68
+ export interface AnimationConfig {
69
+ /** Entry animation duration in ms @default 350 */
70
+ duration?: number;
71
+ /** Exit animation duration in ms @default 200 */
72
+ exitDuration?: number;
73
+ /** Use spring animation for entry @default true */
74
+ useSpring?: boolean;
75
+ /** Spring damping @default 18 */
76
+ damping?: number;
77
+ /** Spring stiffness @default 140 */
78
+ stiffness?: number;
79
+ /** Spring mass @default 1 */
80
+ mass?: number;
81
+ }
82
+ /**
83
+ * Accessibility configuration
84
+ */
85
+ export interface AccessibilityConfig {
86
+ /** Accessibility role @default "alert" */
87
+ role?: AccessibilityRole;
88
+ /** Whether to announce toast to screen readers @default true */
89
+ announceToScreenReader?: boolean;
90
+ /** Custom accessibility label */
91
+ accessibilityLabel?: string;
92
+ }
93
+ /**
94
+ * Internal toast data structure
95
+ */
96
+ export interface ToastT {
97
+ id: string | number;
98
+ type: ToastType;
99
+ title: string | ReactNode;
100
+ description?: string | ReactNode;
101
+ icon?: ReactNode;
102
+ duration?: number;
103
+ dismissible?: boolean;
104
+ action?: Action;
105
+ cancel?: Action;
106
+ onDismiss?: (toast: ToastT) => void;
107
+ onAutoClose?: (toast: ToastT) => void;
108
+ styles?: ToastStyles;
109
+ /** Mark toast as important (won't be auto-dismissed when queue is full) */
110
+ important?: boolean;
111
+ /** Toaster ID to target specific Toaster instance */
112
+ toasterId?: string;
113
+ /** Internal: timestamp when created */
114
+ createdAt: number;
115
+ /** Internal: whether this toast is being dismissed */
116
+ dismissed?: boolean;
117
+ /** Animation configuration for this toast */
118
+ animation?: AnimationConfig;
119
+ /** Accessibility configuration */
120
+ accessibility?: AccessibilityConfig;
121
+ }
122
+ /**
123
+ * Options for updating a toast
124
+ */
125
+ export type UpdateToastOptions = Partial<Omit<ToastT, "id" | "createdAt">>;
126
+ /**
127
+ * External toast options (what users pass to toast())
128
+ */
129
+ export type ExternalToast = Omit<ToastT, "id" | "type" | "title" | "createdAt"> & {
130
+ /** Optional custom ID for the toast */
131
+ id?: string | number;
132
+ };
133
+ /**
134
+ * Toast height tracking for stacking
135
+ */
136
+ export interface HeightT {
137
+ toastId: string | number;
138
+ height: number;
139
+ }
140
+ /**
141
+ * Toaster component props
142
+ */
143
+ export interface ToasterProps {
144
+ /**
145
+ * Position of toasts on screen
146
+ * @default "top-center"
147
+ */
148
+ position?: Position;
149
+ /**
150
+ * Theme for toasts
151
+ * @default "system"
152
+ */
153
+ theme?: Theme;
154
+ /**
155
+ * Maximum number of visible toasts (excess queued)
156
+ * @default 3
157
+ */
158
+ visibleToasts?: number;
159
+ /**
160
+ * Default duration in milliseconds
161
+ * @default 4000
162
+ */
163
+ duration?: number;
164
+ /**
165
+ * Gap between toasts in pixels
166
+ * @default 12
167
+ */
168
+ gap?: number;
169
+ /**
170
+ * Offset from screen edges
171
+ * @default { top: 52, bottom: 52, left: 16, right: 16 }
172
+ */
173
+ offset?: {
174
+ top?: number;
175
+ bottom?: number;
176
+ left?: number;
177
+ right?: number;
178
+ };
179
+ /**
180
+ * Enable swipe to dismiss
181
+ * @default true
182
+ */
183
+ swipeToDismiss?: boolean;
184
+ /**
185
+ * Swipe direction(s) to dismiss
186
+ * @default ["left", "right"]
187
+ */
188
+ swipeDirection?: SwipeDirection | SwipeDirection[];
189
+ /**
190
+ * Pause toast timer when app is in background
191
+ * @default true
192
+ */
193
+ pauseOnAppBackground?: boolean;
194
+ /**
195
+ * Custom icons for toast types
196
+ */
197
+ icons?: ToastIcons;
198
+ /**
199
+ * Default styles for all toasts
200
+ */
201
+ toastStyles?: ToastStyles;
202
+ /**
203
+ * Custom container style
204
+ */
205
+ containerStyle?: StyleProp<ViewStyle>;
206
+ /**
207
+ * Rich colors mode (more vibrant backgrounds)
208
+ * @default false
209
+ */
210
+ richColors?: boolean;
211
+ /**
212
+ * Close button on toasts
213
+ * @default false
214
+ */
215
+ closeButton?: boolean;
216
+ /**
217
+ * Only show toasts with matching toasterId
218
+ */
219
+ toasterId?: string;
220
+ /**
221
+ * Default animation configuration
222
+ */
223
+ animation?: AnimationConfig;
224
+ /**
225
+ * Enable haptic feedback on toast actions
226
+ * @default false
227
+ */
228
+ hapticFeedback?: boolean;
229
+ }
230
+ /**
231
+ * Individual toast component props (internal)
232
+ */
233
+ export interface ToastProps {
234
+ toast: ToastT;
235
+ position: Position;
236
+ gap: number;
237
+ swipeToDismiss: boolean;
238
+ swipeDirection: SwipeDirection[];
239
+ theme: ResolvedTheme;
240
+ richColors: boolean;
241
+ closeButton: boolean;
242
+ icons?: ToastIcons;
243
+ defaultStyles?: ToastStyles;
244
+ defaultAnimation?: AnimationConfig;
245
+ onDismiss: (toastId: string | number) => void;
246
+ /** Default duration for auto-dismiss */
247
+ duration: number;
248
+ /** Pause timer when app goes to background */
249
+ pauseOnAppBackground: boolean;
250
+ hapticFeedback?: boolean;
251
+ }
252
+ /**
253
+ * Toast state subscriber callback
254
+ */
255
+ export type ToastStateSubscriber = (toast: ToastT) => void;
256
+ /**
257
+ * Toast dismiss subscriber callback
258
+ */
259
+ export type ToastDismissSubscriber = (toastId: string | number | undefined) => void;
260
+ /**
261
+ * Toast update subscriber callback
262
+ */
263
+ export type ToastUpdateSubscriber = (toast: ToastT) => void;
264
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,MAAM,GACN,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,eAAe,GACf,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,cAAc,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K,IAAI,CAAC;IAC9C,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;AAEpF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type AppStateStatus } from "react-native";
2
+ export declare function useAppState(): AppStateStatus;
3
+ //# sourceMappingURL=use-app-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-app-state.d.ts","sourceRoot":"","sources":["../../../src/use-app-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,wBAAgB,WAAW,IAAI,cAAc,CAW5C"}
@@ -0,0 +1,2 @@
1
+ export declare function usePauseableTimer(callback: () => void, duration: number, enabled: boolean, pauseOnBackground: boolean): void;
2
+ //# sourceMappingURL=use-pauseable-timer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pauseable-timer.d.ts","sourceRoot":"","sources":["../../../src/use-pauseable-timer.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,IAAI,EACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,OAAO,GACzB,IAAI,CAeN"}
@@ -0,0 +1,7 @@
1
+ import type { ToastT } from "./types";
2
+ export declare function useToastState(): {
3
+ toasts: ToastT[];
4
+ getToast: (id: string | number) => ToastT | undefined;
5
+ isActive: (id: string | number) => boolean;
6
+ };
7
+ //# sourceMappingURL=use-toast-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-toast-state.d.ts","sourceRoot":"","sources":["../../../src/use-toast-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,wBAAgB,aAAa;;mBAyBO,MAAM,GAAG,MAAM;mBAIf,MAAM,GAAG,MAAM;EASlD"}
package/package.json ADDED
@@ -0,0 +1,152 @@
1
+ {
2
+ "name": "react-native-sooner",
3
+ "version": "1.0.0",
4
+ "description": "A beautiful, lightweight toast library for React Native inspired by Sonner",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "!**/__tests__",
19
+ "!**/__fixtures__",
20
+ "!**/__mocks__",
21
+ "!**/.*"
22
+ ],
23
+ "scripts": {
24
+ "example": "yarn workspace react-native-sooner-example",
25
+ "clean": "del-cli lib example/android/build example/android/app/build example/ios/build",
26
+ "build": "bob build",
27
+ "typecheck": "tsc",
28
+ "test": "jest",
29
+ "release": "release-it --only-version"
30
+ },
31
+ "keywords": [
32
+ "react-native",
33
+ "toast",
34
+ "notification",
35
+ "sonner",
36
+ "expo",
37
+ "ios",
38
+ "android",
39
+ "snackbar",
40
+ "alert"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/idrissgarfa/react-native-sooner.git"
45
+ },
46
+ "author": "Idriss Garfa <idrissgarfa@outlook.com> (https://github.com/idrissgarfa)",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/idrissgarfa/react-native-sooner/issues"
50
+ },
51
+ "homepage": "https://github.com/idrissgarfa/react-native-sooner#readme",
52
+ "publishConfig": {
53
+ "registry": "https://registry.npmjs.org/"
54
+ },
55
+ "devDependencies": {
56
+ "@commitlint/config-conventional": "^19.8.1",
57
+ "@react-native/babel-preset": "0.83.0",
58
+ "@release-it/conventional-changelog": "^10.0.1",
59
+ "@types/jest": "^29.5.14",
60
+ "@types/react": "^19.2.0",
61
+ "commitlint": "^19.8.1",
62
+ "del-cli": "^6.0.0",
63
+ "jest": "^29.7.0",
64
+ "lefthook": "^2.0.3",
65
+ "react": "19.2.0",
66
+ "react-native": "0.83.0",
67
+ "react-native-builder-bob": "^0.40.13",
68
+ "react-native-gesture-handler": "^2.16.0",
69
+ "react-native-reanimated": "^3.10.0",
70
+ "react-native-safe-area-context": "^4.10.0",
71
+ "react-native-svg": "^15.0.0",
72
+ "release-it": "^19.0.4",
73
+ "turbo": "^2.5.6",
74
+ "typescript": "^5.9.2"
75
+ },
76
+ "peerDependencies": {
77
+ "react": ">=18.0.0",
78
+ "react-native": ">=0.70.0",
79
+ "react-native-gesture-handler": ">=2.0.0",
80
+ "react-native-reanimated": ">=3.0.0",
81
+ "react-native-safe-area-context": ">=4.0.0",
82
+ "react-native-svg": ">=13.0.0"
83
+ },
84
+ "peerDependenciesMeta": {
85
+ "react-native-svg": {
86
+ "optional": true
87
+ }
88
+ },
89
+ "workspaces": [
90
+ "example"
91
+ ],
92
+ "packageManager": "yarn@4.11.0",
93
+ "react-native-builder-bob": {
94
+ "source": "src",
95
+ "output": "lib",
96
+ "targets": [
97
+ [
98
+ "module",
99
+ {
100
+ "esm": true
101
+ }
102
+ ],
103
+ [
104
+ "typescript",
105
+ {
106
+ "project": "tsconfig.build.json"
107
+ }
108
+ ]
109
+ ]
110
+ },
111
+ "jest": {
112
+ "preset": "react-native",
113
+ "modulePathIgnorePatterns": [
114
+ "<rootDir>/example/node_modules",
115
+ "<rootDir>/lib/"
116
+ ]
117
+ },
118
+ "commitlint": {
119
+ "extends": [
120
+ "@commitlint/config-conventional"
121
+ ]
122
+ },
123
+ "release-it": {
124
+ "git": {
125
+ "commitMessage": "chore: release ${version}",
126
+ "tagName": "v${version}"
127
+ },
128
+ "npm": {
129
+ "publish": true
130
+ },
131
+ "github": {
132
+ "release": true
133
+ },
134
+ "plugins": {
135
+ "@release-it/conventional-changelog": {
136
+ "preset": {
137
+ "name": "angular"
138
+ }
139
+ }
140
+ }
141
+ },
142
+ "create-react-native-library": {
143
+ "type": "turbo-module",
144
+ "languages": "kotlin-objc",
145
+ "tools": [
146
+ "jest",
147
+ "lefthook",
148
+ "release-it"
149
+ ],
150
+ "version": "0.56.0"
151
+ }
152
+ }
@@ -0,0 +1,44 @@
1
+ import type { AnimationConfig, Position, SwipeDirection, Theme } from "./types";
2
+
3
+ export const ANIMATION_DEFAULTS: Required<AnimationConfig> = {
4
+ duration: 350,
5
+ exitDuration: 200,
6
+ useSpring: true,
7
+ damping: 18,
8
+ stiffness: 140,
9
+ mass: 1,
10
+ } as const;
11
+
12
+ export const ENTRY_OFFSET = 40;
13
+
14
+ export const SWIPE_THRESHOLD = 60;
15
+ export const VELOCITY_THRESHOLD = 500;
16
+ export const DAMPING_FACTOR = 0.5;
17
+ export const SWIPE_EXIT_DISTANCE = 300;
18
+ export const SNAP_BACK_DURATION = 150;
19
+
20
+ export const DEFAULT_ICON_SIZE = 20;
21
+
22
+ export const DISMISSED_CACHE_MAX_SIZE = 100;
23
+ export const DISMISSED_CACHE_CLEANUP_THRESHOLD = 50;
24
+
25
+ export const toastDefaults = {
26
+ duration: 3000,
27
+ position: "top-center" as Position,
28
+ gap: 12,
29
+ offset: {
30
+ top: 52,
31
+ bottom: 52,
32
+ left: 16,
33
+ right: 16,
34
+ },
35
+ swipeToDismiss: true,
36
+ swipeDirection: ["left", "right"] as SwipeDirection[],
37
+ theme: "system" as Theme,
38
+ richColors: false,
39
+ closeButton: false,
40
+ dismissible: true,
41
+ pauseOnAppBackground: true,
42
+ visibleToasts: 5,
43
+ hapticFeedback: false,
44
+ } as const;