@urbackend/react 0.1.1 → 0.2.0
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 +69 -2
- package/dist/index.d.ts +69 -2
- package/dist/index.js +245 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +246 -82
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
- 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,48 @@ 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 || 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 headerSubtitle = branding?.subtitle || (mode === "signin" ? text.loginTitle : mode === "signup" ? text.signupTitle : mode === "forgot" ? text.forgotTitle : text.resetTitle);
|
|
504
|
+
const showSwitcher = hasPasswordAuth;
|
|
389
505
|
useEffect4(() => {
|
|
390
506
|
if (error) {
|
|
391
507
|
setToast({ message: error, type: "error" });
|
|
392
508
|
}
|
|
393
509
|
}, [error]);
|
|
510
|
+
useEffect4(() => {
|
|
511
|
+
if (!hasPasswordAuth && mode !== "signin") {
|
|
512
|
+
setMode("signin");
|
|
513
|
+
}
|
|
514
|
+
}, [hasPasswordAuth, mode]);
|
|
394
515
|
const handleSubmit = async (e) => {
|
|
395
516
|
e.preventDefault();
|
|
396
517
|
try {
|
|
@@ -417,28 +538,58 @@ var UrAuth = ({
|
|
|
417
538
|
} catch (err) {
|
|
418
539
|
}
|
|
419
540
|
};
|
|
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
541
|
const styles = {
|
|
427
542
|
wrapper: {
|
|
428
543
|
width: "100%",
|
|
429
544
|
maxWidth: "420px",
|
|
430
545
|
margin: "0 auto",
|
|
431
546
|
borderRadius: "0",
|
|
432
|
-
background:
|
|
433
|
-
boxShadow:
|
|
434
|
-
border: `1px solid ${border}`,
|
|
547
|
+
background: themeColors.background,
|
|
548
|
+
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)",
|
|
549
|
+
border: `1px solid ${themeColors.border}`,
|
|
435
550
|
overflow: "hidden",
|
|
436
551
|
fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
437
|
-
color: text
|
|
552
|
+
color: themeColors.text
|
|
438
553
|
},
|
|
439
554
|
body: {
|
|
440
555
|
padding: "32px 32px 24px 32px"
|
|
441
556
|
},
|
|
557
|
+
header: {
|
|
558
|
+
textAlign: "center",
|
|
559
|
+
marginBottom: "28px"
|
|
560
|
+
},
|
|
561
|
+
brandRow: {
|
|
562
|
+
display: "flex",
|
|
563
|
+
justifyContent: "center",
|
|
564
|
+
alignItems: "center",
|
|
565
|
+
gap: "12px",
|
|
566
|
+
marginBottom: "10px"
|
|
567
|
+
},
|
|
568
|
+
brandLogo: {
|
|
569
|
+
width: "44px",
|
|
570
|
+
height: "44px",
|
|
571
|
+
borderRadius: "12px",
|
|
572
|
+
display: "inline-flex",
|
|
573
|
+
alignItems: "center",
|
|
574
|
+
justifyContent: "center",
|
|
575
|
+
background: theme === "dark" ? "#2a2a2a" : "#f1f5f9",
|
|
576
|
+
color: themeColors.text,
|
|
577
|
+
overflow: "hidden"
|
|
578
|
+
},
|
|
579
|
+
brandTitle: {
|
|
580
|
+
margin: 0,
|
|
581
|
+
fontSize: "26px",
|
|
582
|
+
lineHeight: 1.1,
|
|
583
|
+
fontWeight: 800,
|
|
584
|
+
color: themeColors.text
|
|
585
|
+
},
|
|
586
|
+
brandSubtitle: {
|
|
587
|
+
margin: "0 auto",
|
|
588
|
+
maxWidth: "320px",
|
|
589
|
+
fontSize: "14px",
|
|
590
|
+
lineHeight: 1.5,
|
|
591
|
+
color: themeColors.textMuted
|
|
592
|
+
},
|
|
442
593
|
switcherContainer: {
|
|
443
594
|
display: "flex",
|
|
444
595
|
alignItems: "center",
|
|
@@ -447,7 +598,7 @@ var UrAuth = ({
|
|
|
447
598
|
},
|
|
448
599
|
switcher: {
|
|
449
600
|
display: "inline-flex",
|
|
450
|
-
background:
|
|
601
|
+
background: theme === "dark" ? "#2a2a2a" : "#f1f5f9",
|
|
451
602
|
padding: "4px",
|
|
452
603
|
borderRadius: "0"
|
|
453
604
|
},
|
|
@@ -460,9 +611,9 @@ var UrAuth = ({
|
|
|
460
611
|
fontSize: "13px",
|
|
461
612
|
fontWeight: 600,
|
|
462
613
|
cursor: "pointer",
|
|
463
|
-
color: active ? text : textMuted,
|
|
464
|
-
background: active ?
|
|
465
|
-
boxShadow: active ?
|
|
614
|
+
color: active ? themeColors.text : themeColors.textMuted,
|
|
615
|
+
background: active ? theme === "dark" ? "#444444" : "#ffffff" : "transparent",
|
|
616
|
+
boxShadow: active ? theme === "dark" ? "0 2px 4px rgba(0,0,0,0.2)" : "0 2px 8px rgba(0,0,0,0.05)" : "none",
|
|
466
617
|
border: "none",
|
|
467
618
|
transition: "all 0.2s ease"
|
|
468
619
|
}),
|
|
@@ -478,12 +629,12 @@ var UrAuth = ({
|
|
|
478
629
|
label: {
|
|
479
630
|
fontSize: "13px",
|
|
480
631
|
fontWeight: 600,
|
|
481
|
-
color:
|
|
632
|
+
color: theme === "dark" ? "#dddddd" : "#334155"
|
|
482
633
|
},
|
|
483
634
|
forgotLink: {
|
|
484
635
|
fontSize: "12px",
|
|
485
636
|
fontWeight: 600,
|
|
486
|
-
color: text,
|
|
637
|
+
color: themeColors.text,
|
|
487
638
|
cursor: "pointer",
|
|
488
639
|
textDecoration: "none",
|
|
489
640
|
background: "none",
|
|
@@ -494,9 +645,9 @@ var UrAuth = ({
|
|
|
494
645
|
width: "100%",
|
|
495
646
|
padding: "12px 16px",
|
|
496
647
|
borderRadius: "0",
|
|
497
|
-
border: `1px solid ${border}`,
|
|
498
|
-
background:
|
|
499
|
-
color: text,
|
|
648
|
+
border: `1px solid ${themeColors.border}`,
|
|
649
|
+
background: themeColors.inputBackground,
|
|
650
|
+
color: themeColors.text,
|
|
500
651
|
fontSize: "14px",
|
|
501
652
|
boxSizing: "border-box",
|
|
502
653
|
outline: "none",
|
|
@@ -506,8 +657,8 @@ var UrAuth = ({
|
|
|
506
657
|
width: "100%",
|
|
507
658
|
padding: "14px",
|
|
508
659
|
borderRadius: "0",
|
|
509
|
-
background:
|
|
510
|
-
color:
|
|
660
|
+
background: `linear-gradient(180deg, ${primaryColor} 0%, ${secondStopColor} 100%)`,
|
|
661
|
+
color: themeColors.primaryText,
|
|
511
662
|
fontSize: "15px",
|
|
512
663
|
fontWeight: 600,
|
|
513
664
|
border: "none",
|
|
@@ -520,7 +671,7 @@ var UrAuth = ({
|
|
|
520
671
|
display: "flex",
|
|
521
672
|
alignItems: "center",
|
|
522
673
|
margin: "24px 0",
|
|
523
|
-
color:
|
|
674
|
+
color: themeColors.dividerText,
|
|
524
675
|
fontSize: "11px",
|
|
525
676
|
fontWeight: 600,
|
|
526
677
|
letterSpacing: "1px"
|
|
@@ -528,7 +679,7 @@ var UrAuth = ({
|
|
|
528
679
|
dividerLine: {
|
|
529
680
|
flex: 1,
|
|
530
681
|
height: "1px",
|
|
531
|
-
background: border
|
|
682
|
+
background: themeColors.border
|
|
532
683
|
},
|
|
533
684
|
dividerText: {
|
|
534
685
|
padding: "0 12px"
|
|
@@ -537,9 +688,9 @@ var UrAuth = ({
|
|
|
537
688
|
width: "100%",
|
|
538
689
|
padding: "12px",
|
|
539
690
|
borderRadius: "0",
|
|
540
|
-
border: `1px solid ${border}`,
|
|
541
|
-
background:
|
|
542
|
-
color: text,
|
|
691
|
+
border: `1px solid ${themeColors.border}`,
|
|
692
|
+
background: themeColors.socialButtonBackground,
|
|
693
|
+
color: themeColors.text,
|
|
543
694
|
fontSize: "14px",
|
|
544
695
|
fontWeight: 600,
|
|
545
696
|
display: "flex",
|
|
@@ -548,19 +699,19 @@ var UrAuth = ({
|
|
|
548
699
|
gap: "10px",
|
|
549
700
|
marginBottom: "12px",
|
|
550
701
|
cursor: "pointer",
|
|
551
|
-
boxShadow:
|
|
702
|
+
boxShadow: theme === "dark" ? "none" : "0 1px 2px rgba(0,0,0,0.02)",
|
|
552
703
|
transition: "background 0.2s ease"
|
|
553
704
|
},
|
|
554
705
|
footer: {
|
|
555
|
-
background:
|
|
706
|
+
background: themeColors.footerBackground,
|
|
556
707
|
padding: "24px",
|
|
557
708
|
textAlign: "center",
|
|
558
|
-
borderTop: `1px solid ${border}`,
|
|
709
|
+
borderTop: `1px solid ${themeColors.border}`,
|
|
559
710
|
fontSize: "13px",
|
|
560
|
-
color: textMuted
|
|
711
|
+
color: themeColors.textMuted
|
|
561
712
|
},
|
|
562
713
|
footerLink: {
|
|
563
|
-
color: text,
|
|
714
|
+
color: themeColors.text,
|
|
564
715
|
fontWeight: 600,
|
|
565
716
|
textDecoration: "underline",
|
|
566
717
|
cursor: "pointer",
|
|
@@ -576,14 +727,37 @@ var UrAuth = ({
|
|
|
576
727
|
/* @__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
728
|
/* @__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
729
|
] });
|
|
579
|
-
const GithubIcon = () => /* @__PURE__ */ jsx4("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill:
|
|
730
|
+
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" }) });
|
|
731
|
+
const renderSocialButtons = () => {
|
|
732
|
+
if (!hasSocialAuth) {
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
return /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
736
|
+
hasPasswordAuth && /* @__PURE__ */ jsxs2("div", { style: styles.divider, children: [
|
|
737
|
+
/* @__PURE__ */ jsx4("div", { style: styles.dividerLine }),
|
|
738
|
+
/* @__PURE__ */ jsx4("span", { style: styles.dividerText, children: text.socialDivider }),
|
|
739
|
+
/* @__PURE__ */ jsx4("div", { style: styles.dividerLine })
|
|
740
|
+
] }),
|
|
741
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
742
|
+
isGoogleEnabled && /* @__PURE__ */ jsxs2("button", { style: styles.socialBtn, onClick: () => socialLogin("google"), type: "button", children: [
|
|
743
|
+
/* @__PURE__ */ jsx4(GoogleIcon, {}),
|
|
744
|
+
text.googleButton
|
|
745
|
+
] }),
|
|
746
|
+
isGithubEnabled && /* @__PURE__ */ jsxs2("button", { style: styles.socialBtn, onClick: () => socialLogin("github"), type: "button", children: [
|
|
747
|
+
/* @__PURE__ */ jsx4(GithubIcon, {}),
|
|
748
|
+
text.githubButton
|
|
749
|
+
] })
|
|
750
|
+
] })
|
|
751
|
+
] });
|
|
752
|
+
};
|
|
753
|
+
const footerPrompt = mode === "signin" ? text.footerSigninPrompt : mode === "signup" ? text.footerSignupPrompt : text.footerForgotPrompt;
|
|
580
754
|
return /* @__PURE__ */ jsxs2("div", { style: styles.wrapper, children: [
|
|
581
755
|
toast && /* @__PURE__ */ jsx4(
|
|
582
756
|
Toast,
|
|
583
757
|
{
|
|
584
758
|
message: toast.message,
|
|
585
759
|
type: toast.type,
|
|
586
|
-
isDark,
|
|
760
|
+
isDark: theme === "dark",
|
|
587
761
|
onClose: () => {
|
|
588
762
|
setToast(null);
|
|
589
763
|
if (toast.type === "error") clearError();
|
|
@@ -591,7 +765,12 @@ var UrAuth = ({
|
|
|
591
765
|
}
|
|
592
766
|
),
|
|
593
767
|
/* @__PURE__ */ jsxs2("div", { style: styles.body, children: [
|
|
594
|
-
(
|
|
768
|
+
(branding?.logo || branding?.brandName || branding?.appName || branding?.title || branding?.subtitle || headerTitle || headerSubtitle) && /* @__PURE__ */ jsxs2("div", { style: styles.header, children: [
|
|
769
|
+
/* @__PURE__ */ jsx4("div", { style: styles.brandRow, children: branding?.logo ? /* @__PURE__ */ jsx4("div", { style: styles.brandLogo, children: typeof branding.logo === "string" ? /* @__PURE__ */ jsx4("img", { src: branding.logo, alt: brandName, style: { width: "100%", height: "100%", objectFit: "contain" } }) : branding.logo }) : /* @__PURE__ */ jsx4("div", { style: styles.brandLogo, "aria-hidden": "true", children: brandName.slice(0, 1).toUpperCase() }) }),
|
|
770
|
+
/* @__PURE__ */ jsx4("h1", { style: styles.brandTitle, children: headerTitle }),
|
|
771
|
+
/* @__PURE__ */ jsx4("p", { style: styles.brandSubtitle, children: headerSubtitle })
|
|
772
|
+
] }),
|
|
773
|
+
showSwitcher && (mode === "signin" || mode === "signup") && /* @__PURE__ */ jsx4("div", { style: styles.switcherContainer, children: /* @__PURE__ */ jsxs2("div", { style: styles.switcher, children: [
|
|
595
774
|
/* @__PURE__ */ jsxs2(
|
|
596
775
|
"button",
|
|
597
776
|
{
|
|
@@ -607,7 +786,7 @@ var UrAuth = ({
|
|
|
607
786
|
/* @__PURE__ */ jsx4("polyline", { points: "10 17 15 12 10 7" }),
|
|
608
787
|
/* @__PURE__ */ jsx4("line", { x1: "15", y1: "12", x2: "3", y2: "12" })
|
|
609
788
|
] }),
|
|
610
|
-
|
|
789
|
+
text.loginTab
|
|
611
790
|
]
|
|
612
791
|
}
|
|
613
792
|
),
|
|
@@ -627,24 +806,25 @@ var UrAuth = ({
|
|
|
627
806
|
/* @__PURE__ */ jsx4("line", { x1: "19", y1: "8", x2: "19", y2: "14" }),
|
|
628
807
|
/* @__PURE__ */ jsx4("line", { x1: "22", y1: "11", x2: "16", y2: "11" })
|
|
629
808
|
] }),
|
|
630
|
-
|
|
809
|
+
text.signupTab
|
|
631
810
|
]
|
|
632
811
|
}
|
|
633
812
|
)
|
|
634
813
|
] }) }),
|
|
635
814
|
(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" ?
|
|
815
|
+
/* @__PURE__ */ jsx4("h2", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 700, color: themeColors.text }, children: mode === "forgot" ? text.forgotTitle : text.resetTitle }),
|
|
816
|
+
/* @__PURE__ */ jsx4("p", { style: { margin: 0, fontSize: "14px", color: themeColors.textMuted }, children: mode === "forgot" ? text.forgotSubtitle : text.resetSubtitle.replace("{email}", email) })
|
|
638
817
|
] }),
|
|
639
|
-
/* @__PURE__ */
|
|
818
|
+
!hasPasswordAuth && !hasSocialAuth && /* @__PURE__ */ jsx4("div", { style: { textAlign: "center", color: themeColors.textMuted, fontSize: "14px", lineHeight: 1.5 }, children: text.noAuthMethods }),
|
|
819
|
+
hasPasswordAuth && /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, children: [
|
|
640
820
|
mode === "signup" && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
641
|
-
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children:
|
|
821
|
+
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: text.nameLabel }) }),
|
|
642
822
|
/* @__PURE__ */ jsx4(
|
|
643
823
|
"input",
|
|
644
824
|
{
|
|
645
825
|
style: styles.input,
|
|
646
826
|
type: "text",
|
|
647
|
-
placeholder:
|
|
827
|
+
placeholder: text.namePlaceholder,
|
|
648
828
|
value: name,
|
|
649
829
|
onChange: (e) => setName(e.target.value),
|
|
650
830
|
required: true
|
|
@@ -652,13 +832,13 @@ var UrAuth = ({
|
|
|
652
832
|
)
|
|
653
833
|
] }),
|
|
654
834
|
/* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
655
|
-
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children:
|
|
835
|
+
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: text.emailLabel }) }),
|
|
656
836
|
/* @__PURE__ */ jsx4(
|
|
657
837
|
"input",
|
|
658
838
|
{
|
|
659
839
|
style: styles.input,
|
|
660
840
|
type: "email",
|
|
661
|
-
placeholder:
|
|
841
|
+
placeholder: text.emailPlaceholder,
|
|
662
842
|
value: email,
|
|
663
843
|
onChange: (e) => setEmail(e.target.value),
|
|
664
844
|
required: true,
|
|
@@ -666,40 +846,40 @@ var UrAuth = ({
|
|
|
666
846
|
}
|
|
667
847
|
)
|
|
668
848
|
] }),
|
|
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
849
|
(mode === "signin" || mode === "signup" || mode === "reset") && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
684
850
|
/* @__PURE__ */ jsxs2("div", { style: styles.labelRow, children: [
|
|
685
|
-
/* @__PURE__ */ jsx4("label", { style: styles.label, children: mode === "reset" ?
|
|
851
|
+
/* @__PURE__ */ jsx4("label", { style: styles.label, children: mode === "reset" ? text.passwordLabel : text.passwordLabel }),
|
|
686
852
|
mode === "signin" && /* @__PURE__ */ jsx4("button", { type: "button", style: styles.forgotLink, onClick: () => {
|
|
687
853
|
setMode("forgot");
|
|
688
854
|
clearError();
|
|
689
|
-
}, children:
|
|
855
|
+
}, children: text.forgotPasswordLink })
|
|
690
856
|
] }),
|
|
691
857
|
/* @__PURE__ */ jsx4(
|
|
692
858
|
"input",
|
|
693
859
|
{
|
|
694
860
|
style: styles.input,
|
|
695
861
|
type: "password",
|
|
696
|
-
placeholder:
|
|
862
|
+
placeholder: text.passwordPlaceholder,
|
|
697
863
|
value: password,
|
|
698
864
|
onChange: (e) => setPassword(e.target.value),
|
|
699
865
|
required: true
|
|
700
866
|
}
|
|
701
867
|
)
|
|
702
868
|
] }),
|
|
869
|
+
mode === "reset" && /* @__PURE__ */ jsxs2("div", { style: styles.field, children: [
|
|
870
|
+
/* @__PURE__ */ jsx4("div", { style: styles.labelRow, children: /* @__PURE__ */ jsx4("label", { style: styles.label, children: text.otpLabel }) }),
|
|
871
|
+
/* @__PURE__ */ jsx4(
|
|
872
|
+
"input",
|
|
873
|
+
{
|
|
874
|
+
style: styles.input,
|
|
875
|
+
type: "text",
|
|
876
|
+
placeholder: text.otpPlaceholder,
|
|
877
|
+
value: otp,
|
|
878
|
+
onChange: (e) => setOtp(e.target.value),
|
|
879
|
+
required: true
|
|
880
|
+
}
|
|
881
|
+
)
|
|
882
|
+
] }),
|
|
703
883
|
/* @__PURE__ */ jsx4(
|
|
704
884
|
"button",
|
|
705
885
|
{
|
|
@@ -709,30 +889,14 @@ var UrAuth = ({
|
|
|
709
889
|
onMouseDown: (e) => e.currentTarget.style.transform = "scale(0.98)",
|
|
710
890
|
onMouseUp: (e) => e.currentTarget.style.transform = "scale(1)",
|
|
711
891
|
onMouseLeave: (e) => e.currentTarget.style.transform = "scale(1)",
|
|
712
|
-
children: isLoading ? "Processing..." : mode === "signin" ?
|
|
892
|
+
children: isLoading ? "Processing..." : mode === "signin" ? text.loginButton : mode === "signup" ? text.signupButton : mode === "forgot" ? text.forgotButton : text.resetButton
|
|
713
893
|
}
|
|
714
894
|
)
|
|
715
895
|
] }),
|
|
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
|
-
] })
|
|
896
|
+
(mode === "signin" || mode === "signup") && renderSocialButtons()
|
|
733
897
|
] }),
|
|
734
|
-
/* @__PURE__ */ jsxs2("div", { style: styles.footer, children: [
|
|
735
|
-
|
|
898
|
+
hasPasswordAuth && /* @__PURE__ */ jsxs2("div", { style: styles.footer, children: [
|
|
899
|
+
footerPrompt,
|
|
736
900
|
/* @__PURE__ */ jsx4(
|
|
737
901
|
"button",
|
|
738
902
|
{
|
|
@@ -742,7 +906,7 @@ var UrAuth = ({
|
|
|
742
906
|
setMode(mode === "signin" ? "signup" : "signin");
|
|
743
907
|
clearError();
|
|
744
908
|
},
|
|
745
|
-
children: mode === "signin" ?
|
|
909
|
+
children: mode === "signin" ? text.signupTab : text.loginTab
|
|
746
910
|
}
|
|
747
911
|
)
|
|
748
912
|
] })
|