@wordrhyme/shadcn-auth 1.0.60 → 2.0.2

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.
Files changed (158) hide show
  1. package/README.md +154 -1
  2. package/dist/components/AuthCard.cjs +45 -0
  3. package/dist/components/AuthCard.d.cts +30 -0
  4. package/dist/components/AuthCard.d.ts +30 -0
  5. package/dist/components/AuthCard.js +42 -0
  6. package/dist/components/AuthForms.cjs +115 -0
  7. package/dist/components/AuthForms.d.cts +95 -0
  8. package/dist/components/AuthForms.d.ts +95 -0
  9. package/dist/components/AuthForms.js +112 -0
  10. package/dist/components/CompleteProfileForm.cjs +38 -0
  11. package/dist/components/CompleteProfileForm.d.cts +32 -0
  12. package/dist/components/CompleteProfileForm.d.ts +32 -0
  13. package/dist/components/CompleteProfileForm.js +36 -0
  14. package/dist/components/EmailOtpForm.cjs +181 -0
  15. package/dist/components/EmailOtpForm.d.cts +56 -0
  16. package/dist/components/EmailOtpForm.d.ts +56 -0
  17. package/dist/components/EmailOtpForm.js +176 -0
  18. package/dist/components/LegalNotice.cjs +37 -0
  19. package/dist/components/LegalNotice.d.cts +26 -0
  20. package/dist/components/LegalNotice.d.ts +26 -0
  21. package/dist/components/LegalNotice.js +35 -0
  22. package/dist/components/MagicLinkForm.cjs +119 -0
  23. package/dist/components/MagicLinkForm.d.cts +46 -0
  24. package/dist/components/MagicLinkForm.d.ts +46 -0
  25. package/dist/components/MagicLinkForm.js +115 -0
  26. package/dist/components/ProviderSignInButtons.cjs +65 -0
  27. package/dist/components/ProviderSignInButtons.d.cts +41 -0
  28. package/dist/components/ProviderSignInButtons.d.ts +41 -0
  29. package/dist/components/ProviderSignInButtons.js +62 -0
  30. package/dist/components/ResetPasswordForm.cjs +89 -0
  31. package/dist/components/ResetPasswordForm.d.cts +20 -0
  32. package/dist/components/ResetPasswordForm.d.ts +20 -0
  33. package/dist/components/ResetPasswordForm.js +85 -0
  34. package/dist/components/SignInForm.cjs +97 -0
  35. package/dist/components/SignInForm.d.cts +41 -0
  36. package/dist/components/SignInForm.d.ts +41 -0
  37. package/dist/components/SignInForm.js +93 -0
  38. package/dist/components/SignUpForm.cjs +123 -0
  39. package/dist/components/SignUpForm.d.cts +40 -0
  40. package/dist/components/SignUpForm.d.ts +40 -0
  41. package/dist/components/SignUpForm.js +119 -0
  42. package/dist/components/auth-pending/AuthButton.cjs +37 -0
  43. package/dist/components/auth-pending/AuthButton.d.cts +36 -0
  44. package/dist/components/auth-pending/AuthButton.d.ts +36 -0
  45. package/dist/components/auth-pending/AuthButton.js +34 -0
  46. package/dist/components/auth-pending/AuthPendingProvider.cjs +19 -0
  47. package/dist/components/auth-pending/AuthPendingProvider.d.cts +17 -0
  48. package/dist/components/auth-pending/AuthPendingProvider.d.ts +17 -0
  49. package/dist/components/auth-pending/AuthPendingProvider.js +17 -0
  50. package/dist/components/auth-pending/auth-pending-context.cjs +57 -0
  51. package/dist/components/auth-pending/auth-pending-context.d.cts +39 -0
  52. package/dist/components/auth-pending/auth-pending-context.d.ts +39 -0
  53. package/dist/components/auth-pending/auth-pending-context.js +52 -0
  54. package/dist/components/auth-pending/index.d.cts +3 -0
  55. package/dist/components/auth-pending/index.d.ts +3 -0
  56. package/dist/components/forms/AuthField.cjs +43 -0
  57. package/dist/components/forms/AuthField.d.cts +26 -0
  58. package/dist/components/forms/AuthField.d.ts +26 -0
  59. package/dist/components/forms/AuthField.js +40 -0
  60. package/dist/components/forms/CompleteProfileFields.cjs +63 -0
  61. package/dist/components/forms/CompleteProfileFields.d.cts +18 -0
  62. package/dist/components/forms/CompleteProfileFields.d.ts +18 -0
  63. package/dist/components/forms/CompleteProfileFields.js +60 -0
  64. package/dist/components/forms/EmailOtpCodeForm.cjs +78 -0
  65. package/dist/components/forms/EmailOtpCodeForm.d.cts +18 -0
  66. package/dist/components/forms/EmailOtpCodeForm.d.ts +18 -0
  67. package/dist/components/forms/EmailOtpCodeForm.js +75 -0
  68. package/dist/components/forms/EmailRequestForm.cjs +82 -0
  69. package/dist/components/forms/EmailRequestForm.d.cts +38 -0
  70. package/dist/components/forms/EmailRequestForm.d.ts +38 -0
  71. package/dist/components/forms/EmailRequestForm.js +79 -0
  72. package/dist/components/forms/SignInCredentialsForm.cjs +79 -0
  73. package/dist/components/forms/SignInCredentialsForm.d.cts +18 -0
  74. package/dist/components/forms/SignInCredentialsForm.d.ts +18 -0
  75. package/dist/components/forms/SignInCredentialsForm.js +76 -0
  76. package/dist/components/forms/SignUpCredentialsForm.cjs +130 -0
  77. package/dist/components/forms/SignUpCredentialsForm.d.cts +24 -0
  78. package/dist/components/forms/SignUpCredentialsForm.d.ts +24 -0
  79. package/dist/components/forms/SignUpCredentialsForm.js +126 -0
  80. package/dist/components/index.d.cts +25 -0
  81. package/dist/components/index.d.ts +25 -0
  82. package/dist/components/provider-icon/ProviderIcon.cjs +82 -0
  83. package/dist/components/provider-icon/ProviderIcon.d.cts +21 -0
  84. package/dist/components/provider-icon/ProviderIcon.d.ts +21 -0
  85. package/dist/components/provider-icon/ProviderIcon.js +79 -0
  86. package/dist/components/sign-in-methods/SignInMethodRow.cjs +55 -0
  87. package/dist/components/sign-in-methods/SignInMethodRow.d.cts +31 -0
  88. package/dist/components/sign-in-methods/SignInMethodRow.d.ts +31 -0
  89. package/dist/components/sign-in-methods/SignInMethodRow.js +50 -0
  90. package/dist/components/sign-in-methods/SignInMethods.cjs +45 -0
  91. package/dist/components/sign-in-methods/SignInMethods.d.cts +26 -0
  92. package/dist/components/sign-in-methods/SignInMethods.d.ts +26 -0
  93. package/dist/components/sign-in-methods/SignInMethods.js +43 -0
  94. package/dist/components/sign-in-methods/SignInMethodsList.cjs +69 -0
  95. package/dist/components/sign-in-methods/SignInMethodsList.d.cts +47 -0
  96. package/dist/components/sign-in-methods/SignInMethodsList.d.ts +47 -0
  97. package/dist/components/sign-in-methods/SignInMethodsList.js +65 -0
  98. package/dist/components/sign-in-methods/sign-in-methods-copy.cjs +13 -0
  99. package/dist/components/sign-in-methods/sign-in-methods-copy.d.cts +11 -0
  100. package/dist/components/sign-in-methods/sign-in-methods-copy.d.ts +11 -0
  101. package/dist/components/sign-in-methods/sign-in-methods-copy.js +12 -0
  102. package/dist/constants/auth-providers.cjs +33 -0
  103. package/dist/constants/auth-providers.d.cts +14 -0
  104. package/dist/constants/auth-providers.d.ts +14 -0
  105. package/dist/constants/auth-providers.js +31 -0
  106. package/dist/constants/validation.cjs +21 -0
  107. package/dist/constants/validation.d.cts +17 -0
  108. package/dist/constants/validation.d.ts +17 -0
  109. package/dist/constants/validation.js +18 -0
  110. package/dist/hooks/use-pending-action.cjs +37 -0
  111. package/dist/hooks/use-pending-action.d.cts +26 -0
  112. package/dist/hooks/use-pending-action.d.ts +26 -0
  113. package/dist/hooks/use-pending-action.js +35 -0
  114. package/dist/hooks/use-reset-on-page-restore.cjs +35 -0
  115. package/dist/hooks/use-reset-on-page-restore.d.cts +15 -0
  116. package/dist/hooks/use-reset-on-page-restore.d.ts +15 -0
  117. package/dist/hooks/use-reset-on-page-restore.js +33 -0
  118. package/dist/index.cjs +67 -7
  119. package/dist/index.d.cts +34 -6
  120. package/dist/index.d.ts +34 -6
  121. package/dist/index.js +33 -6
  122. package/dist/utils/build-sign-in-method-rows.cjs +25 -0
  123. package/dist/utils/build-sign-in-method-rows.d.cts +26 -0
  124. package/dist/utils/build-sign-in-method-rows.d.ts +26 -0
  125. package/dist/utils/build-sign-in-method-rows.js +24 -0
  126. package/dist/utils/until-navigation.cjs +22 -0
  127. package/dist/utils/until-navigation.d.cts +18 -0
  128. package/dist/utils/until-navigation.d.ts +18 -0
  129. package/dist/utils/until-navigation.js +21 -0
  130. package/dist/utils/validate-email.cjs +22 -0
  131. package/dist/utils/validate-email.d.cts +14 -0
  132. package/dist/utils/validate-email.d.ts +14 -0
  133. package/dist/utils/validate-email.js +21 -0
  134. package/dist/utils/validate-password.cjs +16 -0
  135. package/dist/utils/validate-password.d.cts +9 -0
  136. package/dist/utils/validate-password.d.ts +9 -0
  137. package/dist/utils/validate-password.js +16 -0
  138. package/package.json +16 -9
  139. package/dist/AuthForms.cjs +0 -47
  140. package/dist/AuthForms.d.cts +0 -23
  141. package/dist/AuthForms.d.ts +0 -23
  142. package/dist/AuthForms.js +0 -44
  143. package/dist/GoogleSignIn.cjs +0 -46
  144. package/dist/GoogleSignIn.d.cts +0 -10
  145. package/dist/GoogleSignIn.d.ts +0 -10
  146. package/dist/GoogleSignIn.js +0 -42
  147. package/dist/ResetPasswordForm.cjs +0 -106
  148. package/dist/ResetPasswordForm.d.cts +0 -17
  149. package/dist/ResetPasswordForm.d.ts +0 -17
  150. package/dist/ResetPasswordForm.js +0 -100
  151. package/dist/SignInForm.cjs +0 -164
  152. package/dist/SignInForm.d.cts +0 -21
  153. package/dist/SignInForm.d.ts +0 -21
  154. package/dist/SignInForm.js +0 -159
  155. package/dist/SignUpForm.cjs +0 -154
  156. package/dist/SignUpForm.d.cts +0 -19
  157. package/dist/SignUpForm.d.ts +0 -19
  158. package/dist/SignUpForm.js +0 -149
@@ -0,0 +1,112 @@
1
+ 'use client';
2
+
3
+
4
+ import { EmailOtpForm } from "./EmailOtpForm.js";
5
+ import { MagicLinkForm } from "./MagicLinkForm.js";
6
+ import { ResetPasswordForm } from "./ResetPasswordForm.js";
7
+ import { SignInForm } from "./SignInForm.js";
8
+ import { SignUpForm } from "./SignUpForm.js";
9
+ import { useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+
12
+ //#region src/components/AuthForms.tsx
13
+ /**
14
+ * The whole signed-out screen: every step, and the switching between them.
15
+ *
16
+ * Steps appear only when the host passed a handler for them, so this same
17
+ * component covers a password-only app and one with OAuth plus magic links
18
+ * without any configuration flags of its own.
19
+ */
20
+ function AuthForms({ onSignIn, onSignUp, credentialsDisclosureLabel, onResetPassword, onSendMagicLink, onSendEmailOtp, onVerifyEmailOtp, onGoogleSignIn, onLinkedInSignIn, isLoading, error, magicLinkSentTo, emailOtpSentTo, emailOtpExpiryMinutes, resetPasswordSentTo, signupConfirmationSentTo, initialMode = "signin", onModeChange, title, footer, privacyPolicyUrl, privacyNotice, termsUrl, minimumAge, onConsentGiven }) {
21
+ const [mode, setMode] = useState(initialMode);
22
+ const emailPasswordAuthEnabled = onSignIn != null && onSignUp != null;
23
+ const switchTo = (next) => () => {
24
+ setMode(next);
25
+ onModeChange?.(next);
26
+ };
27
+ const providers = {
28
+ onGoogleSignIn,
29
+ onLinkedInSignIn
30
+ };
31
+ const emailOtpEnabled = onSendEmailOtp != null && onVerifyEmailOtp != null;
32
+ const emailOtpSwitch = emailOtpEnabled ? switchTo("email-otp") : void 0;
33
+ const magicLinkSwitch = emailOtpEnabled || onSendMagicLink == null ? void 0 : switchTo("magic-link");
34
+ return /* @__PURE__ */ jsx("div", {
35
+ className: "flex min-h-screen items-center justify-center p-4",
36
+ children: /* @__PURE__ */ jsxs("div", {
37
+ className: "w-full max-w-md",
38
+ children: [
39
+ title != null && /* @__PURE__ */ jsx("h1", {
40
+ className: "mb-6 text-center text-3xl font-bold",
41
+ children: title
42
+ }),
43
+ mode === "signin" && /* @__PURE__ */ jsx(SignInForm, {
44
+ ...providers,
45
+ onSignIn,
46
+ credentialsDisclosureLabel,
47
+ isLoading,
48
+ error,
49
+ onSwitchToSignUp: emailPasswordAuthEnabled ? switchTo("signup") : void 0,
50
+ onSwitchToReset: emailPasswordAuthEnabled && onResetPassword != null ? switchTo("reset") : void 0,
51
+ onSwitchToMagicLink: magicLinkSwitch,
52
+ onSwitchToEmailOtp: emailOtpSwitch
53
+ }),
54
+ mode === "signup" && emailPasswordAuthEnabled && /* @__PURE__ */ jsx(SignUpForm, {
55
+ ...providers,
56
+ onSignUp,
57
+ isLoading,
58
+ error,
59
+ sentTo: signupConfirmationSentTo,
60
+ onSwitchToSignIn: switchTo("signin"),
61
+ onSwitchToMagicLink: magicLinkSwitch,
62
+ onSwitchToEmailOtp: emailOtpSwitch,
63
+ privacyPolicyUrl,
64
+ privacyNotice,
65
+ termsUrl,
66
+ minimumAge,
67
+ onConsentGiven
68
+ }),
69
+ mode === "reset" && onResetPassword != null && /* @__PURE__ */ jsx(ResetPasswordForm, {
70
+ onResetPassword,
71
+ isLoading,
72
+ error,
73
+ sentTo: resetPasswordSentTo,
74
+ onSwitchToSignIn: switchTo("signin")
75
+ }),
76
+ mode === "magic-link" && onSendMagicLink != null && /* @__PURE__ */ jsx(MagicLinkForm, {
77
+ ...providers,
78
+ onSendMagicLink,
79
+ isLoading,
80
+ error,
81
+ sentTo: magicLinkSentTo,
82
+ onUseDifferentEmail: switchTo("magic-link"),
83
+ onSwitchToSignIn: switchTo("signin"),
84
+ privacyPolicyUrl,
85
+ privacyNotice,
86
+ termsUrl
87
+ }),
88
+ mode === "email-otp" && emailOtpEnabled && /* @__PURE__ */ jsx(EmailOtpForm, {
89
+ ...providers,
90
+ onSendEmailOtp,
91
+ onVerifyEmailOtp,
92
+ isLoading,
93
+ error,
94
+ sentTo: emailOtpSentTo,
95
+ expiryMinutes: emailOtpExpiryMinutes,
96
+ onUseDifferentEmail: switchTo("email-otp"),
97
+ onSwitchToSignIn: emailPasswordAuthEnabled ? switchTo("signin") : void 0,
98
+ privacyPolicyUrl,
99
+ privacyNotice,
100
+ termsUrl
101
+ }),
102
+ footer != null && /* @__PURE__ */ jsx("footer", {
103
+ className: "text-muted-foreground mt-6 flex items-center justify-center gap-3 text-sm",
104
+ children: footer
105
+ })
106
+ ]
107
+ })
108
+ });
109
+ }
110
+
111
+ //#endregion
112
+ export { AuthForms };
@@ -0,0 +1,38 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_auth_pending_context = require('./auth-pending/auth-pending-context.cjs');
6
+ const require_AuthPendingProvider = require('./auth-pending/AuthPendingProvider.cjs');
7
+ const require_AuthCard = require('./AuthCard.cjs');
8
+ const require_CompleteProfileFields = require('./forms/CompleteProfileFields.cjs');
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
11
+
12
+ //#region src/components/CompleteProfileForm.tsx
13
+ /**
14
+ * Asks for the one thing a magic link cannot tell us.
15
+ *
16
+ * An emailed link proves an address and nothing else, so an account created
17
+ * that way has no name to greet anyone by. This is the step that fills the gap,
18
+ * and it sits *before* the post-sign-in redirect — once the Chrome extension has
19
+ * its authorization code the sign-in is over and there is nowhere left to ask.
20
+ */
21
+ function CompleteProfileForm({ onSubmit, maxDisplayNameLength, isLoading, error, email, defaultName }) {
22
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthPendingProvider.AuthPendingProvider, {
23
+ value: require_auth_pending_context.useAuthPendingState(isLoading),
24
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthCard.AuthCard, {
25
+ title: "What should we call you?",
26
+ description: email != null && email.length > 0 ? `Finishing sign-in for ${email}.` : "One last step before you continue.",
27
+ error,
28
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CompleteProfileFields.CompleteProfileFields, {
29
+ onSubmit,
30
+ maxDisplayNameLength,
31
+ defaultName
32
+ })
33
+ })
34
+ });
35
+ }
36
+
37
+ //#endregion
38
+ exports.CompleteProfileForm = CompleteProfileForm;
@@ -0,0 +1,32 @@
1
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
2
+
3
+ //#region src/components/CompleteProfileForm.d.ts
4
+ interface CompleteProfileFormProps {
5
+ onSubmit: (name: string) => Promise<void>;
6
+ /** The host's server-enforced display name limit. */
7
+ maxDisplayNameLength: number;
8
+ isLoading: boolean;
9
+ error: string | null;
10
+ /** Address the account was created with, shown so the user knows who they are. */
11
+ email?: string | null;
12
+ /** Prefill, when some provider supplied a partial name. */
13
+ defaultName?: string | null;
14
+ }
15
+ /**
16
+ * Asks for the one thing a magic link cannot tell us.
17
+ *
18
+ * An emailed link proves an address and nothing else, so an account created
19
+ * that way has no name to greet anyone by. This is the step that fills the gap,
20
+ * and it sits *before* the post-sign-in redirect — once the Chrome extension has
21
+ * its authorization code the sign-in is over and there is nowhere left to ask.
22
+ */
23
+ declare function CompleteProfileForm({
24
+ onSubmit,
25
+ maxDisplayNameLength,
26
+ isLoading,
27
+ error,
28
+ email,
29
+ defaultName
30
+ }: CompleteProfileFormProps): react_jsx_runtime2.JSX.Element;
31
+ //#endregion
32
+ export { CompleteProfileForm, CompleteProfileFormProps };
@@ -0,0 +1,32 @@
1
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
2
+
3
+ //#region src/components/CompleteProfileForm.d.ts
4
+ interface CompleteProfileFormProps {
5
+ onSubmit: (name: string) => Promise<void>;
6
+ /** The host's server-enforced display name limit. */
7
+ maxDisplayNameLength: number;
8
+ isLoading: boolean;
9
+ error: string | null;
10
+ /** Address the account was created with, shown so the user knows who they are. */
11
+ email?: string | null;
12
+ /** Prefill, when some provider supplied a partial name. */
13
+ defaultName?: string | null;
14
+ }
15
+ /**
16
+ * Asks for the one thing a magic link cannot tell us.
17
+ *
18
+ * An emailed link proves an address and nothing else, so an account created
19
+ * that way has no name to greet anyone by. This is the step that fills the gap,
20
+ * and it sits *before* the post-sign-in redirect — once the Chrome extension has
21
+ * its authorization code the sign-in is over and there is nowhere left to ask.
22
+ */
23
+ declare function CompleteProfileForm({
24
+ onSubmit,
25
+ maxDisplayNameLength,
26
+ isLoading,
27
+ error,
28
+ email,
29
+ defaultName
30
+ }: CompleteProfileFormProps): react_jsx_runtime2.JSX.Element;
31
+ //#endregion
32
+ export { CompleteProfileForm, CompleteProfileFormProps };
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+
3
+
4
+ import { useAuthPendingState } from "./auth-pending/auth-pending-context.js";
5
+ import { AuthPendingProvider } from "./auth-pending/AuthPendingProvider.js";
6
+ import { AuthCard } from "./AuthCard.js";
7
+ import { CompleteProfileFields } from "./forms/CompleteProfileFields.js";
8
+ import { jsx } from "react/jsx-runtime";
9
+
10
+ //#region src/components/CompleteProfileForm.tsx
11
+ /**
12
+ * Asks for the one thing a magic link cannot tell us.
13
+ *
14
+ * An emailed link proves an address and nothing else, so an account created
15
+ * that way has no name to greet anyone by. This is the step that fills the gap,
16
+ * and it sits *before* the post-sign-in redirect — once the Chrome extension has
17
+ * its authorization code the sign-in is over and there is nowhere left to ask.
18
+ */
19
+ function CompleteProfileForm({ onSubmit, maxDisplayNameLength, isLoading, error, email, defaultName }) {
20
+ return /* @__PURE__ */ jsx(AuthPendingProvider, {
21
+ value: useAuthPendingState(isLoading),
22
+ children: /* @__PURE__ */ jsx(AuthCard, {
23
+ title: "What should we call you?",
24
+ description: email != null && email.length > 0 ? `Finishing sign-in for ${email}.` : "One last step before you continue.",
25
+ error,
26
+ children: /* @__PURE__ */ jsx(CompleteProfileFields, {
27
+ onSubmit,
28
+ maxDisplayNameLength,
29
+ defaultName
30
+ })
31
+ })
32
+ });
33
+ }
34
+
35
+ //#endregion
36
+ export { CompleteProfileForm };
@@ -0,0 +1,181 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_auth_pending_context = require('./auth-pending/auth-pending-context.cjs');
6
+ const require_AuthButton = require('./auth-pending/AuthButton.cjs');
7
+ const require_AuthPendingProvider = require('./auth-pending/AuthPendingProvider.cjs');
8
+ const require_AuthCard = require('./AuthCard.cjs');
9
+ const require_validation = require('../constants/validation.cjs');
10
+ const require_EmailOtpCodeForm = require('./forms/EmailOtpCodeForm.cjs');
11
+ const require_EmailRequestForm = require('./forms/EmailRequestForm.cjs');
12
+ const require_ProviderSignInButtons = require('./ProviderSignInButtons.cjs');
13
+ let react = require("react");
14
+ react = require_rolldown_runtime.__toESM(react);
15
+ let react_jsx_runtime = require("react/jsx-runtime");
16
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
17
+ let __wordrhyme_shadcn = require("@wordrhyme/shadcn");
18
+ __wordrhyme_shadcn = require_rolldown_runtime.__toESM(__wordrhyme_shadcn);
19
+ let lucide_react = require("lucide-react");
20
+ lucide_react = require_rolldown_runtime.__toESM(lucide_react);
21
+
22
+ //#region src/components/EmailOtpForm.tsx
23
+ /**
24
+ * Seconds before "Send a new code" becomes available again. Shorter than the
25
+ * code's own lifetime on purpose — this exists to stop a double-click emailing
26
+ * two codes (the second silently invalidating the first), not to ration them.
27
+ */
28
+ const RESEND_COOLDOWN_SECONDS = 60;
29
+ /** How long the emailed code lasts, for the copy only. Supabase enforces it. */
30
+ const DEFAULT_EXPIRY_MINUTES = 60;
31
+ const MS_PER_SECOND = 1e3;
32
+ /** Key for the "send a new code" button, so only it spins while resending. */
33
+ const RESEND_ACTION = "resend";
34
+ /**
35
+ * The second step: the code itself.
36
+ *
37
+ * Its own component so the parent can mount it under `key={sentTo}` — a new
38
+ * address, or a resent code, then starts with an empty field and a fresh
39
+ * cooldown without an effect reaching in to reset either.
40
+ */
41
+ function CodeEntryStep({ sentTo, onVerifyEmailOtp, onResend, error, expiryMinutes, onUseDifferentEmail, onSwitchToSignIn }) {
42
+ const [resendIn, setResendIn] = (0, react.useState)(RESEND_COOLDOWN_SECONDS);
43
+ (0, react.useEffect)(() => {
44
+ if (resendIn <= 0) return;
45
+ const timer = setTimeout(() => setResendIn((seconds) => seconds - 1), MS_PER_SECOND);
46
+ return () => clearTimeout(timer);
47
+ }, [resendIn]);
48
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_AuthCard.AuthCard, {
49
+ title: "Enter your code",
50
+ error,
51
+ children: [
52
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
53
+ className: "mb-4 flex flex-col items-center gap-3 text-center",
54
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.MailCheck, {
55
+ className: "text-primary h-10 w-10",
56
+ "aria-hidden": "true"
57
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
58
+ className: "text-sm",
59
+ children: [
60
+ "We sent a ",
61
+ require_validation.OTP_LENGTH,
62
+ "-digit code to",
63
+ " ",
64
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
65
+ className: "font-medium",
66
+ children: sentTo
67
+ }),
68
+ "."
69
+ ]
70
+ })]
71
+ }),
72
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmailOtpCodeForm.EmailOtpCodeForm, {
73
+ sentTo,
74
+ onVerifyEmailOtp,
75
+ expiryMinutes
76
+ }),
77
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Separator, { className: "my-4" }),
78
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
79
+ className: "space-y-2 text-center text-sm",
80
+ children: [
81
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
82
+ variant: "link",
83
+ size: "sm",
84
+ actionKey: RESEND_ACTION,
85
+ onAction: async () => onResend(sentTo),
86
+ disabled: resendIn > 0,
87
+ className: "h-auto p-0",
88
+ children: resendIn > 0 ? `Send a new code in ${resendIn}s` : "Send a new code"
89
+ }) }),
90
+ onUseDifferentEmail && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
91
+ variant: "link",
92
+ size: "sm",
93
+ onClick: onUseDifferentEmail,
94
+ className: "h-auto p-0",
95
+ children: "Use a different email"
96
+ }) }),
97
+ onSwitchToSignIn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
98
+ variant: "link",
99
+ size: "sm",
100
+ onClick: onSwitchToSignIn,
101
+ className: "h-auto p-0",
102
+ children: "Back to sign in"
103
+ }) })
104
+ ]
105
+ })
106
+ ]
107
+ });
108
+ }
109
+ /**
110
+ * Passwordless sign-in with a code typed back into this page.
111
+ *
112
+ * Two steps in one component, because they are one flow: collect an address,
113
+ * then collect the code that address received. Keeping both here is what lets
114
+ * "use a different email" and "send a new code" stay a single decision the
115
+ * user makes in one place.
116
+ *
117
+ * Doubles as sign-up — an unknown address gets an account — so it carries the
118
+ * same Terms line the password sign-up form does.
119
+ */
120
+ function EmailOtpForm({ onSendEmailOtp, onVerifyEmailOtp, onGoogleSignIn, onLinkedInSignIn, isLoading, error, sentTo, onUseDifferentEmail, onSwitchToSignIn, expiryMinutes = DEFAULT_EXPIRY_MINUTES, privacyPolicyUrl = "/privacy", privacyNotice, termsUrl = "/terms" }) {
121
+ /**
122
+ * Bumped on every resend. Part of the code step's `key`, so a fresh code
123
+ * gets a fresh field and cooldown even though `sentTo` has not changed.
124
+ */
125
+ const [resendCount, setResendCount] = (0, react.useState)(0);
126
+ const pending = require_auth_pending_context.useAuthPendingState(isLoading);
127
+ const handleResend = async (address) => {
128
+ setResendCount((count) => count + 1);
129
+ return onSendEmailOtp(address);
130
+ };
131
+ if (sentTo != null && sentTo.length > 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthPendingProvider.AuthPendingProvider, {
132
+ value: pending,
133
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeEntryStep, {
134
+ sentTo,
135
+ onVerifyEmailOtp,
136
+ onResend: handleResend,
137
+ error,
138
+ expiryMinutes,
139
+ onUseDifferentEmail,
140
+ onSwitchToSignIn
141
+ }, `${sentTo}:${resendCount}`)
142
+ });
143
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthPendingProvider.AuthPendingProvider, {
144
+ value: pending,
145
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_AuthCard.AuthCard, {
146
+ title: "Sign in with email",
147
+ description: "No password needed — we'll email you a single-use code.",
148
+ error,
149
+ children: [
150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmailRequestForm.EmailRequestForm, {
151
+ fieldId: "email-otp-email",
152
+ onSubmitEmail: onSendEmailOtp,
153
+ submitLabel: "Email me a sign-in code",
154
+ submittingLabel: "Sending code...",
155
+ termsUrl,
156
+ privacyPolicyUrl,
157
+ privacyNotice
158
+ }),
159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ProviderSignInButtons.ProviderSignInButtons, {
160
+ onGoogleSignIn,
161
+ onLinkedInSignIn,
162
+ action: "Sign in"
163
+ }),
164
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "my-4" }),
165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
166
+ className: "text-center text-sm",
167
+ children: onSwitchToSignIn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
168
+ variant: "link",
169
+ size: "sm",
170
+ onClick: onSwitchToSignIn,
171
+ className: "h-auto p-0",
172
+ children: "Sign in with a password instead"
173
+ }) })
174
+ })
175
+ ]
176
+ })
177
+ });
178
+ }
179
+
180
+ //#endregion
181
+ exports.EmailOtpForm = EmailOtpForm;
@@ -0,0 +1,56 @@
1
+ import { ProviderSignInHandlers } from "./ProviderSignInButtons.cjs";
2
+ import React from "react";
3
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
4
+
5
+ //#region src/components/EmailOtpForm.d.ts
6
+ interface EmailOtpFormProps extends ProviderSignInHandlers {
7
+ /** Emails a fresh code to this address. */
8
+ onSendEmailOtp: (email: string) => Promise<void>;
9
+ /** Verifies a typed code. Signs the user in and redirects on success. */
10
+ onVerifyEmailOtp: (email: string, code: string) => Promise<void>;
11
+ isLoading: boolean;
12
+ error: string | null;
13
+ /**
14
+ * The address a code was just sent to, or `null` while the form is still
15
+ * collecting one. Controlled by the host: only it knows whether the server
16
+ * action succeeded, since a failed send reports through `error` rather than
17
+ * by rejecting.
18
+ */
19
+ sentTo?: string | null;
20
+ /** Returns to the collect-an-address state, e.g. after a typo. */
21
+ onUseDifferentEmail?: () => void;
22
+ onSwitchToSignIn?: () => void;
23
+ /** Stated code lifetime, in minutes. Match Supabase's `otp_expiry`. */
24
+ expiryMinutes?: number;
25
+ privacyPolicyUrl?: string;
26
+ privacyNotice?: React.ReactNode;
27
+ termsUrl?: string;
28
+ }
29
+ /**
30
+ * Passwordless sign-in with a code typed back into this page.
31
+ *
32
+ * Two steps in one component, because they are one flow: collect an address,
33
+ * then collect the code that address received. Keeping both here is what lets
34
+ * "use a different email" and "send a new code" stay a single decision the
35
+ * user makes in one place.
36
+ *
37
+ * Doubles as sign-up — an unknown address gets an account — so it carries the
38
+ * same Terms line the password sign-up form does.
39
+ */
40
+ declare function EmailOtpForm({
41
+ onSendEmailOtp,
42
+ onVerifyEmailOtp,
43
+ onGoogleSignIn,
44
+ onLinkedInSignIn,
45
+ isLoading,
46
+ error,
47
+ sentTo,
48
+ onUseDifferentEmail,
49
+ onSwitchToSignIn,
50
+ expiryMinutes,
51
+ privacyPolicyUrl,
52
+ privacyNotice,
53
+ termsUrl
54
+ }: EmailOtpFormProps): react_jsx_runtime3.JSX.Element;
55
+ //#endregion
56
+ export { EmailOtpForm, EmailOtpFormProps };
@@ -0,0 +1,56 @@
1
+ import { ProviderSignInHandlers } from "./ProviderSignInButtons.js";
2
+ import React from "react";
3
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
4
+
5
+ //#region src/components/EmailOtpForm.d.ts
6
+ interface EmailOtpFormProps extends ProviderSignInHandlers {
7
+ /** Emails a fresh code to this address. */
8
+ onSendEmailOtp: (email: string) => Promise<void>;
9
+ /** Verifies a typed code. Signs the user in and redirects on success. */
10
+ onVerifyEmailOtp: (email: string, code: string) => Promise<void>;
11
+ isLoading: boolean;
12
+ error: string | null;
13
+ /**
14
+ * The address a code was just sent to, or `null` while the form is still
15
+ * collecting one. Controlled by the host: only it knows whether the server
16
+ * action succeeded, since a failed send reports through `error` rather than
17
+ * by rejecting.
18
+ */
19
+ sentTo?: string | null;
20
+ /** Returns to the collect-an-address state, e.g. after a typo. */
21
+ onUseDifferentEmail?: () => void;
22
+ onSwitchToSignIn?: () => void;
23
+ /** Stated code lifetime, in minutes. Match Supabase's `otp_expiry`. */
24
+ expiryMinutes?: number;
25
+ privacyPolicyUrl?: string;
26
+ privacyNotice?: React.ReactNode;
27
+ termsUrl?: string;
28
+ }
29
+ /**
30
+ * Passwordless sign-in with a code typed back into this page.
31
+ *
32
+ * Two steps in one component, because they are one flow: collect an address,
33
+ * then collect the code that address received. Keeping both here is what lets
34
+ * "use a different email" and "send a new code" stay a single decision the
35
+ * user makes in one place.
36
+ *
37
+ * Doubles as sign-up — an unknown address gets an account — so it carries the
38
+ * same Terms line the password sign-up form does.
39
+ */
40
+ declare function EmailOtpForm({
41
+ onSendEmailOtp,
42
+ onVerifyEmailOtp,
43
+ onGoogleSignIn,
44
+ onLinkedInSignIn,
45
+ isLoading,
46
+ error,
47
+ sentTo,
48
+ onUseDifferentEmail,
49
+ onSwitchToSignIn,
50
+ expiryMinutes,
51
+ privacyPolicyUrl,
52
+ privacyNotice,
53
+ termsUrl
54
+ }: EmailOtpFormProps): react_jsx_runtime3.JSX.Element;
55
+ //#endregion
56
+ export { EmailOtpForm, EmailOtpFormProps };