@urbackend/react 0.1.1 → 0.2.1
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 +71 -2
- package/dist/index.d.ts +71 -2
- package/dist/index.js +246 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +247 -82
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
- package/src/components/Toast.tsx +0 -91
- package/src/components/UrAuth.tsx +0 -405
- package/src/components/UrUserButton.tsx +0 -207
- package/src/components.tsx +0 -83
- package/src/context.tsx +0 -140
- package/src/hooks.ts +0 -163
- package/src/index.ts +0 -13
- package/tests/UrAuth.test.tsx +0 -90
- package/tests/context.test.tsx +0 -113
- package/tests/setupTests.ts +0 -1
- package/tsconfig.json +0 -24
- package/tsup.config.ts +0 -11
- package/vitest.config.ts +0 -9
package/dist/index.mjs
CHANGED
|
@@ -294,7 +294,7 @@ var GuestRoute = ({
|
|
|
294
294
|
};
|
|
295
295
|
|
|
296
296
|
// src/components/UrAuth.tsx
|
|
297
|
-
import {
|
|
297
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
298
298
|
|
|
299
299
|
// src/components/Toast.tsx
|
|
300
300
|
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
@@ -374,9 +374,93 @@ var Toast = ({ message, type, onClose, isDark = false }) => {
|
|
|
374
374
|
|
|
375
375
|
// src/components/UrAuth.tsx
|
|
376
376
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
377
|
+
var defaultLabels = {
|
|
378
|
+
loginTab: "Login",
|
|
379
|
+
signupTab: "Sign Up",
|
|
380
|
+
loginTitle: "Welcome back",
|
|
381
|
+
signupTitle: "Create your account",
|
|
382
|
+
forgotTitle: "Reset Password",
|
|
383
|
+
resetTitle: "Enter Reset Code",
|
|
384
|
+
loginButton: "Log In",
|
|
385
|
+
signupButton: "Create Account",
|
|
386
|
+
forgotButton: "Send Reset Code",
|
|
387
|
+
resetButton: "Reset Password",
|
|
388
|
+
emailLabel: "Email address",
|
|
389
|
+
emailPlaceholder: "Enter your email address",
|
|
390
|
+
passwordLabel: "Password",
|
|
391
|
+
passwordPlaceholder: "Enter your password",
|
|
392
|
+
nameLabel: "Full Name",
|
|
393
|
+
namePlaceholder: "Enter your name",
|
|
394
|
+
otpLabel: "6-digit OTP Code",
|
|
395
|
+
otpPlaceholder: "Enter reset code",
|
|
396
|
+
forgotPasswordLink: "Forgot password?",
|
|
397
|
+
socialDivider: "OR",
|
|
398
|
+
googleButton: "Continue with Google",
|
|
399
|
+
githubButton: "Continue with GitHub",
|
|
400
|
+
footerSigninPrompt: "Don't have an account yet?",
|
|
401
|
+
footerSignupPrompt: "Already have an account?",
|
|
402
|
+
footerForgotPrompt: "Remember your password?",
|
|
403
|
+
noAuthMethods: "No authentication methods are enabled for this screen.",
|
|
404
|
+
forgotSubtitle: "Welcome back",
|
|
405
|
+
resetSubtitle: "Enter the code sent to {email}"
|
|
406
|
+
};
|
|
407
|
+
var defaultThemeColors = {
|
|
408
|
+
light: {
|
|
409
|
+
background: "#ffffff",
|
|
410
|
+
surface: "#ffffff",
|
|
411
|
+
text: "#0f172a",
|
|
412
|
+
textMuted: "#64748b",
|
|
413
|
+
border: "#e2e8f0",
|
|
414
|
+
inputBackground: "#ffffff",
|
|
415
|
+
primary: "#111111",
|
|
416
|
+
primaryText: "#ffffff",
|
|
417
|
+
footerBackground: "#f8fafc",
|
|
418
|
+
dividerText: "#94a3b8",
|
|
419
|
+
socialButtonBackground: "#ffffff"
|
|
420
|
+
},
|
|
421
|
+
dark: {
|
|
422
|
+
background: "#1a1a1a",
|
|
423
|
+
surface: "#1a1a1a",
|
|
424
|
+
text: "#ffffff",
|
|
425
|
+
textMuted: "#a1a1aa",
|
|
426
|
+
border: "#333333",
|
|
427
|
+
inputBackground: "#2a2a2a",
|
|
428
|
+
primary: "#ffffff",
|
|
429
|
+
primaryText: "#111111",
|
|
430
|
+
footerBackground: "#222222",
|
|
431
|
+
dividerText: "#94a3b8",
|
|
432
|
+
socialButtonBackground: "#2a2a2a"
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
var adjustColor = (color, percent) => {
|
|
436
|
+
try {
|
|
437
|
+
if (color.startsWith("#")) {
|
|
438
|
+
let hex = color.replace("#", "");
|
|
439
|
+
if (hex.length === 3) {
|
|
440
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
441
|
+
}
|
|
442
|
+
let r = parseInt(hex.substring(0, 2), 16);
|
|
443
|
+
let g = parseInt(hex.substring(2, 4), 16);
|
|
444
|
+
let b = parseInt(hex.substring(4, 6), 16);
|
|
445
|
+
r = Math.min(255, Math.max(0, r + percent));
|
|
446
|
+
g = Math.min(255, Math.max(0, g + percent));
|
|
447
|
+
b = Math.min(255, Math.max(0, b + percent));
|
|
448
|
+
const rr = r.toString(16).padStart(2, "0");
|
|
449
|
+
const gg = g.toString(16).padStart(2, "0");
|
|
450
|
+
const bb = b.toString(16).padStart(2, "0");
|
|
451
|
+
return `#${rr}${gg}${bb}`;
|
|
452
|
+
}
|
|
453
|
+
} catch (e) {
|
|
454
|
+
}
|
|
455
|
+
return color;
|
|
456
|
+
};
|
|
377
457
|
var UrAuth = ({
|
|
378
458
|
providers = ["google", "github"],
|
|
459
|
+
enableEmailPassword = true,
|
|
379
460
|
theme = "light",
|
|
461
|
+
colors,
|
|
462
|
+
branding,
|
|
463
|
+
labels,
|
|
380
464
|
onSuccess
|
|
381
465
|
}) => {
|
|
382
466
|
const { login, signUp, socialLogin, requestPasswordReset, resetPassword, isLoading, error, clearError } = useAuth();
|
|
@@ -386,11 +470,49 @@ var UrAuth = ({
|
|
|
386
470
|
const [otp, setOtp] = useState3("");
|
|
387
471
|
const [name, setName] = useState3("");
|
|
388
472
|
const [toast, setToast] = useState3(null);
|
|
473
|
+
const text = {
|
|
474
|
+
...defaultLabels,
|
|
475
|
+
...labels,
|
|
476
|
+
loginTab: labels?.signInTab ?? labels?.loginTab ?? defaultLabels.loginTab,
|
|
477
|
+
loginTitle: labels?.signInTitle ?? labels?.loginTitle ?? defaultLabels.loginTitle,
|
|
478
|
+
loginButton: labels?.signInButton ?? labels?.loginButton ?? defaultLabels.loginButton,
|
|
479
|
+
signupTab: labels?.signUpTab ?? labels?.signupTab ?? defaultLabels.signupTab,
|
|
480
|
+
signupTitle: labels?.signUpTitle ?? labels?.signupTitle ?? defaultLabels.signupTitle,
|
|
481
|
+
signupButton: labels?.signUpButton ?? labels?.signupButton ?? defaultLabels.signupButton
|
|
482
|
+
};
|
|
483
|
+
const themeColors = { ...defaultThemeColors[theme], ...colors };
|
|
484
|
+
const primaryColor = branding?.primaryColor || colors?.primaryColor || themeColors.primary;
|
|
485
|
+
const secondStopColor = adjustColor(primaryColor, -15);
|
|
486
|
+
let isGoogleEnabled = true;
|
|
487
|
+
let isGithubEnabled = true;
|
|
488
|
+
let isEmailPasswordEnabled = enableEmailPassword;
|
|
489
|
+
if (providers) {
|
|
490
|
+
if (Array.isArray(providers)) {
|
|
491
|
+
isGoogleEnabled = providers.includes("google");
|
|
492
|
+
isGithubEnabled = providers.includes("github");
|
|
493
|
+
} else if (typeof providers === "object") {
|
|
494
|
+
isGoogleEnabled = !!providers.google;
|
|
495
|
+
isGithubEnabled = !!providers.github;
|
|
496
|
+
isEmailPasswordEnabled = providers.emailPassword !== void 0 ? providers.emailPassword : enableEmailPassword;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const hasPasswordAuth = isEmailPasswordEnabled;
|
|
500
|
+
const hasSocialAuth = isGoogleEnabled || isGithubEnabled;
|
|
501
|
+
const brandName = branding?.brandName || branding?.appName || branding?.title || "urBackend";
|
|
502
|
+
const headerTitle = branding?.title || brandName;
|
|
503
|
+
const brandingLogo = branding?.logo ?? branding?.logoUrl;
|
|
504
|
+
const headerSubtitle = branding?.subtitle || (mode === "signin" ? text.loginTitle : mode === "signup" ? text.signupTitle : mode === "forgot" ? text.forgotTitle : text.resetTitle);
|
|
505
|
+
const showSwitcher = hasPasswordAuth;
|
|
389
506
|
useEffect4(() => {
|
|
390
507
|
if (error) {
|
|
391
508
|
setToast({ message: error, type: "error" });
|
|
392
509
|
}
|
|
393
510
|
}, [error]);
|
|
511
|
+
useEffect4(() => {
|
|
512
|
+
if (!hasPasswordAuth && mode !== "signin") {
|
|
513
|
+
setMode("signin");
|
|
514
|
+
}
|
|
515
|
+
}, [hasPasswordAuth, mode]);
|
|
394
516
|
const handleSubmit = async (e) => {
|
|
395
517
|
e.preventDefault();
|
|
396
518
|
try {
|
|
@@ -417,28 +539,58 @@ var UrAuth = ({
|
|
|
417
539
|
} catch (err) {
|
|
418
540
|
}
|
|
419
541
|
};
|
|
420
|
-
const isDark = theme === "dark";
|
|
421
|
-
const bg = isDark ? "#1a1a1a" : "#ffffff";
|
|
422
|
-
const text = isDark ? "#ffffff" : "#0f172a";
|
|
423
|
-
const textMuted = isDark ? "#a1a1aa" : "#64748b";
|
|
424
|
-
const border = isDark ? "#333" : "#e2e8f0";
|
|
425
|
-
const inputBg = isDark ? "#2a2a2a" : "#ffffff";
|
|
426
542
|
const styles = {
|
|
427
543
|
wrapper: {
|
|
428
544
|
width: "100%",
|
|
429
545
|
maxWidth: "420px",
|
|
430
546
|
margin: "0 auto",
|
|
431
547
|
borderRadius: "0",
|
|
432
|
-
background:
|
|
433
|
-
boxShadow:
|
|
434
|
-
border: `1px solid ${border}`,
|
|
548
|
+
background: themeColors.background,
|
|
549
|
+
boxShadow: theme === "dark" ? "0 20px 40px rgba(0,0,0,0.5)" : "0 20px 40px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.05)",
|
|
550
|
+
border: `1px solid ${themeColors.border}`,
|
|
435
551
|
overflow: "hidden",
|
|
436
552
|
fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
437
|
-
color: text
|
|
553
|
+
color: themeColors.text
|
|
438
554
|
},
|
|
439
555
|
body: {
|
|
440
556
|
padding: "32px 32px 24px 32px"
|
|
441
557
|
},
|
|
558
|
+
header: {
|
|
559
|
+
textAlign: "center",
|
|
560
|
+
marginBottom: "28px"
|
|
561
|
+
},
|
|
562
|
+
brandRow: {
|
|
563
|
+
display: "flex",
|
|
564
|
+
justifyContent: "center",
|
|
565
|
+
alignItems: "center",
|
|
566
|
+
gap: "12px",
|
|
567
|
+
marginBottom: "10px"
|
|
568
|
+
},
|
|
569
|
+
brandLogo: {
|
|
570
|
+
width: "44px",
|
|
571
|
+
height: "44px",
|
|
572
|
+
borderRadius: "12px",
|
|
573
|
+
display: "inline-flex",
|
|
574
|
+
alignItems: "center",
|
|
575
|
+
justifyContent: "center",
|
|
576
|
+
background: theme === "dark" ? "#2a2a2a" : "#f1f5f9",
|
|
577
|
+
color: themeColors.text,
|
|
578
|
+
overflow: "hidden"
|
|
579
|
+
},
|
|
580
|
+
brandTitle: {
|
|
581
|
+
margin: 0,
|
|
582
|
+
fontSize: "26px",
|
|
583
|
+
lineHeight: 1.1,
|
|
584
|
+
fontWeight: 800,
|
|
585
|
+
color: themeColors.text
|
|
586
|
+
},
|
|
587
|
+
brandSubtitle: {
|
|
588
|
+
margin: "0 auto",
|
|
589
|
+
maxWidth: "320px",
|
|
590
|
+
fontSize: "14px",
|
|
591
|
+
lineHeight: 1.5,
|
|
592
|
+
color: themeColors.textMuted
|
|
593
|
+
},
|
|
442
594
|
switcherContainer: {
|
|
443
595
|
display: "flex",
|
|
444
596
|
alignItems: "center",
|
|
@@ -447,7 +599,7 @@ var UrAuth = ({
|
|
|
447
599
|
},
|
|
448
600
|
switcher: {
|
|
449
601
|
display: "inline-flex",
|
|
450
|
-
background:
|
|
602
|
+
background: theme === "dark" ? "#2a2a2a" : "#f1f5f9",
|
|
451
603
|
padding: "4px",
|
|
452
604
|
borderRadius: "0"
|
|
453
605
|
},
|
|
@@ -460,9 +612,9 @@ var UrAuth = ({
|
|
|
460
612
|
fontSize: "13px",
|
|
461
613
|
fontWeight: 600,
|
|
462
614
|
cursor: "pointer",
|
|
463
|
-
color: active ? text : textMuted,
|
|
464
|
-
background: active ?
|
|
465
|
-
boxShadow: active ?
|
|
615
|
+
color: active ? themeColors.text : themeColors.textMuted,
|
|
616
|
+
background: active ? theme === "dark" ? "#444444" : "#ffffff" : "transparent",
|
|
617
|
+
boxShadow: active ? theme === "dark" ? "0 2px 4px rgba(0,0,0,0.2)" : "0 2px 8px rgba(0,0,0,0.05)" : "none",
|
|
466
618
|
border: "none",
|
|
467
619
|
transition: "all 0.2s ease"
|
|
468
620
|
}),
|
|
@@ -478,12 +630,12 @@ var UrAuth = ({
|
|
|
478
630
|
label: {
|
|
479
631
|
fontSize: "13px",
|
|
480
632
|
fontWeight: 600,
|
|
481
|
-
color:
|
|
633
|
+
color: theme === "dark" ? "#dddddd" : "#334155"
|
|
482
634
|
},
|
|
483
635
|
forgotLink: {
|
|
484
636
|
fontSize: "12px",
|
|
485
637
|
fontWeight: 600,
|
|
486
|
-
color: text,
|
|
638
|
+
color: themeColors.text,
|
|
487
639
|
cursor: "pointer",
|
|
488
640
|
textDecoration: "none",
|
|
489
641
|
background: "none",
|
|
@@ -494,9 +646,9 @@ var UrAuth = ({
|
|
|
494
646
|
width: "100%",
|
|
495
647
|
padding: "12px 16px",
|
|
496
648
|
borderRadius: "0",
|
|
497
|
-
border: `1px solid ${border}`,
|
|
498
|
-
background:
|
|
499
|
-
color: text,
|
|
649
|
+
border: `1px solid ${themeColors.border}`,
|
|
650
|
+
background: themeColors.inputBackground,
|
|
651
|
+
color: themeColors.text,
|
|
500
652
|
fontSize: "14px",
|
|
501
653
|
boxSizing: "border-box",
|
|
502
654
|
outline: "none",
|
|
@@ -506,8 +658,8 @@ var UrAuth = ({
|
|
|
506
658
|
width: "100%",
|
|
507
659
|
padding: "14px",
|
|
508
660
|
borderRadius: "0",
|
|
509
|
-
background:
|
|
510
|
-
color:
|
|
661
|
+
background: `linear-gradient(180deg, ${primaryColor} 0%, ${secondStopColor} 100%)`,
|
|
662
|
+
color: themeColors.primaryText,
|
|
511
663
|
fontSize: "15px",
|
|
512
664
|
fontWeight: 600,
|
|
513
665
|
border: "none",
|
|
@@ -520,7 +672,7 @@ var UrAuth = ({
|
|
|
520
672
|
display: "flex",
|
|
521
673
|
alignItems: "center",
|
|
522
674
|
margin: "24px 0",
|
|
523
|
-
color:
|
|
675
|
+
color: themeColors.dividerText,
|
|
524
676
|
fontSize: "11px",
|
|
525
677
|
fontWeight: 600,
|
|
526
678
|
letterSpacing: "1px"
|
|
@@ -528,7 +680,7 @@ var UrAuth = ({
|
|
|
528
680
|
dividerLine: {
|
|
529
681
|
flex: 1,
|
|
530
682
|
height: "1px",
|
|
531
|
-
background: border
|
|
683
|
+
background: themeColors.border
|
|
532
684
|
},
|
|
533
685
|
dividerText: {
|
|
534
686
|
padding: "0 12px"
|
|
@@ -537,9 +689,9 @@ var UrAuth = ({
|
|
|
537
689
|
width: "100%",
|
|
538
690
|
padding: "12px",
|
|
539
691
|
borderRadius: "0",
|
|
540
|
-
border: `1px solid ${border}`,
|
|
541
|
-
background:
|
|
542
|
-
color: text,
|
|
692
|
+
border: `1px solid ${themeColors.border}`,
|
|
693
|
+
background: themeColors.socialButtonBackground,
|
|
694
|
+
color: themeColors.text,
|
|
543
695
|
fontSize: "14px",
|
|
544
696
|
fontWeight: 600,
|
|
545
697
|
display: "flex",
|
|
@@ -548,19 +700,19 @@ var UrAuth = ({
|
|
|
548
700
|
gap: "10px",
|
|
549
701
|
marginBottom: "12px",
|
|
550
702
|
cursor: "pointer",
|
|
551
|
-
boxShadow:
|
|
703
|
+
boxShadow: theme === "dark" ? "none" : "0 1px 2px rgba(0,0,0,0.02)",
|
|
552
704
|
transition: "background 0.2s ease"
|
|
553
705
|
},
|
|
554
706
|
footer: {
|
|
555
|
-
background:
|
|
707
|
+
background: themeColors.footerBackground,
|
|
556
708
|
padding: "24px",
|
|
557
709
|
textAlign: "center",
|
|
558
|
-
borderTop: `1px solid ${border}`,
|
|
710
|
+
borderTop: `1px solid ${themeColors.border}`,
|
|
559
711
|
fontSize: "13px",
|
|
560
|
-
color: textMuted
|
|
712
|
+
color: themeColors.textMuted
|
|
561
713
|
},
|
|
562
714
|
footerLink: {
|
|
563
|
-
color: text,
|
|
715
|
+
color: themeColors.text,
|
|
564
716
|
fontWeight: 600,
|
|
565
717
|
textDecoration: "underline",
|
|
566
718
|
cursor: "pointer",
|
|
@@ -576,14 +728,37 @@ var UrAuth = ({
|
|
|
576
728
|
/* @__PURE__ */ jsx4("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
|
|
577
729
|
/* @__PURE__ */ jsx4("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
|
|
578
730
|
] });
|
|
579
|
-
const GithubIcon = () => /* @__PURE__ */ jsx4("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill:
|
|
731
|
+
const GithubIcon = () => /* @__PURE__ */ jsx4("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: theme === "dark" ? "#fff" : "#000", children: /* @__PURE__ */ jsx4("path", { d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" }) });
|
|
732
|
+
const renderSocialButtons = () => {
|
|
733
|
+
if (!hasSocialAuth) {
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
return /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
737
|
+
hasPasswordAuth && /* @__PURE__ */ jsxs2("div", { style: styles.divider, children: [
|
|
738
|
+
/* @__PURE__ */ jsx4("div", { style: styles.dividerLine }),
|
|
739
|
+
/* @__PURE__ */ jsx4("span", { style: styles.dividerText, children: text.socialDivider }),
|
|
740
|
+
/* @__PURE__ */ jsx4("div", { style: styles.dividerLine })
|
|
741
|
+
] }),
|
|
742
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
743
|
+
isGoogleEnabled && /* @__PURE__ */ jsxs2("button", { style: styles.socialBtn, onClick: () => socialLogin("google"), type: "button", children: [
|
|
744
|
+
/* @__PURE__ */ jsx4(GoogleIcon, {}),
|
|
745
|
+
text.googleButton
|
|
746
|
+
] }),
|
|
747
|
+
isGithubEnabled && /* @__PURE__ */ jsxs2("button", { style: styles.socialBtn, onClick: () => socialLogin("github"), type: "button", children: [
|
|
748
|
+
/* @__PURE__ */ jsx4(GithubIcon, {}),
|
|
749
|
+
text.githubButton
|
|
750
|
+
] })
|
|
751
|
+
] })
|
|
752
|
+
] });
|
|
753
|
+
};
|
|
754
|
+
const footerPrompt = mode === "signin" ? text.footerSigninPrompt : mode === "signup" ? text.footerSignupPrompt : text.footerForgotPrompt;
|
|
580
755
|
return /* @__PURE__ */ jsxs2("div", { style: styles.wrapper, children: [
|
|
581
756
|
toast && /* @__PURE__ */ jsx4(
|
|
582
757
|
Toast,
|
|
583
758
|
{
|
|
584
759
|
message: toast.message,
|
|
585
760
|
type: toast.type,
|
|
586
|
-
isDark,
|
|
761
|
+
isDark: theme === "dark",
|
|
587
762
|
onClose: () => {
|
|
588
763
|
setToast(null);
|
|
589
764
|
if (toast.type === "error") clearError();
|
|
@@ -591,7 +766,12 @@ var UrAuth = ({
|
|
|
591
766
|
}
|
|
592
767
|
),
|
|
593
768
|
/* @__PURE__ */ jsxs2("div", { style: styles.body, children: [
|
|
594
|
-
(
|
|
769
|
+
(brandingLogo || branding?.brandName || branding?.appName || branding?.title || branding?.subtitle || headerTitle || headerSubtitle) && /* @__PURE__ */ jsxs2("div", { style: styles.header, children: [
|
|
770
|
+
/* @__PURE__ */ jsx4("div", { style: styles.brandRow, children: brandingLogo ? /* @__PURE__ */ jsx4("div", { style: styles.brandLogo, children: typeof brandingLogo === "string" ? /* @__PURE__ */ jsx4("img", { src: brandingLogo, alt: brandName, style: { width: "100%", height: "100%", objectFit: "contain" } }) : brandingLogo }) : /* @__PURE__ */ jsx4("div", { style: styles.brandLogo, "aria-hidden": "true", children: brandName.slice(0, 1).toUpperCase() }) }),
|
|
771
|
+
/* @__PURE__ */ jsx4("h1", { style: styles.brandTitle, children: headerTitle }),
|
|
772
|
+
/* @__PURE__ */ jsx4("p", { style: styles.brandSubtitle, children: headerSubtitle })
|
|
773
|
+
] }),
|
|
774
|
+
showSwitcher && (mode === "signin" || mode === "signup") && /* @__PURE__ */ jsx4("div", { style: styles.switcherContainer, children: /* @__PURE__ */ jsxs2("div", { style: styles.switcher, children: [
|
|
595
775
|
/* @__PURE__ */ jsxs2(
|
|
596
776
|
"button",
|
|
597
777
|
{
|
|
@@ -607,7 +787,7 @@ var UrAuth = ({
|
|
|
607
787
|
/* @__PURE__ */ jsx4("polyline", { points: "10 17 15 12 10 7" }),
|
|
608
788
|
/* @__PURE__ */ jsx4("line", { x1: "15", y1: "12", x2: "3", y2: "12" })
|
|
609
789
|
] }),
|
|
610
|
-
|
|
790
|
+
text.loginTab
|
|
611
791
|
]
|
|
612
792
|
}
|
|
613
793
|
),
|
|
@@ -627,24 +807,25 @@ var UrAuth = ({
|
|
|
627
807
|
/* @__PURE__ */ jsx4("line", { x1: "19", y1: "8", x2: "19", y2: "14" }),
|
|
628
808
|
/* @__PURE__ */ jsx4("line", { x1: "22", y1: "11", x2: "16", y2: "11" })
|
|
629
809
|
] }),
|
|
630
|
-
|
|
810
|
+
text.signupTab
|
|
631
811
|
]
|
|
632
812
|
}
|
|
633
813
|
)
|
|
634
814
|
] }) }),
|
|
635
815
|
(mode === "forgot" || mode === "reset") && /* @__PURE__ */ jsxs2("div", { style: { marginBottom: "24px", textAlign: "center" }, children: [
|
|
636
|
-
/* @__PURE__ */ jsx4("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: text }, children: mode === "forgot" ?
|
|
637
|
-
/* @__PURE__ */ jsx4("p", { style: { margin: 0, fontSize: "14px", color: textMuted }, children: mode === "forgot" ?
|
|
816
|
+
/* @__PURE__ */ jsx4("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: themeColors.text }, children: mode === "forgot" ? text.forgotTitle : text.resetTitle }),
|
|
817
|
+
/* @__PURE__ */ jsx4("p", { style: { margin: 0, fontSize: "14px", color: themeColors.textMuted }, children: mode === "forgot" ? text.forgotSubtitle : text.resetSubtitle.replace("{email}", email) })
|
|
638
818
|
] }),
|
|
639
|
-
/* @__PURE__ */
|
|
819
|
+
!hasPasswordAuth && !hasSocialAuth && /* @__PURE__ */ jsx4("div", { style: { textAlign: "center", color: themeColors.textMuted, fontSize: "14px", lineHeight: 1.5 }, children: text.noAuthMethods }),
|
|
820
|
+
hasPasswordAuth && /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, children: [
|
|
640
821
|
mode === "signup" && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
641
|
-
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children:
|
|
822
|
+
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: text.nameLabel }) }),
|
|
642
823
|
/* @__PURE__ */ jsx4(
|
|
643
824
|
"input",
|
|
644
825
|
{
|
|
645
826
|
style: styles.input,
|
|
646
827
|
type: "text",
|
|
647
|
-
placeholder:
|
|
828
|
+
placeholder: text.namePlaceholder,
|
|
648
829
|
value: name,
|
|
649
830
|
onChange: (e) => setName(e.target.value),
|
|
650
831
|
required: true
|
|
@@ -652,13 +833,13 @@ var UrAuth = ({
|
|
|
652
833
|
)
|
|
653
834
|
] }),
|
|
654
835
|
/* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
655
|
-
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children:
|
|
836
|
+
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: text.emailLabel }) }),
|
|
656
837
|
/* @__PURE__ */ jsx4(
|
|
657
838
|
"input",
|
|
658
839
|
{
|
|
659
840
|
style: styles.input,
|
|
660
841
|
type: "email",
|
|
661
|
-
placeholder:
|
|
842
|
+
placeholder: text.emailPlaceholder,
|
|
662
843
|
value: email,
|
|
663
844
|
onChange: (e) => setEmail(e.target.value),
|
|
664
845
|
required: true,
|
|
@@ -666,40 +847,40 @@ var UrAuth = ({
|
|
|
666
847
|
}
|
|
667
848
|
)
|
|
668
849
|
] }),
|
|
669
|
-
mode === "reset" && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
670
|
-
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: "6-digit OTP Code" }) }),
|
|
671
|
-
/* @__PURE__ */ jsx4(
|
|
672
|
-
"input",
|
|
673
|
-
{
|
|
674
|
-
style: styles.input,
|
|
675
|
-
type: "text",
|
|
676
|
-
placeholder: "Enter reset code",
|
|
677
|
-
value: otp,
|
|
678
|
-
onChange: (e) => setOtp(e.target.value),
|
|
679
|
-
required: true
|
|
680
|
-
}
|
|
681
|
-
)
|
|
682
|
-
] }),
|
|
683
850
|
(mode === "signin" || mode === "signup" || mode === "reset") && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
684
851
|
/* @__PURE__ */ jsxs2("div", { style: styles.labelRow, children: [
|
|
685
|
-
/* @__PURE__ */ jsx4("label", { style: styles.label, children: mode === "reset" ?
|
|
852
|
+
/* @__PURE__ */ jsx4("label", { style: styles.label, children: mode === "reset" ? text.passwordLabel : text.passwordLabel }),
|
|
686
853
|
mode === "signin" && /* @__PURE__ */ jsx4("button", { type: "button", style: styles.forgotLink, onClick: () => {
|
|
687
854
|
setMode("forgot");
|
|
688
855
|
clearError();
|
|
689
|
-
}, children:
|
|
856
|
+
}, children: text.forgotPasswordLink })
|
|
690
857
|
] }),
|
|
691
858
|
/* @__PURE__ */ jsx4(
|
|
692
859
|
"input",
|
|
693
860
|
{
|
|
694
861
|
style: styles.input,
|
|
695
862
|
type: "password",
|
|
696
|
-
placeholder:
|
|
863
|
+
placeholder: text.passwordPlaceholder,
|
|
697
864
|
value: password,
|
|
698
865
|
onChange: (e) => setPassword(e.target.value),
|
|
699
866
|
required: true
|
|
700
867
|
}
|
|
701
868
|
)
|
|
702
869
|
] }),
|
|
870
|
+
mode === "reset" && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
871
|
+
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: text.otpLabel }) }),
|
|
872
|
+
/* @__PURE__ */ jsx4(
|
|
873
|
+
"input",
|
|
874
|
+
{
|
|
875
|
+
style: styles.input,
|
|
876
|
+
type: "text",
|
|
877
|
+
placeholder: text.otpPlaceholder,
|
|
878
|
+
value: otp,
|
|
879
|
+
onChange: (e) => setOtp(e.target.value),
|
|
880
|
+
required: true
|
|
881
|
+
}
|
|
882
|
+
)
|
|
883
|
+
] }),
|
|
703
884
|
/* @__PURE__ */ jsx4(
|
|
704
885
|
"button",
|
|
705
886
|
{
|
|
@@ -709,30 +890,14 @@ var UrAuth = ({
|
|
|
709
890
|
onMouseDown: (e) => e.currentTarget.style.transform = "scale(0.98)",
|
|
710
891
|
onMouseUp: (e) => e.currentTarget.style.transform = "scale(1)",
|
|
711
892
|
onMouseLeave: (e) => e.currentTarget.style.transform = "scale(1)",
|
|
712
|
-
children: isLoading ? "Processing..." : mode === "signin" ?
|
|
893
|
+
children: isLoading ? "Processing..." : mode === "signin" ? text.loginButton : mode === "signup" ? text.signupButton : mode === "forgot" ? text.forgotButton : text.resetButton
|
|
713
894
|
}
|
|
714
895
|
)
|
|
715
896
|
] }),
|
|
716
|
-
(mode === "signin" || mode === "signup") &&
|
|
717
|
-
/* @__PURE__ */ jsxs2("div", { style: styles.divider, children: [
|
|
718
|
-
/* @__PURE__ */ jsx4("div", { style: styles.dividerLine }),
|
|
719
|
-
/* @__PURE__ */ jsx4("span", { style: styles.dividerText, children: "OR" }),
|
|
720
|
-
/* @__PURE__ */ jsx4("div", { style: styles.dividerLine })
|
|
721
|
-
] }),
|
|
722
|
-
/* @__PURE__ */ jsxs2("div", { children: [
|
|
723
|
-
providers.includes("google") && /* @__PURE__ */ jsxs2("button", { style: styles.socialBtn, onClick: () => socialLogin("google"), type: "button", children: [
|
|
724
|
-
/* @__PURE__ */ jsx4(GoogleIcon, {}),
|
|
725
|
-
"Continue with Google"
|
|
726
|
-
] }),
|
|
727
|
-
providers.includes("github") && /* @__PURE__ */ jsxs2("button", { style: styles.socialBtn, onClick: () => socialLogin("github"), type: "button", children: [
|
|
728
|
-
/* @__PURE__ */ jsx4(GithubIcon, {}),
|
|
729
|
-
"Continue with GitHub"
|
|
730
|
-
] })
|
|
731
|
-
] })
|
|
732
|
-
] })
|
|
897
|
+
(mode === "signin" || mode === "signup") && renderSocialButtons()
|
|
733
898
|
] }),
|
|
734
|
-
/* @__PURE__ */ jsxs2("div", { style: styles.footer, children: [
|
|
735
|
-
|
|
899
|
+
hasPasswordAuth && /* @__PURE__ */ jsxs2("div", { style: styles.footer, children: [
|
|
900
|
+
footerPrompt,
|
|
736
901
|
/* @__PURE__ */ jsx4(
|
|
737
902
|
"button",
|
|
738
903
|
{
|
|
@@ -742,7 +907,7 @@ var UrAuth = ({
|
|
|
742
907
|
setMode(mode === "signin" ? "signup" : "signin");
|
|
743
908
|
clearError();
|
|
744
909
|
},
|
|
745
|
-
children: mode === "signin" ?
|
|
910
|
+
children: mode === "signin" ? text.signupTab : text.loginTab
|
|
746
911
|
}
|
|
747
912
|
)
|
|
748
913
|
] })
|