@volr/react-ui 0.1.61 → 0.1.63
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/dist/index.cjs +139 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -25
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React10, { createContext, useContext, useState, useMemo, useEffect, useCallback, useRef, useId } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { useVolrContext, useInternalAuth, usePasskeyEnrollment, useMpcConnection, VolrProvider, useVolrLogin, useDepositListener, createGetNetworkInfo } from '@volr/react';
|
|
4
4
|
export { VolrProvider, useDepositListener, usePasskeyEnrollment, useVolr, useVolrLogin } from '@volr/react';
|
|
@@ -602,8 +602,8 @@ function getUserFriendlyError(error, t) {
|
|
|
602
602
|
function WalletConnectedView({ user, onClose, showHeader = true }) {
|
|
603
603
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
604
604
|
showHeader && onClose && /* @__PURE__ */ jsx(ModalHeader, { onClose }),
|
|
605
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
606
|
-
/* @__PURE__ */ jsx("p", { className: "volr:text-
|
|
605
|
+
/* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
606
|
+
/* @__PURE__ */ jsx("p", { className: "volr:text-xl volr:font-semibold volr:text-slate-900 volr:mb-5", children: "Wallet Connected" }),
|
|
607
607
|
user.evmAddress ? /* @__PURE__ */ jsxs("div", { className: "volr:bg-slate-50 volr:rounded-lg volr:p-5 volr:mb-6 volr:text-left", children: [
|
|
608
608
|
/* @__PURE__ */ jsxs("div", { className: "volr:mb-3", children: [
|
|
609
609
|
/* @__PURE__ */ jsx("div", { className: "volr:text-xs volr:text-slate-500 volr:mb-1 volr:font-medium", children: "Wallet Address" }),
|
|
@@ -846,7 +846,7 @@ var variantMap = {
|
|
|
846
846
|
ghost: { backgroundColor: "transparent", color: "#475569", border: "none" },
|
|
847
847
|
outline: { backgroundColor: "transparent", color: "#475569", border: "1px solid #e2e8f0" }
|
|
848
848
|
};
|
|
849
|
-
var Button =
|
|
849
|
+
var Button = React10.forwardRef(
|
|
850
850
|
({ variant = "primary", size = "md", fullWidth, className, style, disabled, children, ...props }, ref) => {
|
|
851
851
|
const { accentColor } = useVolrUI();
|
|
852
852
|
const sizeStyle = sizeMap[size];
|
|
@@ -1006,13 +1006,6 @@ function PasskeyEnrollView({
|
|
|
1006
1006
|
onError(error);
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
if (!user?.email) {
|
|
1010
|
-
const error = new Error("User email is required for passkey enrollment");
|
|
1011
|
-
setErrorMessage(getUserFriendlyError(error, t));
|
|
1012
|
-
if (onError) {
|
|
1013
|
-
onError(error);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
1009
|
}, [user, onError, t]);
|
|
1017
1010
|
useEffect(() => {
|
|
1018
1011
|
if (enrollmentError) {
|
|
@@ -1024,9 +1017,9 @@ function PasskeyEnrollView({
|
|
|
1024
1017
|
}
|
|
1025
1018
|
}, [enrollmentError, onError, t]);
|
|
1026
1019
|
const handleEnroll = async () => {
|
|
1027
|
-
if (!user?.id
|
|
1020
|
+
if (!user?.id) {
|
|
1028
1021
|
const error = new Error(
|
|
1029
|
-
"User ID
|
|
1022
|
+
"User ID is required for passkey enrollment"
|
|
1030
1023
|
);
|
|
1031
1024
|
setErrorMessage(getUserFriendlyError(error, t));
|
|
1032
1025
|
if (onError) {
|
|
@@ -1120,7 +1113,7 @@ function PasskeyEnrollView({
|
|
|
1120
1113
|
}
|
|
1121
1114
|
) });
|
|
1122
1115
|
}
|
|
1123
|
-
const content = /* @__PURE__ */ jsxs("div", {
|
|
1116
|
+
const content = /* @__PURE__ */ jsxs("div", { children: [
|
|
1124
1117
|
/* @__PURE__ */ jsx("p", { className: "volr:text-xl volr:font-semibold volr:text-slate-900 volr:mb-5", children: t("passkey.start") }),
|
|
1125
1118
|
!hasStarted ? /* @__PURE__ */ jsx(
|
|
1126
1119
|
PasskeyEnrollForm,
|
|
@@ -2233,12 +2226,8 @@ function SigninModal({ isOpen, onClose, onError }) {
|
|
|
2233
2226
|
}
|
|
2234
2227
|
setCurrentScreen("passkey-setup");
|
|
2235
2228
|
};
|
|
2236
|
-
const handleSiweSuccess = (
|
|
2237
|
-
|
|
2238
|
-
onClose();
|
|
2239
|
-
return;
|
|
2240
|
-
}
|
|
2241
|
-
setCurrentScreen("passkey-setup");
|
|
2229
|
+
const handleSiweSuccess = (_data) => {
|
|
2230
|
+
onClose();
|
|
2242
2231
|
};
|
|
2243
2232
|
const handlePasskeyComplete = () => {
|
|
2244
2233
|
onClose();
|
|
@@ -2369,6 +2358,36 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
2369
2358
|
if (!user) {
|
|
2370
2359
|
return /* @__PURE__ */ jsx(SigninModal, { isOpen, onClose, onError });
|
|
2371
2360
|
}
|
|
2361
|
+
if (!user.keyStorageType) {
|
|
2362
|
+
const handlePasskeyComplete = () => {
|
|
2363
|
+
onClose();
|
|
2364
|
+
};
|
|
2365
|
+
const handlePasskeyError = (error) => {
|
|
2366
|
+
if (onError) {
|
|
2367
|
+
onError(error);
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
const handleLogout2 = async () => {
|
|
2371
|
+
try {
|
|
2372
|
+
await logout();
|
|
2373
|
+
onClose();
|
|
2374
|
+
} catch (error) {
|
|
2375
|
+
if (onError) {
|
|
2376
|
+
onError(error instanceof Error ? error : new Error("Logout failed"));
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
return /* @__PURE__ */ jsx(Modal, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsx(
|
|
2381
|
+
PasskeyEnrollView,
|
|
2382
|
+
{
|
|
2383
|
+
wrapInModal: false,
|
|
2384
|
+
onComplete: handlePasskeyComplete,
|
|
2385
|
+
onError: handlePasskeyError,
|
|
2386
|
+
onLogout: handleLogout2,
|
|
2387
|
+
onClose
|
|
2388
|
+
}
|
|
2389
|
+
) });
|
|
2390
|
+
}
|
|
2372
2391
|
const handleLogout = async () => {
|
|
2373
2392
|
setIsLoggingOut(true);
|
|
2374
2393
|
try {
|
|
@@ -2469,7 +2488,7 @@ function AssetSelectView({
|
|
|
2469
2488
|
}) })
|
|
2470
2489
|
] });
|
|
2471
2490
|
}
|
|
2472
|
-
var TextLinkButton =
|
|
2491
|
+
var TextLinkButton = React10.forwardRef(({ showArrow = false, className, children, ...props }, ref) => {
|
|
2473
2492
|
return /* @__PURE__ */ jsxs(
|
|
2474
2493
|
"button",
|
|
2475
2494
|
{
|
|
@@ -3103,7 +3122,7 @@ var DepositModal = ({
|
|
|
3103
3122
|
body
|
|
3104
3123
|
] });
|
|
3105
3124
|
};
|
|
3106
|
-
var VolrUIContext =
|
|
3125
|
+
var VolrUIContext = React10.createContext(null);
|
|
3107
3126
|
var useVolrUI = () => {
|
|
3108
3127
|
const context = useContext(VolrUIContext);
|
|
3109
3128
|
if (!context) {
|
|
@@ -3350,19 +3369,29 @@ function OnboardingChecker({
|
|
|
3350
3369
|
}) {
|
|
3351
3370
|
const { user, provider, isLoading } = useVolrContext();
|
|
3352
3371
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
3372
|
+
const modalWasOpened = React10.useRef(false);
|
|
3373
|
+
useEffect(() => {
|
|
3374
|
+
if (isModalOpen) {
|
|
3375
|
+
modalWasOpened.current = true;
|
|
3376
|
+
}
|
|
3377
|
+
}, [isModalOpen]);
|
|
3353
3378
|
useEffect(() => {
|
|
3354
3379
|
if (isLoading) {
|
|
3355
3380
|
return;
|
|
3356
3381
|
}
|
|
3357
|
-
if (
|
|
3382
|
+
if (isModalOpen) {
|
|
3358
3383
|
onHideOnboarding();
|
|
3359
3384
|
return;
|
|
3360
3385
|
}
|
|
3361
|
-
if (
|
|
3386
|
+
if (modalWasOpened.current) {
|
|
3362
3387
|
onHideOnboarding();
|
|
3363
3388
|
return;
|
|
3364
3389
|
}
|
|
3365
|
-
if (
|
|
3390
|
+
if (user?.keyStorageType) {
|
|
3391
|
+
onHideOnboarding();
|
|
3392
|
+
return;
|
|
3393
|
+
}
|
|
3394
|
+
if (provider) {
|
|
3366
3395
|
onHideOnboarding();
|
|
3367
3396
|
return;
|
|
3368
3397
|
}
|