rn-toastify 1.0.10 → 1.0.11

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/index.js CHANGED
@@ -1,26 +1,27 @@
1
- // CommonJS-friendly entry to avoid default/import interop issues with Metro in some RN versions
2
- // We attempt to require modules and use .default if present (handles transpiled ESM)
3
- const _useToastMod = require('./src/hooks/useToast');
4
- const _toastMod = require('./src/Toast');
5
- const _containerMod = require('./src/context/ToastContainer');
6
- const _successMod = require('./src/components/SuccessToast');
7
- const _customeMod = require('./src/components/CustomeToast');
8
- const _emojiMod = require('./src/components/EmojiToast');
9
- const _errorMod = require('./src/components/ErrorToast');
10
- const _loadingMod = require('./src/components/LoadingToast');
1
+ // Fixed index.js - Simplified export structure
2
+ const useToastModule = require('./src/hooks/useToast');
3
+ const ToastModule = require('./src/Toast');
4
+ const ToastContainerModule = require('./src/context/ToastContainer');
5
+ const SuccessToastModule = require('./src/components/SuccessToast');
6
+ const CustomeToastModule = require('./src/components/CustomeToast');
7
+ const EmojiToastModule = require('./src/components/EmojiToast');
8
+ const ErrorToastModule = require('./src/components/ErrorToast');
9
+ const LoadingToastModule = require('./src/components/LoadingToast');
11
10
 
12
- const useToast = (_useToastMod && _useToastMod.__esModule) ? _useToastMod.default : _useToastMod;
13
- const Toast = (_toastMod && _toastMod.__esModule) ? _toastMod.default : _toastMod;
14
- const ToastContainer = (_containerMod && _containerMod.__esModule) ? _containerMod.default : _containerMod;
15
- const SuccessToast = (_successMod && _successMod.__esModule) ? _successMod.default : _successMod;
16
- const CustomeToast = (_customeMod && _customeMod.__esModule) ? _customeMod.default : _customeMod;
17
- const EmojiToast = (_emojiMod && _emojiMod.__esModule) ? _emojiMod.default : _emojiMod;
18
- const ErrorToast = (_errorMod && _errorMod.__esModule) ? _errorMod.default : _errorMod;
19
- const LoadingToast = (_loadingMod && _loadingMod.__esModule) ? _loadingMod.default : _loadingMod;
11
+ // Extract default exports properly
12
+ const useToast = useToastModule.default || useToastModule;
13
+ const Toast = ToastModule.default || ToastModule;
14
+ const ToastContainer = ToastContainerModule.default || ToastContainerModule;
15
+ const SuccessToast = SuccessToastModule.default || SuccessToastModule;
16
+ const CustomeToast = CustomeToastModule.default || CustomeToastModule;
17
+ const EmojiToast = EmojiToastModule.default || EmojiToastModule;
18
+ const ErrorToast = ErrorToastModule.default || ErrorToastModule;
19
+ const LoadingToast = LoadingToastModule.default || LoadingToastModule;
20
20
 
21
- // Export for both require() and import syntax
21
+ // Primary default export
22
22
  module.exports = useToast;
23
- module.exports.default = useToast;
23
+
24
+ // Named exports
24
25
  module.exports.useToast = useToast;
25
26
  module.exports.Toast = Toast;
26
27
  module.exports.ToastContainer = ToastContainer;
@@ -28,4 +29,7 @@ module.exports.SuccessToast = SuccessToast;
28
29
  module.exports.CustomeToast = CustomeToast;
29
30
  module.exports.EmojiToast = EmojiToast;
30
31
  module.exports.ErrorToast = ErrorToast;
31
- module.exports.LoadingToast = LoadingToast;
32
+ module.exports.LoadingToast = LoadingToast;
33
+
34
+ // Also support default property for ES6 imports
35
+ module.exports.default = useToast;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-toastify",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "A customizable and performant toast notification library for React Native, featuring smooth animations, swipe gestures, and flexible styling options.",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "author": "Mukesh Prajapati",
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
- "react": ">=16.8.0 <19.0.0",
28
+ "react": ">=16.8.0 <20.0.0",
29
29
  "react-native": ">=0.60.0 <1.0.0",
30
30
  "react-native-reanimated": ">=2.0.0 <5.0.0",
31
31
  "lottie-react-native": ">=3.0.0 <9.0.0"
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { View, StyleSheet, Appearance, StatusBar, Platform, SafeAreaView } from 'react-native';
2
+ import { View, StyleSheet, Appearance, StatusBar, Platform } from 'react-native';
3
3
  import Toast from '../Toast';
4
4
  import toastManagerInstance from './ToastManager';
5
5
  import {
@@ -35,23 +35,29 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
35
35
  toastManagerInstance.off('remove', handleRemove);
36
36
  if (appearanceSub && appearanceSub.remove) appearanceSub.remove();
37
37
  };
38
- }, []);
38
+ }, [forcedTheme]);
39
+
40
+ // Calculate safe top margin for status bar
41
+ const getTopMargin = () => {
42
+ if (Platform.OS === 'android') {
43
+ return StatusBar.currentHeight || 0;
44
+ }
45
+ // For iOS, use a default safe area top margin
46
+ return 44; // Standard iOS notch/status bar height
47
+ };
39
48
 
40
49
  // Separate toasts by position
41
50
  const topToasts = toasts.filter(toast => toast?.options?.position === 'top');
42
51
  const centerToasts = toasts.filter(toast => toast?.options?.position === 'center');
43
52
  const bottomToasts = toasts.filter(toast => toast?.options?.position === 'bottom');
44
53
 
54
+ const topMargin = getTopMargin();
55
+
45
56
  return (
46
57
  <>
47
58
  {/* Top positioned toasts */}
48
- <SafeAreaView
49
- style={[
50
- styles.topContainer,
51
- {
52
- top: Platform.OS === 'android' ? StatusBar.currentHeight || 0 : 0,
53
- },
54
- ]}
59
+ <View
60
+ style={[styles.topContainer, { top: topMargin + hp(1) }]}
55
61
  pointerEvents="box-none"
56
62
  >
57
63
  {topToasts.map((toast, index) => (
@@ -61,13 +67,13 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
61
67
  duration={toast?.options?.duration}
62
68
  position="top"
63
69
  theme={theme}
64
- style={[toast?.options?.style || {}, { marginTop: index * 60 }]} // Adjust spacing between top toasts
70
+ style={[toast?.options?.style || {}, { marginTop: index * (hp(7) + hp(1)) }]}
65
71
  onHide={() => toastManagerInstance.remove(toast.id)}
66
72
  >
67
73
  {toast.content}
68
74
  </Toast>
69
75
  ))}
70
- </SafeAreaView>
76
+ </View>
71
77
 
72
78
  {/* Center positioned toasts */}
73
79
  <View style={styles.centerContainer} pointerEvents="box-none">
@@ -78,7 +84,7 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
78
84
  duration={toast?.options?.duration}
79
85
  position="center"
80
86
  theme={theme}
81
- style={[toast?.options?.style || {}, { marginTop: index * 60 }]} // Adjust spacing between center toasts
87
+ style={[toast?.options?.style || {}, { marginTop: index * (hp(7) + hp(1)) }]}
82
88
  onHide={() => toastManagerInstance.remove(toast.id)}
83
89
  >
84
90
  {toast.content}
@@ -95,7 +101,7 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
95
101
  duration={toast?.options?.duration}
96
102
  position="bottom"
97
103
  theme={theme}
98
- style={[toast?.options?.style || {}, { bottom: hp(2) + index * 60 }]} // Adjust spacing between bottom toasts
104
+ style={[toast?.options?.style || {}, { bottom: hp(2) + index * (hp(7) + hp(1)) }]}
99
105
  onHide={() => toastManagerInstance.remove(toast.id)}
100
106
  >
101
107
  {toast.content}
@@ -109,7 +115,6 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
109
115
  const styles = StyleSheet.create({
110
116
  topContainer: {
111
117
  position: 'absolute',
112
- top: 0,
113
118
  left: 0,
114
119
  right: 0,
115
120
  zIndex: 9999,
@@ -119,13 +124,12 @@ const styles = StyleSheet.create({
119
124
  centerContainer: {
120
125
  position: 'absolute',
121
126
  top: '50%',
122
- bottom: '50%',
123
127
  left: 0,
124
128
  right: 0,
125
129
  zIndex: 9999,
126
130
  pointerEvents: 'box-none',
127
131
  alignItems: 'center',
128
- transform: [{ translateY: -30 }] // Center the first toast vertically
132
+ transform: [{ translateY: -hp(3.5) }]
129
133
  },
130
134
  bottomContainer: {
131
135
  position: 'absolute',
@@ -138,4 +142,4 @@ const styles = StyleSheet.create({
138
142
  },
139
143
  });
140
144
 
141
- export default React.memo(ToastContainer);
145
+ export default React.memo(ToastContainer);