@volr/react-ui 0.1.60 → 0.1.62
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 +148 -112
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -27
- 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';
|
|
@@ -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];
|
|
@@ -2233,12 +2233,8 @@ function SigninModal({ isOpen, onClose, onError }) {
|
|
|
2233
2233
|
}
|
|
2234
2234
|
setCurrentScreen("passkey-setup");
|
|
2235
2235
|
};
|
|
2236
|
-
const handleSiweSuccess = (
|
|
2237
|
-
|
|
2238
|
-
onClose();
|
|
2239
|
-
return;
|
|
2240
|
-
}
|
|
2241
|
-
setCurrentScreen("passkey-setup");
|
|
2236
|
+
const handleSiweSuccess = (_data) => {
|
|
2237
|
+
onClose();
|
|
2242
2238
|
};
|
|
2243
2239
|
const handlePasskeyComplete = () => {
|
|
2244
2240
|
onClose();
|
|
@@ -2369,6 +2365,36 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
2369
2365
|
if (!user) {
|
|
2370
2366
|
return /* @__PURE__ */ jsx(SigninModal, { isOpen, onClose, onError });
|
|
2371
2367
|
}
|
|
2368
|
+
if (!user.keyStorageType) {
|
|
2369
|
+
const handlePasskeyComplete = () => {
|
|
2370
|
+
onClose();
|
|
2371
|
+
};
|
|
2372
|
+
const handlePasskeyError = (error) => {
|
|
2373
|
+
if (onError) {
|
|
2374
|
+
onError(error);
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
const handleLogout2 = async () => {
|
|
2378
|
+
try {
|
|
2379
|
+
await logout();
|
|
2380
|
+
onClose();
|
|
2381
|
+
} catch (error) {
|
|
2382
|
+
if (onError) {
|
|
2383
|
+
onError(error instanceof Error ? error : new Error("Logout failed"));
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
return /* @__PURE__ */ jsx(Modal, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsx(
|
|
2388
|
+
PasskeyEnrollView,
|
|
2389
|
+
{
|
|
2390
|
+
wrapInModal: false,
|
|
2391
|
+
onComplete: handlePasskeyComplete,
|
|
2392
|
+
onError: handlePasskeyError,
|
|
2393
|
+
onLogout: handleLogout2,
|
|
2394
|
+
onClose
|
|
2395
|
+
}
|
|
2396
|
+
) });
|
|
2397
|
+
}
|
|
2372
2398
|
const handleLogout = async () => {
|
|
2373
2399
|
setIsLoggingOut(true);
|
|
2374
2400
|
try {
|
|
@@ -2386,7 +2412,7 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
2386
2412
|
return /* @__PURE__ */ jsxs(Modal, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: [
|
|
2387
2413
|
/* @__PURE__ */ jsx(ModalHeader, { onClose }),
|
|
2388
2414
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2389
|
-
/* @__PURE__ */ jsx("p", { className: "volr:text-xl volr:font-semibold volr:text-slate-900 volr:mb-4
|
|
2415
|
+
/* @__PURE__ */ jsx("p", { className: "volr:text-xl volr:font-semibold volr:text-slate-900 volr:mb-4", children: t("account.title") }),
|
|
2390
2416
|
/* @__PURE__ */ jsxs("div", { className: "volr:bg-slate-50 volr:rounded-xl volr:p-4 volr:mb-4", children: [
|
|
2391
2417
|
user.evmAddress && /* @__PURE__ */ jsxs("div", { className: "volr:flex volr:items-center volr:justify-between volr:gap-3", children: [
|
|
2392
2418
|
/* @__PURE__ */ jsxs("div", { className: "volr:flex-1 volr:min-w-0", children: [
|
|
@@ -2425,8 +2451,8 @@ function AssetSelectView({
|
|
|
2425
2451
|
}) {
|
|
2426
2452
|
const { t } = useI18n();
|
|
2427
2453
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2428
|
-
/* @__PURE__ */ jsx("p", { className: "volr:text-xl volr:font-semibold volr:text-slate-900 volr:mb-1
|
|
2429
|
-
/* @__PURE__ */ jsx("p", { className: "volr:text-sm volr:text-slate-500 volr:mb-4
|
|
2454
|
+
/* @__PURE__ */ jsx("p", { className: "volr:text-xl volr:font-semibold volr:text-slate-900 volr:mb-1", children: t("deposit.selectTitle") }),
|
|
2455
|
+
/* @__PURE__ */ jsx("p", { className: "volr:text-sm volr:text-slate-500 volr:mb-4", children: "Supported token" }),
|
|
2430
2456
|
/* @__PURE__ */ jsx("div", { className: "volr:space-y-3", children: assets.map((a, idx) => {
|
|
2431
2457
|
const isNative = a.token === "native";
|
|
2432
2458
|
const tokenSymbol = isNative ? "ETH" : a.token.symbol;
|
|
@@ -2469,7 +2495,7 @@ function AssetSelectView({
|
|
|
2469
2495
|
}) })
|
|
2470
2496
|
] });
|
|
2471
2497
|
}
|
|
2472
|
-
var TextLinkButton =
|
|
2498
|
+
var TextLinkButton = React10.forwardRef(({ showArrow = false, className, children, ...props }, ref) => {
|
|
2473
2499
|
return /* @__PURE__ */ jsxs(
|
|
2474
2500
|
"button",
|
|
2475
2501
|
{
|
|
@@ -3103,7 +3129,7 @@ var DepositModal = ({
|
|
|
3103
3129
|
body
|
|
3104
3130
|
] });
|
|
3105
3131
|
};
|
|
3106
|
-
var VolrUIContext =
|
|
3132
|
+
var VolrUIContext = React10.createContext(null);
|
|
3107
3133
|
var useVolrUI = () => {
|
|
3108
3134
|
const context = useContext(VolrUIContext);
|
|
3109
3135
|
if (!context) {
|
|
@@ -3350,6 +3376,12 @@ function OnboardingChecker({
|
|
|
3350
3376
|
}) {
|
|
3351
3377
|
const { user, provider, isLoading } = useVolrContext();
|
|
3352
3378
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
3379
|
+
const modalWasOpened = React10.useRef(false);
|
|
3380
|
+
useEffect(() => {
|
|
3381
|
+
if (isModalOpen) {
|
|
3382
|
+
modalWasOpened.current = true;
|
|
3383
|
+
}
|
|
3384
|
+
}, [isModalOpen]);
|
|
3353
3385
|
useEffect(() => {
|
|
3354
3386
|
if (isLoading) {
|
|
3355
3387
|
return;
|
|
@@ -3358,22 +3390,26 @@ function OnboardingChecker({
|
|
|
3358
3390
|
onHideOnboarding();
|
|
3359
3391
|
return;
|
|
3360
3392
|
}
|
|
3361
|
-
if (
|
|
3362
|
-
|
|
3363
|
-
|
|
3393
|
+
if (modalWasOpened.current) {
|
|
3394
|
+
onHideOnboarding();
|
|
3395
|
+
return;
|
|
3396
|
+
}
|
|
3397
|
+
if (user?.keyStorageType) {
|
|
3398
|
+
onHideOnboarding();
|
|
3399
|
+
return;
|
|
3400
|
+
}
|
|
3401
|
+
if (provider) {
|
|
3402
|
+
onHideOnboarding();
|
|
3403
|
+
return;
|
|
3404
|
+
}
|
|
3405
|
+
if (user && enforceSelection) {
|
|
3406
|
+
if (!keyStorageType) {
|
|
3407
|
+
console.error(
|
|
3408
|
+
"keyStorageType must be specified in VolrUIProvider props."
|
|
3409
|
+
);
|
|
3364
3410
|
return;
|
|
3365
3411
|
}
|
|
3366
|
-
|
|
3367
|
-
if (!keyStorageType) {
|
|
3368
|
-
console.error(
|
|
3369
|
-
"keyStorageType must be specified in VolrUIProvider props."
|
|
3370
|
-
);
|
|
3371
|
-
return;
|
|
3372
|
-
}
|
|
3373
|
-
onShowOnboarding();
|
|
3374
|
-
}
|
|
3375
|
-
} else if (provider) {
|
|
3376
|
-
onHideOnboarding();
|
|
3412
|
+
onShowOnboarding();
|
|
3377
3413
|
}
|
|
3378
3414
|
}, [
|
|
3379
3415
|
user,
|