@loafmarkets/ui 0.1.380 → 0.1.382
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.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +41 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6601,6 +6601,9 @@ PropertySubheader.displayName = "PropertySubheader";
|
|
|
6601
6601
|
var DEFAULT_LOGO_SRC = Loaf_logo_Banner_default;
|
|
6602
6602
|
var DEFAULT_LOGO_ALT = "Loaf";
|
|
6603
6603
|
var OTP_INPUT_LENGTH = 6;
|
|
6604
|
+
var CODE_PREFIX = "LOAF-";
|
|
6605
|
+
var CODE_SUFFIX_LEN = 5;
|
|
6606
|
+
var normalizeAccessCode = (raw) => CODE_PREFIX + raw.toUpperCase().replace(/^LOAF-?/, "").replace(/[^A-Z0-9]/g, "").slice(0, CODE_SUFFIX_LEN);
|
|
6604
6607
|
var friendlyError = (err, fallback) => {
|
|
6605
6608
|
const data = err?.response?.data;
|
|
6606
6609
|
if (typeof data?.error === "string" && data.error.trim()) return data.error;
|
|
@@ -6627,6 +6630,7 @@ var LoginPopup = ({
|
|
|
6627
6630
|
renderKycWidget,
|
|
6628
6631
|
onFundWallet,
|
|
6629
6632
|
initialView,
|
|
6633
|
+
initialCode,
|
|
6630
6634
|
kycStatus: kycStatusProp,
|
|
6631
6635
|
walletAddress,
|
|
6632
6636
|
onSubmitReferralCode,
|
|
@@ -6640,7 +6644,9 @@ var LoginPopup = ({
|
|
|
6640
6644
|
const [otp, setOtp] = useState(Array(OTP_INPUT_LENGTH).fill(""));
|
|
6641
6645
|
const [error, setError] = useState("");
|
|
6642
6646
|
const [copied, setCopied] = useState(false);
|
|
6643
|
-
const [referralCode, setReferralCode] = useState(
|
|
6647
|
+
const [referralCode, setReferralCode] = useState(
|
|
6648
|
+
() => gate && initialCode ? normalizeAccessCode(initialCode) : ""
|
|
6649
|
+
);
|
|
6644
6650
|
const [referralLoading, setReferralLoading] = useState(false);
|
|
6645
6651
|
const [referralError, setReferralError] = useState("");
|
|
6646
6652
|
const [codeStatus, setCodeStatus] = useState("idle");
|
|
@@ -6649,20 +6655,6 @@ var LoginPopup = ({
|
|
|
6649
6655
|
const [signInMode, setSignInMode] = useState(false);
|
|
6650
6656
|
const [loading, setLoading] = useState(false);
|
|
6651
6657
|
const [isSignUp, setIsSignUp] = useState(false);
|
|
6652
|
-
const [gateViewportH, setGateViewportH] = useState(void 0);
|
|
6653
|
-
useEffect(() => {
|
|
6654
|
-
if (!gate || typeof window === "undefined") return;
|
|
6655
|
-
const vv = window.visualViewport;
|
|
6656
|
-
if (!vv) return;
|
|
6657
|
-
const sync = () => setGateViewportH(vv.height);
|
|
6658
|
-
sync();
|
|
6659
|
-
vv.addEventListener("resize", sync);
|
|
6660
|
-
vv.addEventListener("scroll", sync);
|
|
6661
|
-
return () => {
|
|
6662
|
-
vv.removeEventListener("resize", sync);
|
|
6663
|
-
vv.removeEventListener("scroll", sync);
|
|
6664
|
-
};
|
|
6665
|
-
}, [gate]);
|
|
6666
6658
|
const [fundingAmount] = useState("");
|
|
6667
6659
|
const [kycLoading, setKycLoading] = useState(false);
|
|
6668
6660
|
const [showKycWidget, setShowKycWidget] = useState(false);
|
|
@@ -6699,6 +6691,37 @@ var LoginPopup = ({
|
|
|
6699
6691
|
);
|
|
6700
6692
|
return false;
|
|
6701
6693
|
}, [gate, onSubmitReferralCode, onCheckAccess]);
|
|
6694
|
+
const runCodeValidation = React5__default.useCallback(async (fullCode) => {
|
|
6695
|
+
setCodeStatus("checking");
|
|
6696
|
+
setError("");
|
|
6697
|
+
try {
|
|
6698
|
+
const ok = onValidateCode ? await onValidateCode(fullCode) : true;
|
|
6699
|
+
if (!ok) {
|
|
6700
|
+
validatedCodeRef.current = null;
|
|
6701
|
+
setCodeStatus("invalid");
|
|
6702
|
+
return;
|
|
6703
|
+
}
|
|
6704
|
+
validatedCodeRef.current = fullCode;
|
|
6705
|
+
setCodeStatus("valid");
|
|
6706
|
+
if (isAuthenticated) {
|
|
6707
|
+
if (await finishGate()) setTimeout(() => onClose(), 500);
|
|
6708
|
+
return;
|
|
6709
|
+
}
|
|
6710
|
+
setIsSignUp(true);
|
|
6711
|
+
setSignInRevealed(true);
|
|
6712
|
+
} catch {
|
|
6713
|
+
validatedCodeRef.current = null;
|
|
6714
|
+
setCodeStatus("invalid");
|
|
6715
|
+
}
|
|
6716
|
+
}, [onValidateCode, isAuthenticated, finishGate, onClose]);
|
|
6717
|
+
const autoCodeTriedRef = React5__default.useRef(false);
|
|
6718
|
+
useEffect(() => {
|
|
6719
|
+
if (autoCodeTriedRef.current || !gate || !initialCode) return;
|
|
6720
|
+
const full = normalizeAccessCode(initialCode);
|
|
6721
|
+
if (full.length !== CODE_PREFIX.length + CODE_SUFFIX_LEN) return;
|
|
6722
|
+
autoCodeTriedRef.current = true;
|
|
6723
|
+
void runCodeValidation(full);
|
|
6724
|
+
}, [gate, initialCode, runCodeValidation]);
|
|
6702
6725
|
useEffect(() => {
|
|
6703
6726
|
if (typeof initialView === "string") {
|
|
6704
6727
|
setView(initialView);
|
|
@@ -7184,7 +7207,7 @@ var LoginPopup = ({
|
|
|
7184
7207
|
}
|
|
7185
7208
|
if (view === "otp") {
|
|
7186
7209
|
if (gate) {
|
|
7187
|
-
return /* @__PURE__ */ jsxs(GateShell, {
|
|
7210
|
+
return /* @__PURE__ */ jsxs(GateShell, { children: [
|
|
7188
7211
|
/* @__PURE__ */ jsx(GateTint, { $reveal: otpStatus === "valid" ? 3 : 2 }),
|
|
7189
7212
|
/* @__PURE__ */ jsxs(GateForm, { children: [
|
|
7190
7213
|
/* @__PURE__ */ jsxs(GateBrand, { children: [
|
|
@@ -7467,31 +7490,7 @@ var LoginPopup = ({
|
|
|
7467
7490
|
setReferralLoading(false);
|
|
7468
7491
|
}
|
|
7469
7492
|
};
|
|
7470
|
-
const CODE_PREFIX = "LOAF-";
|
|
7471
7493
|
const codeSuffix = referralCode.startsWith(CODE_PREFIX) ? referralCode.slice(CODE_PREFIX.length) : referralCode.replace(/^LOAF-?/i, "");
|
|
7472
|
-
const runCodeValidation = async (fullCode) => {
|
|
7473
|
-
setCodeStatus("checking");
|
|
7474
|
-
setError("");
|
|
7475
|
-
try {
|
|
7476
|
-
const ok = onValidateCode ? await onValidateCode(fullCode) : true;
|
|
7477
|
-
if (!ok) {
|
|
7478
|
-
validatedCodeRef.current = null;
|
|
7479
|
-
setCodeStatus("invalid");
|
|
7480
|
-
return;
|
|
7481
|
-
}
|
|
7482
|
-
validatedCodeRef.current = fullCode;
|
|
7483
|
-
setCodeStatus("valid");
|
|
7484
|
-
if (isAuthenticated) {
|
|
7485
|
-
if (await finishGate()) setTimeout(() => onClose(), 500);
|
|
7486
|
-
return;
|
|
7487
|
-
}
|
|
7488
|
-
setIsSignUp(true);
|
|
7489
|
-
setSignInRevealed(true);
|
|
7490
|
-
} catch {
|
|
7491
|
-
validatedCodeRef.current = null;
|
|
7492
|
-
setCodeStatus("invalid");
|
|
7493
|
-
}
|
|
7494
|
-
};
|
|
7495
7494
|
const setCodeSuffix = (suffix) => {
|
|
7496
7495
|
setReferralCode(CODE_PREFIX + suffix);
|
|
7497
7496
|
setReferralError("");
|
|
@@ -7565,7 +7564,7 @@ var LoginPopup = ({
|
|
|
7565
7564
|
if (gate) {
|
|
7566
7565
|
const codeAccepted = codeStatus === "valid";
|
|
7567
7566
|
const showSignIn = signInMode || signInRevealed;
|
|
7568
|
-
return /* @__PURE__ */ jsxs(GateShell, {
|
|
7567
|
+
return /* @__PURE__ */ jsxs(GateShell, { children: [
|
|
7569
7568
|
/* @__PURE__ */ jsx(GateTint, { $reveal: showSignIn ? 1 : 0 }),
|
|
7570
7569
|
/* @__PURE__ */ jsxs(GateForm, { children: [
|
|
7571
7570
|
/* @__PURE__ */ jsxs(GateBrand, { children: [
|
|
@@ -8192,21 +8191,12 @@ var GateForm = styled10.div`
|
|
|
8192
8191
|
`;
|
|
8193
8192
|
var GateShell = styled10.div`
|
|
8194
8193
|
position: fixed;
|
|
8195
|
-
|
|
8196
|
-
left: 0;
|
|
8197
|
-
right: 0;
|
|
8198
|
-
/* Visual-viewport height when available (see gateViewportH) so the gate ends
|
|
8199
|
-
at the keyboard top with nothing hidden below it to scroll to; 100% else. */
|
|
8200
|
-
height: ${(props) => props.$h ? `${props.$h}px` : "100%"};
|
|
8194
|
+
inset: 0;
|
|
8201
8195
|
display: flex;
|
|
8202
8196
|
align-items: center;
|
|
8203
8197
|
justify-content: center;
|
|
8204
8198
|
z-index: 10000;
|
|
8205
8199
|
background-color: rgba(10, 10, 12, 0.66);
|
|
8206
|
-
/* If content can't fit the visible area (very short screen + keyboard), scroll
|
|
8207
|
-
WITHIN the gate only — never chain to the platform underneath. */
|
|
8208
|
-
overflow-y: auto;
|
|
8209
|
-
overscroll-behavior: contain;
|
|
8210
8200
|
`;
|
|
8211
8201
|
var GateTint = styled10.div`
|
|
8212
8202
|
position: absolute;
|