@vvedantb/native-ui 0.31.0 → 0.32.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/README.md CHANGED
@@ -24,7 +24,7 @@ Optional, only if you import those components:
24
24
  - `@rn-primitives/portal` — `Select`. Mount one `<PortalHost />` from this package at the app root (for example in the root layout), outside any `Modal`. The package does not re-export it, so install it with `@rn-primitives/select`.
25
25
  - `@swmansion/react-native-bottom-sheet` — `BottomSheetContainer`. It needs the New Architecture, React Native 0.82 or later and a native build (no Expo Go), and no root provider.
26
26
  - `@react-native-community/datetimepicker` and `dayjs` — `DateTimeField`
27
- - `@clerk/clerk-expo`, `convex`, `expo-auth-session`, `expo-web-browser` and `expo-router` — `@vvedantb/native-ui/auth` (0.7.0). `expo-router` also for `@vvedantb/native-ui/expo-web-root`.
27
+ - `@clerk/expo`, `convex`, `expo-auth-session`, `expo-web-browser` and `expo-router` — `@vvedantb/native-ui/auth` (0.7.0). `expo-router` also for `@vvedantb/native-ui/expo-web-root`.
28
28
  - `react-native-gesture-handler` (`>=2.0.0`) — `@vvedantb/native-ui/gesture-handler` (Unreleased). Wrap the app in `GestureHandlerRootView`, and put `GestureHandlerProvider` from that entry inside it: the sheet drags (`SheetContent`, the compact `DialogContent`) then run on Gesture Handler, on the UI thread, and each overlay's `Modal` gets its own root view (Android needs one in every `Modal`). It also turns on the `SwipeableRow` swipe. Without the provider, the sheets drag with `PanResponder`, with the same rules, and a `SwipeableRow` does not swipe. Only that entry imports the peer, so an app without it bundles as before. In a Metro monorepo, resolve the peer from the app (one copy), as for `react`.
29
29
  - `react-native-keyboard-controller` (`>=1.21.0`) — `@vvedantb/native-ui/keyboard-controller` (Unreleased). Put `KeyboardControllerProvider` from that entry inside the app's `KeyboardProvider`: the chat transcript (`ConversationList`), the dock (`ConversationDock`) and its scroll button then follow the keyboard frame by frame, a drag down on the transcript moves the keyboard with the finger (iOS, Android 11+; Android 10 and below lower it at once), and `PromptInput`, `ChatThread`, the overlays and `KeyboardAvoidingView` pad frame by frame. The dock moves by the keyboard less the bottom inset: its content pads that inset, as `PromptInput` does. Without the provider, every part keeps React Native's `KeyboardAvoidingView`. Only that entry imports the peer. In a Metro monorepo, resolve the peer from the app (one copy): the parts read its provider's context.
30
30
  - `react-native-svg` — the app marks (`APP_ICONS`, `Icon*`, `AppMark`, `AppWordmark`), `GoogleMark` and `PricingModal`. Apps with the icon peers above already have it: `lucide-react-native` and `@tabler/icons-react-native` both require it.
@@ -100,7 +100,7 @@ The root entry exports everything. It still imports `BottomSheetContainer` and `
100
100
  | `@vvedantb/native-ui/date-time` | `DateTimeField`, `DateTimeFieldProps` (0.5.0) | `@react-native-community/datetimepicker`, `dayjs` (import) |
101
101
  | `@vvedantb/native-ui/ai` | The AI chat parts (from 0.4.0): `Conversation`, `Message`, `Reasoning`, `AgentTrace`, `ChainOfThought`, `ActivityStep`, `PromptInput`, `Suggestions`, `Sources`, `FileChip`, `Attachments`, `CodeBlock`, `ResponseText`, `Shimmer`, `Collapsible`, `useStreamingDisclosure` and their parts. See [AI chat](#ai-chat-040). Not on the root entry.. From 0.12.0: `ChatThread`, `UIMessage`, `ChatJumpRail` and the `Attachment` props `onPress` and `accessibilityLabel` | none |
102
102
  | `@vvedantb/native-ui/ai-gallery` | `AiChatGallery`, `AiChatSamples` (from 0.4.0) | none |
103
- | `@vvedantb/native-ui/auth` | From 0.7.0: `AuthProviders`, `SignInScreen`, `SignUpScreen`, `GoogleSignInButton`, `useGoogleSignIn`, `AuthScreen`, `OrDivider`, `FieldError`, `authErrorMessage`, `SecondFactorScreen`, `useSecondFactor`, `submitTotpSecondFactor`, `submitSecondFactor`, `prepareSecondFactorIfNeeded`, `prepareFirstFactorIfNeeded`, `submitFirstFactor`, `pickFirstFactorStrategy`, `TOTP_MESSAGES` and their props types. See [Auth](#auth-070). Not on the root entry. | `@clerk/clerk-expo`, `convex`, `expo-auth-session`, `expo-web-browser`, `expo-router` (import) |
103
+ | `@vvedantb/native-ui/auth` | From 0.7.0: `AuthProviders`, `SignInScreen`, `SignUpScreen`, `ChangePasswordScreen`, `DeleteAccountScreen` (0.32.0), `GoogleSignInButton`, `useGoogleSignIn`, `AuthScreen`, `OrDivider`, `FieldError`, `authErrorMessage`, `SecondFactorScreen`, `useSecondFactor`, `submitTotpSecondFactor`, `submitSecondFactor`, `prepareSecondFactorIfNeeded`, `prepareFirstFactorIfNeeded`, `submitFirstFactor`, `pickFirstFactorStrategy`, `TOTP_MESSAGES` and their props types. See [Auth](#auth-070). Not on the root entry. | `@clerk/expo`, `convex`, `expo-auth-session`, `expo-web-browser`, `expo-router` (import) |
104
104
  | `@vvedantb/native-ui/expo-router` | From 0.12.0: `RouterStackPageHeader`, `RouterStackPageHeaderProps`, `goBackOrReplace`. Not on the root, `/layout` or `/page-title` entries. | `expo-router` (import) |
105
105
  | `@vvedantb/native-ui/expo-web-root` | From 0.7.0: `ExpoWebRoot`, `ExpoWebRootProps`, `ExpoWebRootViewport`, `EXPO_WEB_VIEWPORT`, `expoWebBackgroundCss`. Not on the root entry. | `expo-router` (import of `expo-router/html`) |
106
106
  | `@vvedantb/native-ui/tailwind-preset` | From 0.7.0, CommonJS for `tailwind.config.js`: `nativeUiPreset`, `nativeUiContent`, `cssVar`, `hslVar`, `rgbAlpha`, `cssVariables`, `schemeColors` and a default preset. See [Expo / NativeWind](#expo--nativewind). | `nativewind` (`require`, when installed) |
@@ -197,12 +197,12 @@ It renders `<html lang="en">`, the charset, `X-UA-Compatible` and viewport meta
197
197
 
198
198
  ## Auth (0.7.0)
199
199
 
200
- `@vvedantb/native-ui/auth` has the Clerk and Convex providers and a sign-in and sign-up screen. It needs `@clerk/clerk-expo`, `expo-auth-session`, `expo-web-browser` and `expo-router`, and `convex` when you pass a Convex client.
200
+ `@vvedantb/native-ui/auth` has the Clerk and Convex providers and a sign-in and sign-up screen. It needs `@clerk/expo`, `expo-auth-session`, `expo-web-browser` and `expo-router`, and `convex` when you pass a Convex client.
201
201
 
202
202
  ```tsx
203
203
  // app/_layout.tsx
204
- import { useAuth } from "@clerk/clerk-expo";
205
- import { tokenCache } from "@clerk/clerk-expo/token-cache";
204
+ import { useAuth } from "@clerk/expo";
205
+ import { tokenCache } from "@clerk/expo/token-cache";
206
206
  import { AuthProviders } from "@vvedantb/native-ui/auth";
207
207
 
208
208
  <AuthProviders publishableKey={publishableKey} tokenCache={tokenCache} convex={convex} useAuth={useAuth}>
@@ -210,7 +210,7 @@ import { AuthProviders } from "@vvedantb/native-ui/auth";
210
210
  </AuthProviders>
211
211
  ```
212
212
 
213
- `AuthProviders` nests `ClerkProvider`, `ConvexProviderWithClerk` (only with `convex`) and `ClerkLoaded` (with `loaded`, default `true`). Without `convex` the children sit under Clerk only. `clerk={false}` gives a plain `ConvexProvider`, for UI preview builds. The app reads its own key; the component checks nothing.
213
+ `AuthProviders` nests `ClerkProvider`, `ConvexProviderWithClerk` (only with `convex`) and `ClerkLoaded` (with `loaded`, default `true`). Without `convex` the children sit under Clerk only. `clerk={false}` gives a plain `ConvexProvider`, for UI preview builds. The app reads its own key; the component checks nothing. From 0.32.0 the Clerk peer is `@clerk/expo` 4 or later (not `@clerk/clerk-expo`): pass `publishableKey`, because `@clerk/expo` does not read it from the environment.
214
214
 
215
215
  ```tsx
216
216
  // app/(auth)/sign-in.tsx
@@ -256,6 +256,22 @@ export default function SignUp() {
256
256
 
257
257
  ### Second factor (0.10.0)
258
258
 
259
+ Account screens (0.32.0), for a signed-in user. Both use `useUser` from `@clerk/expo` and show errors under the fields.
260
+
261
+ ```tsx
262
+ import { ChangePasswordScreen, DeleteAccountScreen } from "@vvedantb/native-ui/auth";
263
+
264
+ // app/(app)/change-password.tsx
265
+ <ChangePasswordScreen minPasswordLength={8} onCancel={() => router.back()} />
266
+
267
+ // app/(app)/delete-account.tsx
268
+ <DeleteAccountScreen afterDeleteHref="/sign-in" onCancel={() => router.back()} />
269
+ ```
270
+
271
+ - `ChangePasswordScreen` calls `user.updatePassword`: the current password, then the new one twice. An account with no password (Google only) gets no current-password field. `signOutOfOtherSessions` defaults to `true`. After the change it calls `onSuccess`, or `router.back()`.
272
+ - `DeleteAccountScreen` calls `user.delete()`. The user types `confirmWord` (default `DELETE`) first; the button stays off until it matches. Turn on "Allow users to delete their accounts" in the Clerk dashboard, or the call fails. After the delete it calls `onDeleted`, or `router.replace(afterDeleteHref)`.
273
+ - `testID`s: `change-password-current`, `-new`, `-confirm`, `-error`, `-submit`, `-cancel`; `delete-account-confirm`, `-error`, `-submit`, `-cancel`. Change the prefix with `testIDPrefix`.
274
+
259
275
  `SecondFactorScreen` is a one-time code step with no Clerk import. The caller owns the check.
260
276
 
261
277
  | Prop | Default | Use |
@@ -0,0 +1,450 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { useRef, useState } from "react";
3
+ import { useUser } from "@clerk/expo";
4
+ import { useRouter } from "expo-router";
5
+ import { Button } from "../Button";
6
+ import { Input } from "../Input";
7
+ import { PasswordInput } from "../PasswordInput";
8
+ import { AuthScreen, FieldError } from "./AuthScreen";
9
+ import { authErrorMessage, DEFAULT_STAGE_TIMEOUT_MS, logAuthFailure, withAuthTimeout } from "./authErrors";
10
+
11
+ /** The messages the account screens can show. Generic: none names a provider. */
12
+ export const ACCOUNT_MESSAGES = {
13
+ changePasswordTitle: "Change password",
14
+ changePasswordSubtitle: "Enter your current password, then a new one.",
15
+ setPasswordTitle: "Set a password",
16
+ setPasswordSubtitle: "Your account has no password yet. Choose one.",
17
+ currentPasswordLabel: "Current password",
18
+ newPasswordLabel: "New password",
19
+ confirmPasswordLabel: "Confirm new password",
20
+ missingCurrentPassword: "Enter your current password",
21
+ missingNewPassword: "Enter a new password",
22
+ passwordMismatch: "The passwords do not match",
23
+ changePasswordFailed: "Could not change the password",
24
+ changePassword: "Change password",
25
+ setPassword: "Set password",
26
+ deleteTitle: "Delete account",
27
+ deleteSubtitle: "This deletes your account and its data. It cannot be undone.",
28
+ deleteConfirmMismatch: "Type the word exactly to confirm",
29
+ deleteFailed: "Could not delete the account",
30
+ deleteAccount: "Delete account",
31
+ cancel: "Cancel",
32
+ notReady: "Your account is not ready yet. Try again in a moment."
33
+ };
34
+ /**
35
+ * Changes the signed-in user's password with `user.updatePassword`: the
36
+ * current password, then the new one typed twice. An account with no password
37
+ * (Google only) gets no current-password field and the "Set a password" copy.
38
+ * Errors show under the fields. Render it under `ClerkProvider`, signed in.
39
+ */
40
+ export function ChangePasswordScreen(t0) {
41
+ const $ = _c(55);
42
+ const {
43
+ title,
44
+ subtitle,
45
+ header,
46
+ footer,
47
+ onCancel,
48
+ stageTimeoutMs: t1,
49
+ minPasswordLength,
50
+ signOutOfOtherSessions: t2,
51
+ onSuccess,
52
+ testIDPrefix: t3
53
+ } = t0;
54
+ const stageTimeoutMs = t1 === undefined ? DEFAULT_STAGE_TIMEOUT_MS : t1;
55
+ const signOutOfOtherSessions = t2 === undefined ? true : t2;
56
+ const testIDPrefix = t3 === undefined ? "change-password" : t3;
57
+ const {
58
+ isLoaded,
59
+ user
60
+ } = useUser();
61
+ const router = useRouter();
62
+ const [current, setCurrent] = useState("");
63
+ const [next, setNext] = useState("");
64
+ const [confirm, setConfirm] = useState("");
65
+ const [error, setError] = useState("");
66
+ const [submitting, setSubmitting] = useState(false);
67
+ const nextField = useRef(null);
68
+ const confirmField = useRef(null);
69
+ let t4;
70
+ if ($[0] !== testIDPrefix) {
71
+ t4 = name => `${testIDPrefix}-${name}`;
72
+ $[0] = testIDPrefix;
73
+ $[1] = t4;
74
+ } else {
75
+ t4 = $[1];
76
+ }
77
+ const id = t4;
78
+ const hasPassword = user ? user.passwordEnabled : true;
79
+ let t5;
80
+ if ($[2] !== confirm || $[3] !== current || $[4] !== hasPassword || $[5] !== isLoaded || $[6] !== minPasswordLength || $[7] !== next || $[8] !== onSuccess || $[9] !== router || $[10] !== signOutOfOtherSessions || $[11] !== stageTimeoutMs || $[12] !== submitting || $[13] !== user) {
81
+ t5 = async () => {
82
+ if (submitting) {
83
+ return;
84
+ }
85
+ if (!isLoaded || !user) {
86
+ return setError(ACCOUNT_MESSAGES.notReady);
87
+ }
88
+ if (hasPassword && !current) {
89
+ return setError(ACCOUNT_MESSAGES.missingCurrentPassword);
90
+ }
91
+ if (!next) {
92
+ return setError(ACCOUNT_MESSAGES.missingNewPassword);
93
+ }
94
+ if (minPasswordLength && next.length < minPasswordLength) {
95
+ return setError(`Use at least ${minPasswordLength} characters for the password`);
96
+ }
97
+ if (next !== confirm) {
98
+ return setError(ACCOUNT_MESSAGES.passwordMismatch);
99
+ }
100
+ setSubmitting(true);
101
+ setError("");
102
+ const params = hasPassword ? {
103
+ newPassword: next,
104
+ signOutOfOtherSessions,
105
+ currentPassword: current
106
+ } : {
107
+ newPassword: next,
108
+ signOutOfOtherSessions
109
+ };
110
+ let failed = false;
111
+ let failure;
112
+ ;
113
+ try {
114
+ await withAuthTimeout(user.updatePassword(params), "update-password", stageTimeoutMs);
115
+ } catch (t6) {
116
+ const caught = t6;
117
+ failed = true;
118
+ failure = caught;
119
+ }
120
+ setSubmitting(false);
121
+ if (failed) {
122
+ logAuthFailure("update-password", failure);
123
+ return setError(authErrorMessage(failure, ACCOUNT_MESSAGES.changePasswordFailed));
124
+ }
125
+ setCurrent("");
126
+ setNext("");
127
+ setConfirm("");
128
+ if (onSuccess) {
129
+ onSuccess();
130
+ } else {
131
+ router.back();
132
+ }
133
+ };
134
+ $[2] = confirm;
135
+ $[3] = current;
136
+ $[4] = hasPassword;
137
+ $[5] = isLoaded;
138
+ $[6] = minPasswordLength;
139
+ $[7] = next;
140
+ $[8] = onSuccess;
141
+ $[9] = router;
142
+ $[10] = signOutOfOtherSessions;
143
+ $[11] = stageTimeoutMs;
144
+ $[12] = submitting;
145
+ $[13] = user;
146
+ $[14] = t5;
147
+ } else {
148
+ t5 = $[14];
149
+ }
150
+ const submit = t5;
151
+ const t6 = id("screen");
152
+ const t7 = title ?? (hasPassword ? ACCOUNT_MESSAGES.changePasswordTitle : ACCOUNT_MESSAGES.setPasswordTitle);
153
+ const t8 = subtitle ?? (hasPassword ? ACCOUNT_MESSAGES.changePasswordSubtitle : ACCOUNT_MESSAGES.setPasswordSubtitle);
154
+ let t9;
155
+ if ($[15] !== current || $[16] !== hasPassword || $[17] !== id) {
156
+ t9 = hasPassword ? <PasswordInput testID={id("current")} accessibilityLabel={ACCOUNT_MESSAGES.currentPasswordLabel} autoCapitalize="none" autoComplete="password" textContentType="password" returnKeyType="next" submitBehavior="submit" onSubmitEditing={() => nextField.current?.focus()} value={current} placeholder={ACCOUNT_MESSAGES.currentPasswordLabel} onChangeText={setCurrent} /> : null;
157
+ $[15] = current;
158
+ $[16] = hasPassword;
159
+ $[17] = id;
160
+ $[18] = t9;
161
+ } else {
162
+ t9 = $[18];
163
+ }
164
+ const t10 = id("new");
165
+ let t11;
166
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
167
+ t11 = () => confirmField.current?.focus();
168
+ $[19] = t11;
169
+ } else {
170
+ t11 = $[19];
171
+ }
172
+ let t12;
173
+ if ($[20] !== next || $[21] !== t10) {
174
+ t12 = <PasswordInput testID={t10} ref={nextField} accessibilityLabel={ACCOUNT_MESSAGES.newPasswordLabel} autoCapitalize="none" autoComplete="new-password" textContentType="newPassword" returnKeyType="next" submitBehavior="submit" onSubmitEditing={t11} value={next} placeholder={ACCOUNT_MESSAGES.newPasswordLabel} onChangeText={setNext} />;
175
+ $[20] = next;
176
+ $[21] = t10;
177
+ $[22] = t12;
178
+ } else {
179
+ t12 = $[22];
180
+ }
181
+ const t13 = id("confirm");
182
+ let t14;
183
+ if ($[23] !== submit) {
184
+ t14 = () => void submit();
185
+ $[23] = submit;
186
+ $[24] = t14;
187
+ } else {
188
+ t14 = $[24];
189
+ }
190
+ let t15;
191
+ if ($[25] !== confirm || $[26] !== t13 || $[27] !== t14) {
192
+ t15 = <PasswordInput testID={t13} ref={confirmField} accessibilityLabel={ACCOUNT_MESSAGES.confirmPasswordLabel} autoCapitalize="none" autoComplete="new-password" textContentType="newPassword" returnKeyType="go" value={confirm} placeholder={ACCOUNT_MESSAGES.confirmPasswordLabel} onChangeText={setConfirm} onSubmitEditing={t14} />;
193
+ $[25] = confirm;
194
+ $[26] = t13;
195
+ $[27] = t14;
196
+ $[28] = t15;
197
+ } else {
198
+ t15 = $[28];
199
+ }
200
+ const t16 = id("error");
201
+ let t17;
202
+ if ($[29] !== error || $[30] !== t16) {
203
+ t17 = <FieldError testID={t16} message={error} />;
204
+ $[29] = error;
205
+ $[30] = t16;
206
+ $[31] = t17;
207
+ } else {
208
+ t17 = $[31];
209
+ }
210
+ const t18 = id("submit");
211
+ let t19;
212
+ if ($[32] !== submit) {
213
+ t19 = () => void submit();
214
+ $[32] = submit;
215
+ $[33] = t19;
216
+ } else {
217
+ t19 = $[33];
218
+ }
219
+ const t20 = hasPassword ? ACCOUNT_MESSAGES.changePassword : ACCOUNT_MESSAGES.setPassword;
220
+ let t21;
221
+ if ($[34] !== submitting || $[35] !== t18 || $[36] !== t19 || $[37] !== t20) {
222
+ t21 = <Button testID={t18} loading={submitting} onPress={t19}>{t20}</Button>;
223
+ $[34] = submitting;
224
+ $[35] = t18;
225
+ $[36] = t19;
226
+ $[37] = t20;
227
+ $[38] = t21;
228
+ } else {
229
+ t21 = $[38];
230
+ }
231
+ let t22;
232
+ if ($[39] !== id || $[40] !== onCancel || $[41] !== submitting) {
233
+ t22 = onCancel ? <Button testID={id("cancel")} variant="ghost" disabled={submitting} onPress={onCancel}>{ACCOUNT_MESSAGES.cancel}</Button> : null;
234
+ $[39] = id;
235
+ $[40] = onCancel;
236
+ $[41] = submitting;
237
+ $[42] = t22;
238
+ } else {
239
+ t22 = $[42];
240
+ }
241
+ let t23;
242
+ if ($[43] !== footer || $[44] !== header || $[45] !== t12 || $[46] !== t15 || $[47] !== t17 || $[48] !== t21 || $[49] !== t22 || $[50] !== t6 || $[51] !== t7 || $[52] !== t8 || $[53] !== t9) {
243
+ t23 = <AuthScreen testID={t6} title={t7} subtitle={t8} header={header} footer={footer}>{t9}{t12}{t15}{t17}{t21}{t22}</AuthScreen>;
244
+ $[43] = footer;
245
+ $[44] = header;
246
+ $[45] = t12;
247
+ $[46] = t15;
248
+ $[47] = t17;
249
+ $[48] = t21;
250
+ $[49] = t22;
251
+ $[50] = t6;
252
+ $[51] = t7;
253
+ $[52] = t8;
254
+ $[53] = t9;
255
+ $[54] = t23;
256
+ } else {
257
+ t23 = $[54];
258
+ }
259
+ return t23;
260
+ }
261
+ /**
262
+ * Deletes the signed-in user's account with `user.delete()`. The user types
263
+ * `confirmWord` first; the delete button stays off until it matches. Needs
264
+ * "Allow users to delete their accounts" turned on for the instance. Errors
265
+ * show under the field. Render it under `ClerkProvider`, signed in.
266
+ */
267
+ export function DeleteAccountScreen(t0) {
268
+ const $ = _c(44);
269
+ const {
270
+ title,
271
+ subtitle,
272
+ header,
273
+ footer,
274
+ onCancel,
275
+ stageTimeoutMs: t1,
276
+ confirmWord: t2,
277
+ onDeleted,
278
+ afterDeleteHref: t3,
279
+ testIDPrefix: t4
280
+ } = t0;
281
+ const stageTimeoutMs = t1 === undefined ? DEFAULT_STAGE_TIMEOUT_MS : t1;
282
+ const confirmWord = t2 === undefined ? "DELETE" : t2;
283
+ const afterDeleteHref = t3 === undefined ? "/" : t3;
284
+ const testIDPrefix = t4 === undefined ? "delete-account" : t4;
285
+ const {
286
+ isLoaded,
287
+ user
288
+ } = useUser();
289
+ const router = useRouter();
290
+ const [typed, setTyped] = useState("");
291
+ const [error, setError] = useState("");
292
+ const [submitting, setSubmitting] = useState(false);
293
+ let t5;
294
+ if ($[0] !== testIDPrefix) {
295
+ t5 = name => `${testIDPrefix}-${name}`;
296
+ $[0] = testIDPrefix;
297
+ $[1] = t5;
298
+ } else {
299
+ t5 = $[1];
300
+ }
301
+ const id = t5;
302
+ let t6;
303
+ if ($[2] !== typed) {
304
+ t6 = typed.trim().toLowerCase();
305
+ $[2] = typed;
306
+ $[3] = t6;
307
+ } else {
308
+ t6 = $[3];
309
+ }
310
+ let t7;
311
+ if ($[4] !== confirmWord) {
312
+ t7 = confirmWord.toLowerCase();
313
+ $[4] = confirmWord;
314
+ $[5] = t7;
315
+ } else {
316
+ t7 = $[5];
317
+ }
318
+ const matches = t6 === t7;
319
+ let t8;
320
+ if ($[6] !== afterDeleteHref || $[7] !== isLoaded || $[8] !== matches || $[9] !== onDeleted || $[10] !== router || $[11] !== stageTimeoutMs || $[12] !== submitting || $[13] !== user) {
321
+ t8 = async () => {
322
+ if (submitting) {
323
+ return;
324
+ }
325
+ if (!matches) {
326
+ return setError(ACCOUNT_MESSAGES.deleteConfirmMismatch);
327
+ }
328
+ if (!isLoaded || !user) {
329
+ return setError(ACCOUNT_MESSAGES.notReady);
330
+ }
331
+ setSubmitting(true);
332
+ setError("");
333
+ let failed = false;
334
+ let failure;
335
+ ;
336
+ try {
337
+ await withAuthTimeout(user.delete(), "delete-account", stageTimeoutMs);
338
+ } catch (t9) {
339
+ const caught = t9;
340
+ failed = true;
341
+ failure = caught;
342
+ }
343
+ setSubmitting(false);
344
+ if (failed) {
345
+ logAuthFailure("delete-account", failure);
346
+ return setError(authErrorMessage(failure, ACCOUNT_MESSAGES.deleteFailed));
347
+ }
348
+ if (onDeleted) {
349
+ onDeleted();
350
+ } else {
351
+ router.replace(afterDeleteHref);
352
+ }
353
+ };
354
+ $[6] = afterDeleteHref;
355
+ $[7] = isLoaded;
356
+ $[8] = matches;
357
+ $[9] = onDeleted;
358
+ $[10] = router;
359
+ $[11] = stageTimeoutMs;
360
+ $[12] = submitting;
361
+ $[13] = user;
362
+ $[14] = t8;
363
+ } else {
364
+ t8 = $[14];
365
+ }
366
+ const submit = t8;
367
+ const label = `Type ${confirmWord} to confirm`;
368
+ const t9 = id("screen");
369
+ const t10 = title ?? ACCOUNT_MESSAGES.deleteTitle;
370
+ const t11 = subtitle ?? ACCOUNT_MESSAGES.deleteSubtitle;
371
+ const t12 = id("confirm");
372
+ let t13;
373
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
374
+ t13 = text => {
375
+ setTyped(text);
376
+ setError("");
377
+ };
378
+ $[15] = t13;
379
+ } else {
380
+ t13 = $[15];
381
+ }
382
+ let t14;
383
+ if ($[16] !== label || $[17] !== t12 || $[18] !== typed) {
384
+ t14 = <Input testID={t12} accessibilityLabel={label} autoCapitalize="characters" autoCorrect={false} returnKeyType="done" value={typed} placeholder={label} onChangeText={t13} />;
385
+ $[16] = label;
386
+ $[17] = t12;
387
+ $[18] = typed;
388
+ $[19] = t14;
389
+ } else {
390
+ t14 = $[19];
391
+ }
392
+ const t15 = id("error");
393
+ let t16;
394
+ if ($[20] !== error || $[21] !== t15) {
395
+ t16 = <FieldError testID={t15} message={error} />;
396
+ $[20] = error;
397
+ $[21] = t15;
398
+ $[22] = t16;
399
+ } else {
400
+ t16 = $[22];
401
+ }
402
+ const t17 = id("submit");
403
+ const t18 = !matches;
404
+ let t19;
405
+ if ($[23] !== submit) {
406
+ t19 = () => void submit();
407
+ $[23] = submit;
408
+ $[24] = t19;
409
+ } else {
410
+ t19 = $[24];
411
+ }
412
+ let t20;
413
+ if ($[25] !== submitting || $[26] !== t17 || $[27] !== t18 || $[28] !== t19) {
414
+ t20 = <Button testID={t17} variant="destructive" loading={submitting} disabled={t18} onPress={t19}>{ACCOUNT_MESSAGES.deleteAccount}</Button>;
415
+ $[25] = submitting;
416
+ $[26] = t17;
417
+ $[27] = t18;
418
+ $[28] = t19;
419
+ $[29] = t20;
420
+ } else {
421
+ t20 = $[29];
422
+ }
423
+ let t21;
424
+ if ($[30] !== id || $[31] !== onCancel || $[32] !== submitting) {
425
+ t21 = onCancel ? <Button testID={id("cancel")} variant="ghost" disabled={submitting} onPress={onCancel}>{ACCOUNT_MESSAGES.cancel}</Button> : null;
426
+ $[30] = id;
427
+ $[31] = onCancel;
428
+ $[32] = submitting;
429
+ $[33] = t21;
430
+ } else {
431
+ t21 = $[33];
432
+ }
433
+ let t22;
434
+ if ($[34] !== footer || $[35] !== header || $[36] !== t10 || $[37] !== t11 || $[38] !== t14 || $[39] !== t16 || $[40] !== t20 || $[41] !== t21 || $[42] !== t9) {
435
+ t22 = <AuthScreen testID={t9} title={t10} subtitle={t11} header={header} footer={footer}>{t14}{t16}{t20}{t21}</AuthScreen>;
436
+ $[34] = footer;
437
+ $[35] = header;
438
+ $[36] = t10;
439
+ $[37] = t11;
440
+ $[38] = t14;
441
+ $[39] = t16;
442
+ $[40] = t20;
443
+ $[41] = t21;
444
+ $[42] = t9;
445
+ $[43] = t22;
446
+ } else {
447
+ t22 = $[43];
448
+ }
449
+ return t22;
450
+ }
@@ -1,4 +1,4 @@
1
- import { ClerkLoaded, ClerkProvider, useAuth as useClerkAuth } from "@clerk/clerk-expo";
1
+ import { ClerkLoaded, ClerkProvider, useAuth as useClerkAuth } from "@clerk/expo";
2
2
  import { ConvexProvider } from "convex/react";
3
3
  import { ConvexProviderWithClerk } from "convex/react-clerk";
4
4
  /**
@@ -19,7 +19,7 @@ export function AuthProviders({
19
19
  return convex ? <ConvexProvider client={convex}>{children}</ConvexProvider> : <>{children}</>;
20
20
  }
21
21
  const inner = loaded ? <ClerkLoaded>{children}</ClerkLoaded> : children;
22
- return <ClerkProvider publishableKey={publishableKey} tokenCache={tokenCache}>
22
+ return <ClerkProvider publishableKey={publishableKey ?? ""} tokenCache={tokenCache}>
23
23
  {convex ? <ConvexProviderWithClerk client={convex} useAuth={useAuth}>
24
24
  {inner}
25
25
  </ConvexProviderWithClerk> : inner}
@@ -1,7 +1,7 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { Platform } from "react-native";
4
- import { useSSO } from "@clerk/clerk-expo";
4
+ import { useSSO } from "@clerk/expo";
5
5
  import * as AuthSession from "expo-auth-session";
6
6
  import * as WebBrowser from "expo-web-browser";
7
7
  import { useRouter } from "expo-router";
@@ -1,7 +1,7 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useRef, useState } from "react";
3
3
  import { Text, View } from "react-native";
4
- import { useSignIn, useSignUp } from "@clerk/clerk-expo";
4
+ import { useSignIn, useSignUp } from "@clerk/expo/legacy";
5
5
  import { useRouter } from "expo-router";
6
6
  import { Button } from "../Button";
7
7
  import { textStyle } from "../controlStyles";
@@ -1,4 +1,4 @@
1
- import { isClerkAPIResponseError } from "@clerk/clerk-expo";
1
+ import { isClerkAPIResponseError } from "@clerk/expo";
2
2
 
3
3
  /** Words that must not reach the user: the auth provider and stack names. */
4
4
  const PRODUCT_NAMES = /\b(clerk|convex)\b/gi;
@@ -1,5 +1,5 @@
1
1
  // Clerk + Convex providers and the shared sign-in and sign-up screens. On
2
- // `@vvedantb/native-ui/auth` only: they import `@clerk/clerk-expo`, `convex`,
2
+ // `@vvedantb/native-ui/auth` only: they import `@clerk/expo`, `convex`,
3
3
  // `expo-auth-session`, `expo-web-browser` and `expo-router`, and Metro does not
4
4
  // tree-shake.
5
5
  export { AuthProviders } from "./AuthProviders";
@@ -7,5 +7,6 @@ export { AuthScreen, OrDivider, FieldError } from "./AuthScreen";
7
7
  export { authErrorMessage, logAuthFailure, withAuthTimeout, AuthTimeoutError, isAuthTimeoutError, AUTH_TIMEOUT_CODE, DEFAULT_STAGE_TIMEOUT_MS, CREDENTIAL_ERROR_CODES } from "./authErrors";
8
8
  export { GoogleSignInButton, useGoogleSignIn, useWarmUpBrowser, GOOGLE_ERROR_MESSAGE } from "./GoogleSignInButton";
9
9
  export { SignInScreen, SignUpScreen, ResetPasswordScreen, AUTH_MESSAGES } from "./SignInScreen";
10
+ export { ChangePasswordScreen, DeleteAccountScreen, ACCOUNT_MESSAGES } from "./AccountScreens";
10
11
  export { SecondFactorScreen } from "./SecondFactorScreen";
11
12
  export { submitTotpSecondFactor, submitSecondFactor, prepareSecondFactorIfNeeded, prepareFirstFactorIfNeeded, submitFirstFactor, pickFirstFactorStrategy, supportedFirstFactorStrategies, FIRST_FACTOR_PREFERENCE, pickSecondFactorStrategy, supportedSecondFactorStrategies, SECOND_FACTOR_PREFERENCE, useSecondFactor, TOTP_MESSAGES } from "./totp";
package/dist/auth/totp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useState } from "react";
3
- import { useSignIn } from "@clerk/clerk-expo";
3
+ import { useSignIn } from "@clerk/expo/legacy";
4
4
  import { authErrorMessage, DEFAULT_STAGE_TIMEOUT_MS, isAuthTimeoutError, logAuthFailure, withAuthTimeout } from "./authErrors";
5
5
 
6
6
  /** Logs a timed-out stage. Other failures are not logged here. */
@@ -1,5 +1,5 @@
1
1
  // `@vvedantb/native-ui/auth`: `AuthProviders`, `SignInScreen`, `SignUpScreen`,
2
2
  // `GoogleSignInButton` and the auth frame. Not on the root entry: it imports
3
- // `@clerk/clerk-expo`, `convex`, `expo-auth-session`, `expo-web-browser` and
3
+ // `@clerk/expo`, `convex`, `expo-auth-session`, `expo-web-browser` and
4
4
  // `expo-router`, and Metro does not tree-shake.
5
5
  export * from "../auth";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/native-ui",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
6
6
  "type": "module",
@@ -190,7 +190,7 @@
190
190
  "sideEffects": false,
191
191
  "peerDependencies": {
192
192
  "expo-paste-input": ">=0.2.0",
193
- "@clerk/clerk-expo": "*",
193
+ "@clerk/expo": ">=4.0.0",
194
194
  "@expo/vector-icons": "*",
195
195
  "@json-render/core": ">=0.21.0",
196
196
  "@json-render/react-native": ">=0.21.0",
@@ -234,7 +234,7 @@
234
234
  "expo-paste-input": {
235
235
  "optional": true
236
236
  },
237
- "@clerk/clerk-expo": {
237
+ "@clerk/expo": {
238
238
  "optional": true
239
239
  },
240
240
  "@swmansion/react-native-bottom-sheet": {
@@ -308,7 +308,7 @@
308
308
  }
309
309
  },
310
310
  "devDependencies": {
311
- "@clerk/clerk-expo": "2.20.2",
311
+ "@clerk/expo": "4.17.2",
312
312
  "@types/react": "^19.1.0",
313
313
  "react": "^19.1.0",
314
314
  "typescript": "^5.9.0",
@@ -0,0 +1,294 @@
1
+ import { useRef, useState, type ReactNode } from "react";
2
+ import type { TextInput } from "react-native";
3
+ import { useUser } from "@clerk/expo";
4
+ import { useRouter, type Href } from "expo-router";
5
+ import { Button } from "../Button";
6
+ import { Input } from "../Input";
7
+ import { PasswordInput } from "../PasswordInput";
8
+ import { AuthScreen, FieldError } from "./AuthScreen";
9
+ import {
10
+ authErrorMessage,
11
+ DEFAULT_STAGE_TIMEOUT_MS,
12
+ logAuthFailure,
13
+ withAuthTimeout,
14
+ } from "./authErrors";
15
+
16
+ /** The messages the account screens can show. Generic: none names a provider. */
17
+ export const ACCOUNT_MESSAGES = {
18
+ changePasswordTitle: "Change password",
19
+ changePasswordSubtitle: "Enter your current password, then a new one.",
20
+ setPasswordTitle: "Set a password",
21
+ setPasswordSubtitle: "Your account has no password yet. Choose one.",
22
+ currentPasswordLabel: "Current password",
23
+ newPasswordLabel: "New password",
24
+ confirmPasswordLabel: "Confirm new password",
25
+ missingCurrentPassword: "Enter your current password",
26
+ missingNewPassword: "Enter a new password",
27
+ passwordMismatch: "The passwords do not match",
28
+ changePasswordFailed: "Could not change the password",
29
+ changePassword: "Change password",
30
+ setPassword: "Set password",
31
+ deleteTitle: "Delete account",
32
+ deleteSubtitle: "This deletes your account and its data. It cannot be undone.",
33
+ deleteConfirmMismatch: "Type the word exactly to confirm",
34
+ deleteFailed: "Could not delete the account",
35
+ deleteAccount: "Delete account",
36
+ cancel: "Cancel",
37
+ notReady: "Your account is not ready yet. Try again in a moment.",
38
+ } as const;
39
+
40
+ type AccountScreenBase = {
41
+ title?: string;
42
+ subtitle?: string;
43
+ /** Above the title. App brand chrome goes here. */
44
+ header?: ReactNode;
45
+ /** Below the form. */
46
+ footer?: ReactNode;
47
+ /** Shows a "Cancel" button that calls it. No button without it. */
48
+ onCancel?: () => void;
49
+ /** Time for the call, in milliseconds. A longer call fails with code `auth_timeout`. Default 20000. */
50
+ stageTimeoutMs?: number;
51
+ };
52
+
53
+ export type ChangePasswordScreenProps = AccountScreenBase & {
54
+ /** Rejects a shorter new password before sending it. Default: no check. */
55
+ minPasswordLength?: number;
56
+ /** Ends the user's other sessions after the change. Default `true`. */
57
+ signOutOfOtherSessions?: boolean;
58
+ /** Called after the password changed. Default: `router.back()`. */
59
+ onSuccess?: () => void;
60
+ /** Prefix for every `testID`. Default `"change-password"`. */
61
+ testIDPrefix?: string;
62
+ };
63
+
64
+ /**
65
+ * Changes the signed-in user's password with `user.updatePassword`: the
66
+ * current password, then the new one typed twice. An account with no password
67
+ * (Google only) gets no current-password field and the "Set a password" copy.
68
+ * Errors show under the fields. Render it under `ClerkProvider`, signed in.
69
+ */
70
+ export function ChangePasswordScreen({
71
+ title,
72
+ subtitle,
73
+ header,
74
+ footer,
75
+ onCancel,
76
+ stageTimeoutMs = DEFAULT_STAGE_TIMEOUT_MS,
77
+ minPasswordLength,
78
+ signOutOfOtherSessions = true,
79
+ onSuccess,
80
+ testIDPrefix = "change-password",
81
+ }: ChangePasswordScreenProps) {
82
+ const { isLoaded, user } = useUser();
83
+ const router = useRouter();
84
+ const [current, setCurrent] = useState("");
85
+ const [next, setNext] = useState("");
86
+ const [confirm, setConfirm] = useState("");
87
+ const [error, setError] = useState("");
88
+ const [submitting, setSubmitting] = useState(false);
89
+ const nextField = useRef<TextInput>(null);
90
+ const confirmField = useRef<TextInput>(null);
91
+ const id = (name: string) => `${testIDPrefix}-${name}`;
92
+ // Until the user loads, show the current-password field: most accounts have one.
93
+ const hasPassword = user ? user.passwordEnabled : true;
94
+
95
+ const submit = async () => {
96
+ if (submitting) return;
97
+ if (!isLoaded || !user) return setError(ACCOUNT_MESSAGES.notReady);
98
+ if (hasPassword && !current) return setError(ACCOUNT_MESSAGES.missingCurrentPassword);
99
+ if (!next) return setError(ACCOUNT_MESSAGES.missingNewPassword);
100
+ if (minPasswordLength && next.length < minPasswordLength) {
101
+ return setError(`Use at least ${minPasswordLength} characters for the password`);
102
+ }
103
+ if (next !== confirm) return setError(ACCOUNT_MESSAGES.passwordMismatch);
104
+ setSubmitting(true);
105
+ setError("");
106
+ // React Compiler memoises a component only when its `try` has no branch and
107
+ // no `finally`, so the branches sit before and after it.
108
+ const params = hasPassword
109
+ ? { newPassword: next, signOutOfOtherSessions, currentPassword: current }
110
+ : { newPassword: next, signOutOfOtherSessions };
111
+ let failed = false;
112
+ let failure: unknown;
113
+ try {
114
+ await withAuthTimeout(user.updatePassword(params), "update-password", stageTimeoutMs);
115
+ } catch (caught) {
116
+ failed = true;
117
+ failure = caught;
118
+ }
119
+ setSubmitting(false);
120
+ if (failed) {
121
+ logAuthFailure("update-password", failure);
122
+ return setError(authErrorMessage(failure, ACCOUNT_MESSAGES.changePasswordFailed));
123
+ }
124
+ setCurrent("");
125
+ setNext("");
126
+ setConfirm("");
127
+ if (onSuccess) onSuccess();
128
+ else router.back();
129
+ };
130
+
131
+ return (
132
+ <AuthScreen
133
+ testID={id("screen")}
134
+ title={title ?? (hasPassword ? ACCOUNT_MESSAGES.changePasswordTitle : ACCOUNT_MESSAGES.setPasswordTitle)}
135
+ subtitle={subtitle ?? (hasPassword ? ACCOUNT_MESSAGES.changePasswordSubtitle : ACCOUNT_MESSAGES.setPasswordSubtitle)}
136
+ header={header}
137
+ footer={footer}
138
+ >
139
+ {hasPassword ? (
140
+ <PasswordInput
141
+ testID={id("current")}
142
+ accessibilityLabel={ACCOUNT_MESSAGES.currentPasswordLabel}
143
+ autoCapitalize="none"
144
+ autoComplete="password"
145
+ textContentType="password"
146
+ returnKeyType="next"
147
+ submitBehavior="submit"
148
+ onSubmitEditing={() => nextField.current?.focus()}
149
+ value={current}
150
+ placeholder={ACCOUNT_MESSAGES.currentPasswordLabel}
151
+ onChangeText={setCurrent}
152
+ />
153
+ ) : null}
154
+ <PasswordInput
155
+ testID={id("new")}
156
+ ref={nextField}
157
+ accessibilityLabel={ACCOUNT_MESSAGES.newPasswordLabel}
158
+ autoCapitalize="none"
159
+ autoComplete="new-password"
160
+ textContentType="newPassword"
161
+ returnKeyType="next"
162
+ submitBehavior="submit"
163
+ onSubmitEditing={() => confirmField.current?.focus()}
164
+ value={next}
165
+ placeholder={ACCOUNT_MESSAGES.newPasswordLabel}
166
+ onChangeText={setNext}
167
+ />
168
+ <PasswordInput
169
+ testID={id("confirm")}
170
+ ref={confirmField}
171
+ accessibilityLabel={ACCOUNT_MESSAGES.confirmPasswordLabel}
172
+ autoCapitalize="none"
173
+ autoComplete="new-password"
174
+ textContentType="newPassword"
175
+ returnKeyType="go"
176
+ value={confirm}
177
+ placeholder={ACCOUNT_MESSAGES.confirmPasswordLabel}
178
+ onChangeText={setConfirm}
179
+ onSubmitEditing={() => void submit()}
180
+ />
181
+ <FieldError testID={id("error")} message={error} />
182
+ <Button testID={id("submit")} loading={submitting} onPress={() => void submit()}>
183
+ {hasPassword ? ACCOUNT_MESSAGES.changePassword : ACCOUNT_MESSAGES.setPassword}
184
+ </Button>
185
+ {onCancel ? (
186
+ <Button testID={id("cancel")} variant="ghost" disabled={submitting} onPress={onCancel}>
187
+ {ACCOUNT_MESSAGES.cancel}
188
+ </Button>
189
+ ) : null}
190
+ </AuthScreen>
191
+ );
192
+ }
193
+
194
+ export type DeleteAccountScreenProps = AccountScreenBase & {
195
+ /** The word the user types to confirm. Compared without case. Default `"DELETE"`. */
196
+ confirmWord?: string;
197
+ /** Called after the account is deleted, in place of `router.replace`. */
198
+ onDeleted?: () => void;
199
+ /** Where to go after the account is deleted. Default `"/"`. */
200
+ afterDeleteHref?: Href;
201
+ /** Prefix for every `testID`. Default `"delete-account"`. */
202
+ testIDPrefix?: string;
203
+ };
204
+
205
+ /**
206
+ * Deletes the signed-in user's account with `user.delete()`. The user types
207
+ * `confirmWord` first; the delete button stays off until it matches. Needs
208
+ * "Allow users to delete their accounts" turned on for the instance. Errors
209
+ * show under the field. Render it under `ClerkProvider`, signed in.
210
+ */
211
+ export function DeleteAccountScreen({
212
+ title,
213
+ subtitle,
214
+ header,
215
+ footer,
216
+ onCancel,
217
+ stageTimeoutMs = DEFAULT_STAGE_TIMEOUT_MS,
218
+ confirmWord = "DELETE",
219
+ onDeleted,
220
+ afterDeleteHref = "/",
221
+ testIDPrefix = "delete-account",
222
+ }: DeleteAccountScreenProps) {
223
+ const { isLoaded, user } = useUser();
224
+ const router = useRouter();
225
+ const [typed, setTyped] = useState("");
226
+ const [error, setError] = useState("");
227
+ const [submitting, setSubmitting] = useState(false);
228
+ const id = (name: string) => `${testIDPrefix}-${name}`;
229
+ const matches = typed.trim().toLowerCase() === confirmWord.toLowerCase();
230
+
231
+ const submit = async () => {
232
+ if (submitting) return;
233
+ if (!matches) return setError(ACCOUNT_MESSAGES.deleteConfirmMismatch);
234
+ if (!isLoaded || !user) return setError(ACCOUNT_MESSAGES.notReady);
235
+ setSubmitting(true);
236
+ setError("");
237
+ // No branch inside the `try`: see `ChangePasswordScreen`.
238
+ let failed = false;
239
+ let failure: unknown;
240
+ try {
241
+ await withAuthTimeout(user.delete(), "delete-account", stageTimeoutMs);
242
+ } catch (caught) {
243
+ failed = true;
244
+ failure = caught;
245
+ }
246
+ setSubmitting(false);
247
+ if (failed) {
248
+ logAuthFailure("delete-account", failure);
249
+ return setError(authErrorMessage(failure, ACCOUNT_MESSAGES.deleteFailed));
250
+ }
251
+ if (onDeleted) onDeleted();
252
+ else router.replace(afterDeleteHref);
253
+ };
254
+
255
+ const label = `Type ${confirmWord} to confirm`;
256
+ return (
257
+ <AuthScreen
258
+ testID={id("screen")}
259
+ title={title ?? ACCOUNT_MESSAGES.deleteTitle}
260
+ subtitle={subtitle ?? ACCOUNT_MESSAGES.deleteSubtitle}
261
+ header={header}
262
+ footer={footer}
263
+ >
264
+ <Input
265
+ testID={id("confirm")}
266
+ accessibilityLabel={label}
267
+ autoCapitalize="characters"
268
+ autoCorrect={false}
269
+ returnKeyType="done"
270
+ value={typed}
271
+ placeholder={label}
272
+ onChangeText={(text) => {
273
+ setTyped(text);
274
+ setError("");
275
+ }}
276
+ />
277
+ <FieldError testID={id("error")} message={error} />
278
+ <Button
279
+ testID={id("submit")}
280
+ variant="destructive"
281
+ loading={submitting}
282
+ disabled={!matches}
283
+ onPress={() => void submit()}
284
+ >
285
+ {ACCOUNT_MESSAGES.deleteAccount}
286
+ </Button>
287
+ {onCancel ? (
288
+ <Button testID={id("cancel")} variant="ghost" disabled={submitting} onPress={onCancel}>
289
+ {ACCOUNT_MESSAGES.cancel}
290
+ </Button>
291
+ ) : null}
292
+ </AuthScreen>
293
+ );
294
+ }
@@ -1,17 +1,20 @@
1
1
  import type { ReactNode } from "react";
2
- import { ClerkLoaded, ClerkProvider, useAuth as useClerkAuth, type TokenCache } from "@clerk/clerk-expo";
2
+ import { ClerkLoaded, ClerkProvider, useAuth as useClerkAuth, type TokenCache } from "@clerk/expo";
3
3
  import { ConvexProvider, type ConvexReactClient } from "convex/react";
4
4
  import { ConvexProviderWithClerk } from "convex/react-clerk";
5
5
 
6
6
  export type AuthProvidersProps = {
7
7
  children: ReactNode;
8
- /** The Clerk publishable key. The app reads it from its own config; this component does not check it. */
8
+ /**
9
+ * The Clerk publishable key. The app reads it from its own config; this component does not check it.
10
+ * `@clerk/expo` needs it: pass it unless `clerk` is `false`.
11
+ */
9
12
  publishableKey?: string;
10
- /** `tokenCache` from `@clerk/clerk-expo/token-cache`, so the session survives a restart. */
13
+ /** `tokenCache` from `@clerk/expo/token-cache`, so the session survives a restart. */
11
14
  tokenCache?: TokenCache;
12
15
  /** A Convex client. Without one, the children sit under Clerk only (vmem). */
13
16
  convex?: ConvexReactClient | null;
14
- /** `useAuth` from `@clerk/clerk-expo`, for `ConvexProviderWithClerk`. Default: the one this package imports. */
17
+ /** `useAuth` from `@clerk/expo`, for `ConvexProviderWithClerk`. Default: the one this package imports. */
15
18
  useAuth?: typeof useClerkAuth;
16
19
  /** Wrap the children in `ClerkLoaded`, so they wait for the session. Default `true`. */
17
20
  loaded?: boolean;
@@ -42,7 +45,7 @@ export function AuthProviders({
42
45
  }
43
46
  const inner = loaded ? <ClerkLoaded>{children}</ClerkLoaded> : children;
44
47
  return (
45
- <ClerkProvider publishableKey={publishableKey} tokenCache={tokenCache}>
48
+ <ClerkProvider publishableKey={publishableKey ?? ""} tokenCache={tokenCache}>
46
49
  {convex ? (
47
50
  <ConvexProviderWithClerk client={convex} useAuth={useAuth}>
48
51
  {inner}
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { Platform } from "react-native";
3
- import { useSSO } from "@clerk/clerk-expo";
3
+ import { useSSO } from "@clerk/expo";
4
4
  import * as AuthSession from "expo-auth-session";
5
5
  import * as WebBrowser from "expo-web-browser";
6
6
  import { useRouter, type Href } from "expo-router";
@@ -1,6 +1,6 @@
1
1
  import { useRef, useState, type ReactNode } from "react";
2
2
  import { Text, View, type TextInput } from "react-native";
3
- import { useSignIn, useSignUp } from "@clerk/clerk-expo";
3
+ import { useSignIn, useSignUp } from "@clerk/expo/legacy";
4
4
  import { useRouter, type Href } from "expo-router";
5
5
  import { Button } from "../Button";
6
6
  import { textStyle } from "../controlStyles";
@@ -1,4 +1,4 @@
1
- import { isClerkAPIResponseError } from "@clerk/clerk-expo";
1
+ import { isClerkAPIResponseError } from "@clerk/expo";
2
2
 
3
3
  /** Words that must not reach the user: the auth provider and stack names. */
4
4
  const PRODUCT_NAMES = /\b(clerk|convex)\b/gi;
package/src/auth/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Clerk + Convex providers and the shared sign-in and sign-up screens. On
2
- // `@vvedantb/native-ui/auth` only: they import `@clerk/clerk-expo`, `convex`,
2
+ // `@vvedantb/native-ui/auth` only: they import `@clerk/expo`, `convex`,
3
3
  // `expo-auth-session`, `expo-web-browser` and `expo-router`, and Metro does not
4
4
  // tree-shake.
5
5
  export { AuthProviders } from "./AuthProviders";
@@ -36,6 +36,8 @@ export type {
36
36
  SignInScreenProps,
37
37
  SignUpScreenProps,
38
38
  } from "./SignInScreen";
39
+ export { ChangePasswordScreen, DeleteAccountScreen, ACCOUNT_MESSAGES } from "./AccountScreens";
40
+ export type { ChangePasswordScreenProps, DeleteAccountScreenProps } from "./AccountScreens";
39
41
  export { SecondFactorScreen } from "./SecondFactorScreen";
40
42
  export type { SecondFactorScreenProps } from "./SecondFactorScreen";
41
43
  export {
package/src/auth/totp.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useState } from "react";
2
- import { useSignIn } from "@clerk/clerk-expo";
2
+ import { useSignIn } from "@clerk/expo/legacy";
3
3
  import {
4
4
  authErrorMessage,
5
5
  DEFAULT_STAGE_TIMEOUT_MS,
@@ -1,5 +1,5 @@
1
1
  // `@vvedantb/native-ui/auth`: `AuthProviders`, `SignInScreen`, `SignUpScreen`,
2
2
  // `GoogleSignInButton` and the auth frame. Not on the root entry: it imports
3
- // `@clerk/clerk-expo`, `convex`, `expo-auth-session`, `expo-web-browser` and
3
+ // `@clerk/expo`, `convex`, `expo-auth-session`, `expo-web-browser` and
4
4
  // `expo-router`, and Metro does not tree-shake.
5
5
  export * from "../auth";