@loafmarkets/ui 0.1.381 → 0.1.383
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 +39 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -580,6 +580,13 @@ type LoginPopupProps = {
|
|
|
580
580
|
onFundWallet?: (params: FundWalletParams) => Promise<FundWalletResult> | void;
|
|
581
581
|
/** Optional view to show immediately when the popup opens. */
|
|
582
582
|
initialView?: LoginPopupView;
|
|
583
|
+
/**
|
|
584
|
+
* Gate-only: an access code supplied out-of-band (e.g. the `?code=` param on an
|
|
585
|
+
* invite link). Any form is accepted ("LOAF-M8TRP" / "loaf-m8trp" / "M8TRP").
|
|
586
|
+
* Pre-fills the code field and, when complete, auto-validates on open so the
|
|
587
|
+
* gate advances straight to sign-in.
|
|
588
|
+
*/
|
|
589
|
+
initialCode?: string;
|
|
583
590
|
/** Wallet address used for the receive funds view (bypasses Privy modal). */
|
|
584
591
|
walletAddress?: string | null;
|
|
585
592
|
/** Called when the user submits a referral code during onboarding. */
|
package/dist/index.d.ts
CHANGED
|
@@ -580,6 +580,13 @@ type LoginPopupProps = {
|
|
|
580
580
|
onFundWallet?: (params: FundWalletParams) => Promise<FundWalletResult> | void;
|
|
581
581
|
/** Optional view to show immediately when the popup opens. */
|
|
582
582
|
initialView?: LoginPopupView;
|
|
583
|
+
/**
|
|
584
|
+
* Gate-only: an access code supplied out-of-band (e.g. the `?code=` param on an
|
|
585
|
+
* invite link). Any form is accepted ("LOAF-M8TRP" / "loaf-m8trp" / "M8TRP").
|
|
586
|
+
* Pre-fills the code field and, when complete, auto-validates on open so the
|
|
587
|
+
* gate advances straight to sign-in.
|
|
588
|
+
*/
|
|
589
|
+
initialCode?: string;
|
|
583
590
|
/** Wallet address used for the receive funds view (bypasses Privy modal). */
|
|
584
591
|
walletAddress?: string | null;
|
|
585
592
|
/** Called when the user submits a referral code during onboarding. */
|
package/dist/index.js
CHANGED
|
@@ -6626,6 +6626,9 @@ PropertySubheader.displayName = "PropertySubheader";
|
|
|
6626
6626
|
var DEFAULT_LOGO_SRC = Loaf_logo_Banner_default;
|
|
6627
6627
|
var DEFAULT_LOGO_ALT = "Loaf";
|
|
6628
6628
|
var OTP_INPUT_LENGTH = 6;
|
|
6629
|
+
var CODE_PREFIX = "LOAF-";
|
|
6630
|
+
var CODE_SUFFIX_LEN = 5;
|
|
6631
|
+
var normalizeAccessCode = (raw) => CODE_PREFIX + raw.toUpperCase().replace(/^LOAF-?/, "").replace(/[^A-Z0-9]/g, "").slice(0, CODE_SUFFIX_LEN);
|
|
6629
6632
|
var friendlyError = (err, fallback) => {
|
|
6630
6633
|
const data = err?.response?.data;
|
|
6631
6634
|
if (typeof data?.error === "string" && data.error.trim()) return data.error;
|
|
@@ -6652,6 +6655,7 @@ var LoginPopup = ({
|
|
|
6652
6655
|
renderKycWidget,
|
|
6653
6656
|
onFundWallet,
|
|
6654
6657
|
initialView,
|
|
6658
|
+
initialCode,
|
|
6655
6659
|
kycStatus: kycStatusProp,
|
|
6656
6660
|
walletAddress,
|
|
6657
6661
|
onSubmitReferralCode,
|
|
@@ -6665,7 +6669,9 @@ var LoginPopup = ({
|
|
|
6665
6669
|
const [otp, setOtp] = React5.useState(Array(OTP_INPUT_LENGTH).fill(""));
|
|
6666
6670
|
const [error, setError] = React5.useState("");
|
|
6667
6671
|
const [copied, setCopied] = React5.useState(false);
|
|
6668
|
-
const [referralCode, setReferralCode] = React5.useState(
|
|
6672
|
+
const [referralCode, setReferralCode] = React5.useState(
|
|
6673
|
+
() => gate && initialCode ? normalizeAccessCode(initialCode) : ""
|
|
6674
|
+
);
|
|
6669
6675
|
const [referralLoading, setReferralLoading] = React5.useState(false);
|
|
6670
6676
|
const [referralError, setReferralError] = React5.useState("");
|
|
6671
6677
|
const [codeStatus, setCodeStatus] = React5.useState("idle");
|
|
@@ -6710,6 +6716,37 @@ var LoginPopup = ({
|
|
|
6710
6716
|
);
|
|
6711
6717
|
return false;
|
|
6712
6718
|
}, [gate, onSubmitReferralCode, onCheckAccess]);
|
|
6719
|
+
const runCodeValidation = React5__namespace.default.useCallback(async (fullCode) => {
|
|
6720
|
+
setCodeStatus("checking");
|
|
6721
|
+
setError("");
|
|
6722
|
+
try {
|
|
6723
|
+
const ok = onValidateCode ? await onValidateCode(fullCode) : true;
|
|
6724
|
+
if (!ok) {
|
|
6725
|
+
validatedCodeRef.current = null;
|
|
6726
|
+
setCodeStatus("invalid");
|
|
6727
|
+
return;
|
|
6728
|
+
}
|
|
6729
|
+
validatedCodeRef.current = fullCode;
|
|
6730
|
+
setCodeStatus("valid");
|
|
6731
|
+
if (isAuthenticated) {
|
|
6732
|
+
if (await finishGate()) setTimeout(() => onClose(), 500);
|
|
6733
|
+
return;
|
|
6734
|
+
}
|
|
6735
|
+
setIsSignUp(true);
|
|
6736
|
+
setSignInRevealed(true);
|
|
6737
|
+
} catch {
|
|
6738
|
+
validatedCodeRef.current = null;
|
|
6739
|
+
setCodeStatus("invalid");
|
|
6740
|
+
}
|
|
6741
|
+
}, [onValidateCode, isAuthenticated, finishGate, onClose]);
|
|
6742
|
+
const autoCodeTriedRef = React5__namespace.default.useRef(false);
|
|
6743
|
+
React5.useEffect(() => {
|
|
6744
|
+
if (autoCodeTriedRef.current || !gate || !initialCode) return;
|
|
6745
|
+
const full = normalizeAccessCode(initialCode);
|
|
6746
|
+
if (full.length !== CODE_PREFIX.length + CODE_SUFFIX_LEN) return;
|
|
6747
|
+
autoCodeTriedRef.current = true;
|
|
6748
|
+
void runCodeValidation(full);
|
|
6749
|
+
}, [gate, initialCode, runCodeValidation]);
|
|
6713
6750
|
React5.useEffect(() => {
|
|
6714
6751
|
if (typeof initialView === "string") {
|
|
6715
6752
|
setView(initialView);
|
|
@@ -7478,31 +7515,7 @@ var LoginPopup = ({
|
|
|
7478
7515
|
setReferralLoading(false);
|
|
7479
7516
|
}
|
|
7480
7517
|
};
|
|
7481
|
-
const CODE_PREFIX = "LOAF-";
|
|
7482
7518
|
const codeSuffix = referralCode.startsWith(CODE_PREFIX) ? referralCode.slice(CODE_PREFIX.length) : referralCode.replace(/^LOAF-?/i, "");
|
|
7483
|
-
const runCodeValidation = async (fullCode) => {
|
|
7484
|
-
setCodeStatus("checking");
|
|
7485
|
-
setError("");
|
|
7486
|
-
try {
|
|
7487
|
-
const ok = onValidateCode ? await onValidateCode(fullCode) : true;
|
|
7488
|
-
if (!ok) {
|
|
7489
|
-
validatedCodeRef.current = null;
|
|
7490
|
-
setCodeStatus("invalid");
|
|
7491
|
-
return;
|
|
7492
|
-
}
|
|
7493
|
-
validatedCodeRef.current = fullCode;
|
|
7494
|
-
setCodeStatus("valid");
|
|
7495
|
-
if (isAuthenticated) {
|
|
7496
|
-
if (await finishGate()) setTimeout(() => onClose(), 500);
|
|
7497
|
-
return;
|
|
7498
|
-
}
|
|
7499
|
-
setIsSignUp(true);
|
|
7500
|
-
setSignInRevealed(true);
|
|
7501
|
-
} catch {
|
|
7502
|
-
validatedCodeRef.current = null;
|
|
7503
|
-
setCodeStatus("invalid");
|
|
7504
|
-
}
|
|
7505
|
-
};
|
|
7506
7519
|
const setCodeSuffix = (suffix) => {
|
|
7507
7520
|
setReferralCode(CODE_PREFIX + suffix);
|
|
7508
7521
|
setReferralError("");
|
|
@@ -15865,7 +15878,7 @@ var Tab = styled10__default.default.button`
|
|
|
15865
15878
|
}
|
|
15866
15879
|
`;
|
|
15867
15880
|
var TabCount = styled10__default.default.span`
|
|
15868
|
-
color: #
|
|
15881
|
+
color: var(--color-accent, #E6C87E);
|
|
15869
15882
|
font-weight: 600;
|
|
15870
15883
|
margin-left: 2px;
|
|
15871
15884
|
`;
|