@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
package/README.md CHANGED
@@ -1,3 +1,156 @@
1
1
  # @wordrhyme/shadcn-auth
2
2
 
3
- ## Usage Add usage instructions here.
3
+ Reusable auth screens: sign in, sign up, passwordless sign-in, password reset,
4
+ profile completion, and the signed-in account's sign-in-methods list.
5
+
6
+ Presentation only. Every component takes handlers, controlled state, and any
7
+ server-owned rule it needs from the host. The package does not depend on an auth
8
+ backend, tRPC client, server action, router, or toast. The same components cover
9
+ a password-only app and one with Google, LinkedIn, and magic links.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pnpm add @wordrhyme/shadcn-auth
15
+ ```
16
+
17
+ Peers: `react` / `react-dom` 18 or 19. Styling comes from `@wordrhyme/shadcn`, so
18
+ the host must already load that Tailwind layer.
19
+
20
+ ## Usage
21
+
22
+ `AuthForms` is the whole screen, including switching between steps:
23
+
24
+ ```tsx
25
+ 'use client';
26
+
27
+ import { AuthForms } from '@wordrhyme/shadcn-auth';
28
+
29
+ export function LoginClient() {
30
+ const [isLoading, setIsLoading] = useState(false);
31
+ const [error, setError] = useState<string | null>(null);
32
+ const [magicLinkSentTo, setMagicLinkSentTo] = useState<string | null>(null);
33
+
34
+ return (
35
+ <AuthForms
36
+ onSignIn={handleSignIn}
37
+ onSignUp={handleSignUp}
38
+ onSendMagicLink={handleSendMagicLink} // omit to hide the passwordless step
39
+ onGoogleSignIn={handleGoogleSignIn} // omit to hide the Google button
40
+ onLinkedInSignIn={handleLinkedInSignIn} // omit to hide the LinkedIn button
41
+ isLoading={isLoading}
42
+ error={error}
43
+ magicLinkSentTo={magicLinkSentTo}
44
+ onModeChange={() => {
45
+ setError(null);
46
+ setMagicLinkSentTo(null);
47
+ }}
48
+ />
49
+ );
50
+ }
51
+ ```
52
+
53
+ Or compose the steps yourself — `SignInForm`, `SignUpForm`, `MagicLinkForm`,
54
+ `ResetPasswordForm` and `CompleteProfileForm` are all exported and usable alone.
55
+
56
+ `CompleteProfileForm` requires the host's server-enforced display-name limit:
57
+
58
+ ```tsx
59
+ import { CompleteProfileForm } from '@wordrhyme/shadcn-auth';
60
+
61
+ <CompleteProfileForm
62
+ onSubmit={handleCompleteProfile}
63
+ maxDisplayNameLength={displayNameLimit}
64
+ isLoading={isLoading}
65
+ error={error}
66
+ />;
67
+ ```
68
+
69
+ Pass the same limit to `CompleteProfileFields` when composing that field directly.
70
+
71
+ `SignInMethods` is the signed-in counterpart: what the account can sign in with
72
+ today, and what it could add. Use `SignInMethodsList` when the host supplies its
73
+ own section heading or card:
74
+
75
+ ```tsx
76
+ import { SignInMethods } from '@wordrhyme/shadcn-auth';
77
+
78
+ <SignInMethods
79
+ identities={identities} // each item needs only provider and email
80
+ linkableProviders={['google']} // a provider already linked is filtered out
81
+ isLoading={isLoading}
82
+ pendingProvider={pendingProvider} // the one mid-flow, or null
83
+ error={error}
84
+ notice={notice}
85
+ onConnect={handleConnect}
86
+ />;
87
+ ```
88
+
89
+ Adding GitHub or LinkedIn later is one more entry in `linkableProviders`:
90
+ labels come from `describeAuthProvider` and marks from `ProviderIcon`, both of
91
+ which fall back sensibly for a provider they have never heard of.
92
+ `identities` accepts objects with `{ provider: string, email: string | null }`;
93
+ the host may pass richer identity objects without adapting them.
94
+
95
+ ## Who owns what state
96
+
97
+ `isLoading`, `error` and `magicLinkSentTo` are **controlled by the host**, and
98
+ deliberately so. The auth server actions return their failures rather than
99
+ throwing — Next.js replaces the message of any error that escapes a Server
100
+ Action with an opaque digest in production — so a resolved promise tells the
101
+ form nothing about whether the call succeeded. Only the caller knows.
102
+
103
+ That is why `MagicLinkForm` needs `sentTo` rather than flipping to its receipt
104
+ state on its own.
105
+
106
+ `onModeChange` fires on every step change, including "use a different email"
107
+ returning to the step it is already on. Use it to clear both `error` and
108
+ `magicLinkSentTo`.
109
+
110
+ ### Which button spins
111
+
112
+ `isLoading` says that _something_ is happening; it cannot say which button the
113
+ user pressed. So it disables the card and spins nothing.
114
+
115
+ The spinner is owned per card instead. `useAuthPendingState` creates one pending
116
+ scope, `AuthPendingProvider` shares it, and every `AuthButton` on the card takes
117
+ its `loading` and `disabled` from it: the button whose `actionKey` is running is
118
+ the only one that spins, and everything else goes disabled until it settles.
119
+ Clicking "Sign in with Google" therefore spins the Google button alone, rather
120
+ than lighting up LinkedIn and the submit button with it.
121
+
122
+ Hosts get this for free — the cards wire it themselves. It only matters if you
123
+ compose `ProviderSignInButtons` or `AuthButton` into a card of your own, in
124
+ which case create the scope with `useAuthPendingState(isLoading)` and provide
125
+ it.
126
+
127
+ ## Components
128
+
129
+ | Component | For |
130
+ | ----------------------- | ------------------------------------------------------------------ |
131
+ | `AuthForms` | The whole screen and the switching between steps |
132
+ | `SignInForm` | Email + password, with provider buttons and the passwordless link |
133
+ | `SignUpForm` | Registration, including the Terms checkbox and the privacy notice |
134
+ | `MagicLinkForm` | Request a link; shows the receipt once `sentTo` is set |
135
+ | `ResetPasswordForm` | Request a password-reset email |
136
+ | `CompleteProfileForm` | Collect the display name a magic link could not supply |
137
+ | `ProviderSignInButtons` | Google / LinkedIn buttons plus the "or continue with" rule |
138
+ | `AuthButton` | A button wired to its card's pending scope (see above) |
139
+ | `AuthField` | A labelled input with its validation message |
140
+ | `SignInMethods` | The signed-in account's sign-in methods, and what it can connect |
141
+ | `SignInMethodRow` | One method: its mark, its account, and Connected / Connect |
142
+ | `ProviderIcon` | The mark for a provider key, with a generic fallback |
143
+ | `AuthCard` | The shared card frame: heading, optional description, error banner |
144
+ | `LegalNotice` | The privacy notice shown wherever an account can be created |
145
+
146
+ ## Validation
147
+
148
+ The forms validate before calling your handler and render their own messages,
149
+ which is why every `<form>` here is `noValidate`. The fields keep their `type`
150
+ and `required` attributes for assistive technology and mobile keyboards, but the
151
+ native validation bubble is off: it would otherwise pre-empt the first error,
152
+ and none of the other messages on these forms (password length, consent, name
153
+ length) have a native equivalent to match.
154
+
155
+ These checks are a courtesy, not a boundary. The host must enforce its own
156
+ validation server-side and pass matching limits where the UI requests them.
@@ -0,0 +1,45 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
7
+ let __wordrhyme_shadcn = require("@wordrhyme/shadcn");
8
+ __wordrhyme_shadcn = require_rolldown_runtime.__toESM(__wordrhyme_shadcn);
9
+
10
+ //#region src/components/AuthCard.tsx
11
+ /**
12
+ * The frame every auth step shares: one card, one heading, one error slot.
13
+ *
14
+ * Having a single owner for the error banner is the point — each form used to
15
+ * repeat the same `error != null && error.trim() !== ''` dance, which is exactly
16
+ * the kind of thing that quietly diverges between screens.
17
+ */
18
+ function AuthCard({ title, description, error, children, className }) {
19
+ const hasError = error != null && error.trim() !== "";
20
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Card, {
21
+ className: `mx-auto w-full max-w-md pb-3 ${className ?? ""}`,
22
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.CardContent, {
23
+ className: "p-6 py-2 pb-0",
24
+ children: [
25
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
26
+ className: "mb-4 text-center text-2xl font-bold",
27
+ children: title
28
+ }),
29
+ description != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
30
+ className: "text-muted-foreground mb-4 text-center text-sm",
31
+ children: description
32
+ }),
33
+ hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Alert, {
34
+ variant: "destructive",
35
+ className: "mb-4",
36
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.AlertDescription, { children: error })
37
+ }),
38
+ children
39
+ ]
40
+ })
41
+ });
42
+ }
43
+
44
+ //#endregion
45
+ exports.AuthCard = AuthCard;
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/components/AuthCard.d.ts
5
+ interface AuthCardProps {
6
+ /** Heading for the step, e.g. "Sign In". */
7
+ title: string;
8
+ /** Optional line under the heading explaining what happens next. */
9
+ description?: React.ReactNode;
10
+ /** Server-supplied failure copy. Blank and `null` both render nothing. */
11
+ error?: string | null;
12
+ children: React.ReactNode;
13
+ className?: string;
14
+ }
15
+ /**
16
+ * The frame every auth step shares: one card, one heading, one error slot.
17
+ *
18
+ * Having a single owner for the error banner is the point — each form used to
19
+ * repeat the same `error != null && error.trim() !== ''` dance, which is exactly
20
+ * the kind of thing that quietly diverges between screens.
21
+ */
22
+ declare function AuthCard({
23
+ title,
24
+ description,
25
+ error,
26
+ children,
27
+ className
28
+ }: AuthCardProps): react_jsx_runtime0.JSX.Element;
29
+ //#endregion
30
+ export { AuthCard, AuthCardProps };
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/components/AuthCard.d.ts
5
+ interface AuthCardProps {
6
+ /** Heading for the step, e.g. "Sign In". */
7
+ title: string;
8
+ /** Optional line under the heading explaining what happens next. */
9
+ description?: React.ReactNode;
10
+ /** Server-supplied failure copy. Blank and `null` both render nothing. */
11
+ error?: string | null;
12
+ children: React.ReactNode;
13
+ className?: string;
14
+ }
15
+ /**
16
+ * The frame every auth step shares: one card, one heading, one error slot.
17
+ *
18
+ * Having a single owner for the error banner is the point — each form used to
19
+ * repeat the same `error != null && error.trim() !== ''` dance, which is exactly
20
+ * the kind of thing that quietly diverges between screens.
21
+ */
22
+ declare function AuthCard({
23
+ title,
24
+ description,
25
+ error,
26
+ children,
27
+ className
28
+ }: AuthCardProps): react_jsx_runtime0.JSX.Element;
29
+ //#endregion
30
+ export { AuthCard, AuthCardProps };
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+
3
+
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Alert, AlertDescription, Card, CardContent } from "@wordrhyme/shadcn";
6
+
7
+ //#region src/components/AuthCard.tsx
8
+ /**
9
+ * The frame every auth step shares: one card, one heading, one error slot.
10
+ *
11
+ * Having a single owner for the error banner is the point — each form used to
12
+ * repeat the same `error != null && error.trim() !== ''` dance, which is exactly
13
+ * the kind of thing that quietly diverges between screens.
14
+ */
15
+ function AuthCard({ title, description, error, children, className }) {
16
+ const hasError = error != null && error.trim() !== "";
17
+ return /* @__PURE__ */ jsx(Card, {
18
+ className: `mx-auto w-full max-w-md pb-3 ${className ?? ""}`,
19
+ children: /* @__PURE__ */ jsxs(CardContent, {
20
+ className: "p-6 py-2 pb-0",
21
+ children: [
22
+ /* @__PURE__ */ jsx("h2", {
23
+ className: "mb-4 text-center text-2xl font-bold",
24
+ children: title
25
+ }),
26
+ description != null && /* @__PURE__ */ jsx("p", {
27
+ className: "text-muted-foreground mb-4 text-center text-sm",
28
+ children: description
29
+ }),
30
+ hasError && /* @__PURE__ */ jsx(Alert, {
31
+ variant: "destructive",
32
+ className: "mb-4",
33
+ children: /* @__PURE__ */ jsx(AlertDescription, { children: error })
34
+ }),
35
+ children
36
+ ]
37
+ })
38
+ });
39
+ }
40
+
41
+ //#endregion
42
+ export { AuthCard };
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_EmailOtpForm = require('./EmailOtpForm.cjs');
6
+ const require_MagicLinkForm = require('./MagicLinkForm.cjs');
7
+ const require_ResetPasswordForm = require('./ResetPasswordForm.cjs');
8
+ const require_SignInForm = require('./SignInForm.cjs');
9
+ const require_SignUpForm = require('./SignUpForm.cjs');
10
+ let react = require("react");
11
+ react = require_rolldown_runtime.__toESM(react);
12
+ let react_jsx_runtime = require("react/jsx-runtime");
13
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
14
+
15
+ //#region src/components/AuthForms.tsx
16
+ /**
17
+ * The whole signed-out screen: every step, and the switching between them.
18
+ *
19
+ * Steps appear only when the host passed a handler for them, so this same
20
+ * component covers a password-only app and one with OAuth plus magic links
21
+ * without any configuration flags of its own.
22
+ */
23
+ 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 }) {
24
+ const [mode, setMode] = (0, react.useState)(initialMode);
25
+ const emailPasswordAuthEnabled = onSignIn != null && onSignUp != null;
26
+ const switchTo = (next) => () => {
27
+ setMode(next);
28
+ onModeChange?.(next);
29
+ };
30
+ const providers = {
31
+ onGoogleSignIn,
32
+ onLinkedInSignIn
33
+ };
34
+ const emailOtpEnabled = onSendEmailOtp != null && onVerifyEmailOtp != null;
35
+ const emailOtpSwitch = emailOtpEnabled ? switchTo("email-otp") : void 0;
36
+ const magicLinkSwitch = emailOtpEnabled || onSendMagicLink == null ? void 0 : switchTo("magic-link");
37
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
38
+ className: "flex min-h-screen items-center justify-center p-4",
39
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
40
+ className: "w-full max-w-md",
41
+ children: [
42
+ title != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
43
+ className: "mb-6 text-center text-3xl font-bold",
44
+ children: title
45
+ }),
46
+ mode === "signin" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SignInForm.SignInForm, {
47
+ ...providers,
48
+ onSignIn,
49
+ credentialsDisclosureLabel,
50
+ isLoading,
51
+ error,
52
+ onSwitchToSignUp: emailPasswordAuthEnabled ? switchTo("signup") : void 0,
53
+ onSwitchToReset: emailPasswordAuthEnabled && onResetPassword != null ? switchTo("reset") : void 0,
54
+ onSwitchToMagicLink: magicLinkSwitch,
55
+ onSwitchToEmailOtp: emailOtpSwitch
56
+ }),
57
+ mode === "signup" && emailPasswordAuthEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SignUpForm.SignUpForm, {
58
+ ...providers,
59
+ onSignUp,
60
+ isLoading,
61
+ error,
62
+ sentTo: signupConfirmationSentTo,
63
+ onSwitchToSignIn: switchTo("signin"),
64
+ onSwitchToMagicLink: magicLinkSwitch,
65
+ onSwitchToEmailOtp: emailOtpSwitch,
66
+ privacyPolicyUrl,
67
+ privacyNotice,
68
+ termsUrl,
69
+ minimumAge,
70
+ onConsentGiven
71
+ }),
72
+ mode === "reset" && onResetPassword != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ResetPasswordForm.ResetPasswordForm, {
73
+ onResetPassword,
74
+ isLoading,
75
+ error,
76
+ sentTo: resetPasswordSentTo,
77
+ onSwitchToSignIn: switchTo("signin")
78
+ }),
79
+ mode === "magic-link" && onSendMagicLink != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MagicLinkForm.MagicLinkForm, {
80
+ ...providers,
81
+ onSendMagicLink,
82
+ isLoading,
83
+ error,
84
+ sentTo: magicLinkSentTo,
85
+ onUseDifferentEmail: switchTo("magic-link"),
86
+ onSwitchToSignIn: switchTo("signin"),
87
+ privacyPolicyUrl,
88
+ privacyNotice,
89
+ termsUrl
90
+ }),
91
+ mode === "email-otp" && emailOtpEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmailOtpForm.EmailOtpForm, {
92
+ ...providers,
93
+ onSendEmailOtp,
94
+ onVerifyEmailOtp,
95
+ isLoading,
96
+ error,
97
+ sentTo: emailOtpSentTo,
98
+ expiryMinutes: emailOtpExpiryMinutes,
99
+ onUseDifferentEmail: switchTo("email-otp"),
100
+ onSwitchToSignIn: emailPasswordAuthEnabled ? switchTo("signin") : void 0,
101
+ privacyPolicyUrl,
102
+ privacyNotice,
103
+ termsUrl
104
+ }),
105
+ footer != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
106
+ className: "text-muted-foreground mt-6 flex items-center justify-center gap-3 text-sm",
107
+ children: footer
108
+ })
109
+ ]
110
+ })
111
+ });
112
+ }
113
+
114
+ //#endregion
115
+ exports.AuthForms = AuthForms;
@@ -0,0 +1,95 @@
1
+ import { ProviderSignInHandlers } from "./ProviderSignInButtons.cjs";
2
+ import React from "react";
3
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
4
+
5
+ //#region src/components/AuthForms.d.ts
6
+ /** Steps the screen can show. Which are reachable depends on the handlers given. */
7
+ type AuthMode = 'signin' | 'signup' | 'reset' | 'magic-link' | 'email-otp';
8
+ interface AuthFormsProps extends ProviderSignInHandlers {
9
+ /** Pass both credential handlers to enable email/password authentication. */
10
+ onSignIn?: (email: string, password: string) => Promise<void>;
11
+ onSignUp?: (email: string, password: string) => Promise<void>;
12
+ /**
13
+ * Hides the sign-in credential fields behind a link carrying this label. Only
14
+ * affects the sign-in step; see `SignInForm` for when that is worth doing.
15
+ */
16
+ credentialsDisclosureLabel?: string;
17
+ /** Enables the "Forgot your password?" step. Omit to hide it. */
18
+ onResetPassword?: (email: string) => Promise<void>;
19
+ /** Enables the passwordless step. Omit to hide it. */
20
+ onSendMagicLink?: (email: string) => Promise<void>;
21
+ /**
22
+ * Pass both to enable the emailed-code step. It is offered ahead of the
23
+ * magic link when the host wires both, since the two share one Supabase
24
+ * template and only one of them can be what the mail actually carries.
25
+ */
26
+ onSendEmailOtp?: (email: string) => Promise<void>;
27
+ onVerifyEmailOtp?: (email: string, code: string) => Promise<void>;
28
+ isLoading: boolean;
29
+ error: string | null;
30
+ /** Address a magic link was just sent to; switches that step to its receipt. */
31
+ magicLinkSentTo?: string | null;
32
+ /** Address a sign-in code was just sent to; switches that step to code entry. */
33
+ emailOtpSentTo?: string | null;
34
+ /** Stated lifetime of an emailed code, in minutes. Match Supabase's `otp_expiry`. */
35
+ emailOtpExpiryMinutes?: number;
36
+ /** Address a recovery link was just sent to; switches that step to its receipt. */
37
+ resetPasswordSentTo?: string | null;
38
+ /** Address a signup confirmation was just sent to; switches that step to its receipt. */
39
+ signupConfirmationSentTo?: string | null;
40
+ /** Step to open on. Default `'signin'`. */
41
+ initialMode?: AuthMode;
42
+ /**
43
+ * Fired on every step change, including "use a different email" returning to
44
+ * the passwordless step it is already on. Hosts use it to reset the state
45
+ * they own — the error banner and `magicLinkSentTo` — since copy from the
46
+ * step you just left has no business on the next one.
47
+ */
48
+ onModeChange?: (mode: AuthMode) => void;
49
+ /** Product name or logo shown above the card. */
50
+ title?: React.ReactNode;
51
+ /** Optional legal or support links shown below the active form. */
52
+ footer?: React.ReactNode;
53
+ privacyPolicyUrl?: string;
54
+ /** Notice shown on every account-creation path; include a policy link in the node. */
55
+ privacyNotice?: React.ReactNode;
56
+ termsUrl?: string;
57
+ minimumAge?: number;
58
+ onConsentGiven?: () => void;
59
+ }
60
+ /**
61
+ * The whole signed-out screen: every step, and the switching between them.
62
+ *
63
+ * Steps appear only when the host passed a handler for them, so this same
64
+ * component covers a password-only app and one with OAuth plus magic links
65
+ * without any configuration flags of its own.
66
+ */
67
+ declare function AuthForms({
68
+ onSignIn,
69
+ onSignUp,
70
+ credentialsDisclosureLabel,
71
+ onResetPassword,
72
+ onSendMagicLink,
73
+ onSendEmailOtp,
74
+ onVerifyEmailOtp,
75
+ onGoogleSignIn,
76
+ onLinkedInSignIn,
77
+ isLoading,
78
+ error,
79
+ magicLinkSentTo,
80
+ emailOtpSentTo,
81
+ emailOtpExpiryMinutes,
82
+ resetPasswordSentTo,
83
+ signupConfirmationSentTo,
84
+ initialMode,
85
+ onModeChange,
86
+ title,
87
+ footer,
88
+ privacyPolicyUrl,
89
+ privacyNotice,
90
+ termsUrl,
91
+ minimumAge,
92
+ onConsentGiven
93
+ }: AuthFormsProps): react_jsx_runtime1.JSX.Element;
94
+ //#endregion
95
+ export { AuthForms, AuthFormsProps, AuthMode };
@@ -0,0 +1,95 @@
1
+ import { ProviderSignInHandlers } from "./ProviderSignInButtons.js";
2
+ import React from "react";
3
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
4
+
5
+ //#region src/components/AuthForms.d.ts
6
+ /** Steps the screen can show. Which are reachable depends on the handlers given. */
7
+ type AuthMode = 'signin' | 'signup' | 'reset' | 'magic-link' | 'email-otp';
8
+ interface AuthFormsProps extends ProviderSignInHandlers {
9
+ /** Pass both credential handlers to enable email/password authentication. */
10
+ onSignIn?: (email: string, password: string) => Promise<void>;
11
+ onSignUp?: (email: string, password: string) => Promise<void>;
12
+ /**
13
+ * Hides the sign-in credential fields behind a link carrying this label. Only
14
+ * affects the sign-in step; see `SignInForm` for when that is worth doing.
15
+ */
16
+ credentialsDisclosureLabel?: string;
17
+ /** Enables the "Forgot your password?" step. Omit to hide it. */
18
+ onResetPassword?: (email: string) => Promise<void>;
19
+ /** Enables the passwordless step. Omit to hide it. */
20
+ onSendMagicLink?: (email: string) => Promise<void>;
21
+ /**
22
+ * Pass both to enable the emailed-code step. It is offered ahead of the
23
+ * magic link when the host wires both, since the two share one Supabase
24
+ * template and only one of them can be what the mail actually carries.
25
+ */
26
+ onSendEmailOtp?: (email: string) => Promise<void>;
27
+ onVerifyEmailOtp?: (email: string, code: string) => Promise<void>;
28
+ isLoading: boolean;
29
+ error: string | null;
30
+ /** Address a magic link was just sent to; switches that step to its receipt. */
31
+ magicLinkSentTo?: string | null;
32
+ /** Address a sign-in code was just sent to; switches that step to code entry. */
33
+ emailOtpSentTo?: string | null;
34
+ /** Stated lifetime of an emailed code, in minutes. Match Supabase's `otp_expiry`. */
35
+ emailOtpExpiryMinutes?: number;
36
+ /** Address a recovery link was just sent to; switches that step to its receipt. */
37
+ resetPasswordSentTo?: string | null;
38
+ /** Address a signup confirmation was just sent to; switches that step to its receipt. */
39
+ signupConfirmationSentTo?: string | null;
40
+ /** Step to open on. Default `'signin'`. */
41
+ initialMode?: AuthMode;
42
+ /**
43
+ * Fired on every step change, including "use a different email" returning to
44
+ * the passwordless step it is already on. Hosts use it to reset the state
45
+ * they own — the error banner and `magicLinkSentTo` — since copy from the
46
+ * step you just left has no business on the next one.
47
+ */
48
+ onModeChange?: (mode: AuthMode) => void;
49
+ /** Product name or logo shown above the card. */
50
+ title?: React.ReactNode;
51
+ /** Optional legal or support links shown below the active form. */
52
+ footer?: React.ReactNode;
53
+ privacyPolicyUrl?: string;
54
+ /** Notice shown on every account-creation path; include a policy link in the node. */
55
+ privacyNotice?: React.ReactNode;
56
+ termsUrl?: string;
57
+ minimumAge?: number;
58
+ onConsentGiven?: () => void;
59
+ }
60
+ /**
61
+ * The whole signed-out screen: every step, and the switching between them.
62
+ *
63
+ * Steps appear only when the host passed a handler for them, so this same
64
+ * component covers a password-only app and one with OAuth plus magic links
65
+ * without any configuration flags of its own.
66
+ */
67
+ declare function AuthForms({
68
+ onSignIn,
69
+ onSignUp,
70
+ credentialsDisclosureLabel,
71
+ onResetPassword,
72
+ onSendMagicLink,
73
+ onSendEmailOtp,
74
+ onVerifyEmailOtp,
75
+ onGoogleSignIn,
76
+ onLinkedInSignIn,
77
+ isLoading,
78
+ error,
79
+ magicLinkSentTo,
80
+ emailOtpSentTo,
81
+ emailOtpExpiryMinutes,
82
+ resetPasswordSentTo,
83
+ signupConfirmationSentTo,
84
+ initialMode,
85
+ onModeChange,
86
+ title,
87
+ footer,
88
+ privacyPolicyUrl,
89
+ privacyNotice,
90
+ termsUrl,
91
+ minimumAge,
92
+ onConsentGiven
93
+ }: AuthFormsProps): react_jsx_runtime1.JSX.Element;
94
+ //#endregion
95
+ export { AuthForms, AuthFormsProps, AuthMode };