@umituz/react-native-auth 2.5.1 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AuthBottomSheet Component
|
|
3
3
|
* Bottom sheet modal for authentication (Login/Register)
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* ```tsx
|
|
7
|
-
* import { AuthBottomSheet } from '@umituz/react-native-auth';
|
|
8
|
-
*
|
|
9
|
-
* // In your app root (inside BottomSheetModalProvider)
|
|
10
|
-
* <AuthBottomSheet
|
|
11
|
-
* termsUrl="https://example.com/terms"
|
|
12
|
-
* privacyUrl="https://example.com/privacy"
|
|
13
|
-
* />
|
|
14
|
-
* ```
|
|
15
4
|
*/
|
|
16
5
|
|
|
17
6
|
import React, { useEffect, useCallback, useRef } from "react";
|
|
18
|
-
import { View, Text, StyleSheet,
|
|
7
|
+
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
|
|
19
8
|
import {
|
|
20
9
|
BottomSheetModal,
|
|
21
|
-
BottomSheetView,
|
|
22
10
|
BottomSheetBackdrop,
|
|
23
11
|
BottomSheetScrollView,
|
|
24
12
|
type BottomSheetBackdropProps,
|
|
25
13
|
} from "@gorhom/bottom-sheet";
|
|
26
14
|
import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
|
|
27
15
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
16
|
+
import { X } from "lucide-react-native";
|
|
28
17
|
import { useAuthModalStore } from "../stores/authModalStore";
|
|
29
18
|
import { useAuth } from "../hooks/useAuth";
|
|
30
19
|
import { LoginForm } from "./LoginForm";
|
|
31
20
|
import { RegisterForm } from "./RegisterForm";
|
|
32
21
|
|
|
33
22
|
export interface AuthBottomSheetProps {
|
|
34
|
-
/** Terms of Service URL */
|
|
35
23
|
termsUrl?: string;
|
|
36
|
-
/** Privacy Policy URL */
|
|
37
24
|
privacyUrl?: string;
|
|
38
|
-
/** Callback when Terms of Service is pressed */
|
|
39
25
|
onTermsPress?: () => void;
|
|
40
|
-
/** Callback when Privacy Policy is pressed */
|
|
41
26
|
onPrivacyPress?: () => void;
|
|
42
27
|
}
|
|
43
28
|
|
|
@@ -55,7 +40,6 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
|
|
|
55
40
|
useAuthModalStore();
|
|
56
41
|
const { isAuthenticated, isGuest } = useAuth();
|
|
57
42
|
|
|
58
|
-
// Present/dismiss modal based on visibility state
|
|
59
43
|
useEffect(() => {
|
|
60
44
|
if (isVisible) {
|
|
61
45
|
modalRef.current?.present();
|
|
@@ -64,7 +48,6 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
|
|
|
64
48
|
}
|
|
65
49
|
}, [isVisible]);
|
|
66
50
|
|
|
67
|
-
// Handle successful authentication
|
|
68
51
|
useEffect(() => {
|
|
69
52
|
if (isAuthenticated && !isGuest && isVisible) {
|
|
70
53
|
hideAuthModal();
|
|
@@ -77,6 +60,11 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
|
|
|
77
60
|
clearPendingCallback();
|
|
78
61
|
}, [hideAuthModal, clearPendingCallback]);
|
|
79
62
|
|
|
63
|
+
const handleClose = useCallback(() => {
|
|
64
|
+
modalRef.current?.dismiss();
|
|
65
|
+
handleDismiss();
|
|
66
|
+
}, [handleDismiss]);
|
|
67
|
+
|
|
80
68
|
const handleNavigateToRegister = useCallback(() => {
|
|
81
69
|
setMode("register");
|
|
82
70
|
}, [setMode]);
|
|
@@ -112,6 +100,14 @@ export const AuthBottomSheet: React.FC<AuthBottomSheetProps> = ({
|
|
|
112
100
|
showsVerticalScrollIndicator={false}
|
|
113
101
|
keyboardShouldPersistTaps="handled"
|
|
114
102
|
>
|
|
103
|
+
<TouchableOpacity
|
|
104
|
+
style={styles.closeButton}
|
|
105
|
+
onPress={handleClose}
|
|
106
|
+
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
107
|
+
>
|
|
108
|
+
<X size={24} color={tokens.colors.textSecondary} />
|
|
109
|
+
</TouchableOpacity>
|
|
110
|
+
|
|
115
111
|
<View style={styles.header}>
|
|
116
112
|
<Text style={[styles.title, { color: tokens.colors.textPrimary }]}>
|
|
117
113
|
{mode === "login" ? t("auth.signIn") : t("auth.createAccount")}
|
|
@@ -153,10 +149,18 @@ const styles = StyleSheet.create({
|
|
|
153
149
|
paddingHorizontal: 24,
|
|
154
150
|
paddingBottom: 40,
|
|
155
151
|
},
|
|
152
|
+
closeButton: {
|
|
153
|
+
position: "absolute",
|
|
154
|
+
top: 0,
|
|
155
|
+
right: 0,
|
|
156
|
+
padding: 8,
|
|
157
|
+
zIndex: 10,
|
|
158
|
+
},
|
|
156
159
|
header: {
|
|
157
160
|
alignItems: "center",
|
|
158
161
|
marginBottom: 24,
|
|
159
162
|
marginTop: 8,
|
|
163
|
+
paddingTop: 16,
|
|
160
164
|
},
|
|
161
165
|
title: {
|
|
162
166
|
fontSize: 28,
|
|
@@ -9,16 +9,13 @@ import { AtomicInput, AtomicButton } from "@umituz/react-native-design-system-at
|
|
|
9
9
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
10
|
import { useLoginForm } from "../hooks/useLoginForm";
|
|
11
11
|
import { AuthErrorDisplay } from "./AuthErrorDisplay";
|
|
12
|
-
import { AuthDivider } from "./AuthDivider";
|
|
13
12
|
import { AuthLink } from "./AuthLink";
|
|
14
13
|
|
|
15
14
|
interface LoginFormProps {
|
|
16
15
|
onNavigateToRegister: () => void;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export const LoginForm: React.FC<LoginFormProps> = ({
|
|
20
|
-
onNavigateToRegister,
|
|
21
|
-
}) => {
|
|
18
|
+
export const LoginForm: React.FC<LoginFormProps> = ({ onNavigateToRegister }) => {
|
|
22
19
|
const { t } = useLocalization();
|
|
23
20
|
const {
|
|
24
21
|
email,
|
|
@@ -29,7 +26,6 @@ export const LoginForm: React.FC<LoginFormProps> = ({
|
|
|
29
26
|
handleEmailChange,
|
|
30
27
|
handlePasswordChange,
|
|
31
28
|
handleSignIn,
|
|
32
|
-
handleContinueAsGuest,
|
|
33
29
|
displayError,
|
|
34
30
|
} = useLoginForm();
|
|
35
31
|
|
|
@@ -77,21 +73,6 @@ export const LoginForm: React.FC<LoginFormProps> = ({
|
|
|
77
73
|
</AtomicButton>
|
|
78
74
|
</View>
|
|
79
75
|
|
|
80
|
-
<AuthDivider />
|
|
81
|
-
|
|
82
|
-
<View style={styles.buttonContainer}>
|
|
83
|
-
<AtomicButton
|
|
84
|
-
variant="outline"
|
|
85
|
-
onPress={handleContinueAsGuest}
|
|
86
|
-
disabled={loading}
|
|
87
|
-
fullWidth
|
|
88
|
-
style={styles.guestButton}
|
|
89
|
-
testID="continue-as-guest-button"
|
|
90
|
-
>
|
|
91
|
-
{t("auth.continueAsGuest")}
|
|
92
|
-
</AtomicButton>
|
|
93
|
-
</View>
|
|
94
|
-
|
|
95
76
|
<AuthLink
|
|
96
77
|
text={t("auth.dontHaveAccount")}
|
|
97
78
|
linkText={t("auth.createAccount")}
|
|
@@ -112,8 +93,4 @@ const styles = StyleSheet.create({
|
|
|
112
93
|
signInButton: {
|
|
113
94
|
minHeight: 52,
|
|
114
95
|
},
|
|
115
|
-
guestButton: {
|
|
116
|
-
minHeight: 52,
|
|
117
|
-
},
|
|
118
96
|
});
|
|
119
|
-
|