@wordrhyme/shadcn-auth 1.0.61 → 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 +15 -8
  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,75 @@
1
+ 'use client';
2
+
3
+
4
+ import { AUTH_SUBMIT_ACTION, useAuthPending } from "../auth-pending/auth-pending-context.js";
5
+ import { AuthButton } from "../auth-pending/AuthButton.js";
6
+ import { OTP_LENGTH } from "../../constants/validation.js";
7
+ import { AuthField } from "./AuthField.js";
8
+ import { useState } from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+
11
+ //#region src/components/forms/EmailOtpCodeForm.tsx
12
+ const DIGITS_ONLY = /^\d+$/u;
13
+ const NON_DIGITS = /\D/gu;
14
+ /** The code-entry half of the emailed-code card. */
15
+ function EmailOtpCodeForm({ sentTo, onVerifyEmailOtp, expiryMinutes }) {
16
+ const [code, setCode] = useState("");
17
+ const [codeError, setCodeError] = useState("");
18
+ const pending = useAuthPending();
19
+ const isSubmitting = pending.pendingKey === AUTH_SUBMIT_ACTION;
20
+ const handleSubmit = (e) => {
21
+ e.preventDefault();
22
+ const trimmed = code.trim();
23
+ if (trimmed.length === 0) {
24
+ setCodeError("Enter the code from your email");
25
+ return;
26
+ }
27
+ if (trimmed.length !== OTP_LENGTH || !DIGITS_ONLY.test(trimmed)) {
28
+ setCodeError(`The code is ${OTP_LENGTH} digits`);
29
+ return;
30
+ }
31
+ setCodeError("");
32
+ pending.run(AUTH_SUBMIT_ACTION, async () => onVerifyEmailOtp(sentTo, trimmed));
33
+ };
34
+ return /* @__PURE__ */ jsxs("form", {
35
+ onSubmit: handleSubmit,
36
+ className: "space-y-4",
37
+ noValidate: true,
38
+ children: [
39
+ /* @__PURE__ */ jsx(AuthField, {
40
+ id: "email-otp-code",
41
+ label: "Sign-in code",
42
+ autoComplete: "one-time-code",
43
+ inputMode: "numeric",
44
+ autoFocus: true,
45
+ maxLength: OTP_LENGTH,
46
+ placeholder: "0".repeat(OTP_LENGTH),
47
+ value: code,
48
+ onChange: (e) => {
49
+ setCode(e.target.value.replace(NON_DIGITS, ""));
50
+ if (codeError) setCodeError("");
51
+ },
52
+ error: codeError,
53
+ required: true,
54
+ className: "text-center font-mono text-lg tracking-[0.4em]"
55
+ }),
56
+ /* @__PURE__ */ jsxs("p", {
57
+ className: "text-muted-foreground text-xs",
58
+ children: [
59
+ "The code works once and expires in ",
60
+ expiryMinutes,
61
+ " minutes. Check your spam folder if it does not arrive."
62
+ ]
63
+ }),
64
+ /* @__PURE__ */ jsx(AuthButton, {
65
+ type: "submit",
66
+ className: "w-full",
67
+ actionKey: AUTH_SUBMIT_ACTION,
68
+ children: isSubmitting ? "Signing in..." : "Sign in"
69
+ })
70
+ ]
71
+ });
72
+ }
73
+
74
+ //#endregion
75
+ export { EmailOtpCodeForm };
@@ -0,0 +1,82 @@
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_AuthField = require('./AuthField.cjs');
8
+ const require_validate_email = require('../../utils/validate-email.cjs');
9
+ const require_LegalNotice = require('../LegalNotice.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/forms/EmailRequestForm.tsx
16
+ /**
17
+ * A card body that collects one address and sends something to it.
18
+ *
19
+ * The magic-link and emailed-code routes ask for exactly the same thing and
20
+ * differ only in what lands in the inbox, so they share this rather than
21
+ * keeping two copies of the same field, validation and Terms line.
22
+ */
23
+ function EmailRequestForm({ fieldId, onSubmitEmail, submitLabel, submittingLabel, termsUrl, privacyPolicyUrl, privacyNotice }) {
24
+ const [email, setEmail] = (0, react.useState)("");
25
+ const [emailError, setEmailError] = (0, react.useState)("");
26
+ const pending = require_auth_pending_context.useAuthPending();
27
+ const isSubmitting = pending.pendingKey === require_auth_pending_context.AUTH_SUBMIT_ACTION;
28
+ const handleSubmit = (e) => {
29
+ e.preventDefault();
30
+ const emailMessage = require_validate_email.validateEmailValue(email);
31
+ setEmailError(emailMessage ?? "");
32
+ if (emailMessage != null) return;
33
+ pending.run(require_auth_pending_context.AUTH_SUBMIT_ACTION, async () => onSubmitEmail(email));
34
+ };
35
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
36
+ onSubmit: handleSubmit,
37
+ className: "space-y-4",
38
+ noValidate: true,
39
+ children: [
40
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthField.AuthField, {
41
+ id: fieldId,
42
+ label: "Email",
43
+ type: "email",
44
+ value: email,
45
+ onChange: (e) => {
46
+ setEmail(e.target.value);
47
+ if (emailError) setEmailError("");
48
+ },
49
+ error: emailError,
50
+ required: true
51
+ }),
52
+ termsUrl != null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
53
+ className: "text-muted-foreground text-xs",
54
+ children: [
55
+ "By continuing you accept the",
56
+ " ",
57
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
58
+ href: termsUrl,
59
+ target: "_blank",
60
+ rel: "noopener noreferrer",
61
+ className: "text-primary underline",
62
+ children: "Terms of Service"
63
+ }),
64
+ ". If you don't have an account yet, one will be created for you."
65
+ ]
66
+ }),
67
+ (privacyNotice != null || privacyPolicyUrl != null) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LegalNotice.LegalNotice, {
68
+ privacyPolicyUrl,
69
+ notice: privacyNotice
70
+ }),
71
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
72
+ type: "submit",
73
+ className: "mt-6 w-full",
74
+ actionKey: require_auth_pending_context.AUTH_SUBMIT_ACTION,
75
+ children: isSubmitting ? submittingLabel : submitLabel
76
+ })
77
+ ]
78
+ });
79
+ }
80
+
81
+ //#endregion
82
+ exports.EmailRequestForm = EmailRequestForm;
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
3
+
4
+ //#region src/components/forms/EmailRequestForm.d.ts
5
+ interface EmailRequestFormProps {
6
+ /** Distinguishes this form's field from another card's. */
7
+ fieldId: string;
8
+ onSubmitEmail: (email: string) => Promise<void>;
9
+ /** Button copy at rest, and while its send is in flight. */
10
+ submitLabel: string;
11
+ submittingLabel: string;
12
+ /**
13
+ * Terms line shown above the button. Passed only by the passwordless routes,
14
+ * which double as sign-up and so need the acceptance that the password
15
+ * sign-up form collects with a checkbox.
16
+ */
17
+ termsUrl?: string;
18
+ privacyPolicyUrl?: string;
19
+ privacyNotice?: React.ReactNode;
20
+ }
21
+ /**
22
+ * A card body that collects one address and sends something to it.
23
+ *
24
+ * The magic-link and emailed-code routes ask for exactly the same thing and
25
+ * differ only in what lands in the inbox, so they share this rather than
26
+ * keeping two copies of the same field, validation and Terms line.
27
+ */
28
+ declare function EmailRequestForm({
29
+ fieldId,
30
+ onSubmitEmail,
31
+ submitLabel,
32
+ submittingLabel,
33
+ termsUrl,
34
+ privacyPolicyUrl,
35
+ privacyNotice
36
+ }: EmailRequestFormProps): react_jsx_runtime7.JSX.Element;
37
+ //#endregion
38
+ export { EmailRequestForm, EmailRequestFormProps };
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
3
+
4
+ //#region src/components/forms/EmailRequestForm.d.ts
5
+ interface EmailRequestFormProps {
6
+ /** Distinguishes this form's field from another card's. */
7
+ fieldId: string;
8
+ onSubmitEmail: (email: string) => Promise<void>;
9
+ /** Button copy at rest, and while its send is in flight. */
10
+ submitLabel: string;
11
+ submittingLabel: string;
12
+ /**
13
+ * Terms line shown above the button. Passed only by the passwordless routes,
14
+ * which double as sign-up and so need the acceptance that the password
15
+ * sign-up form collects with a checkbox.
16
+ */
17
+ termsUrl?: string;
18
+ privacyPolicyUrl?: string;
19
+ privacyNotice?: React.ReactNode;
20
+ }
21
+ /**
22
+ * A card body that collects one address and sends something to it.
23
+ *
24
+ * The magic-link and emailed-code routes ask for exactly the same thing and
25
+ * differ only in what lands in the inbox, so they share this rather than
26
+ * keeping two copies of the same field, validation and Terms line.
27
+ */
28
+ declare function EmailRequestForm({
29
+ fieldId,
30
+ onSubmitEmail,
31
+ submitLabel,
32
+ submittingLabel,
33
+ termsUrl,
34
+ privacyPolicyUrl,
35
+ privacyNotice
36
+ }: EmailRequestFormProps): react_jsx_runtime7.JSX.Element;
37
+ //#endregion
38
+ export { EmailRequestForm, EmailRequestFormProps };
@@ -0,0 +1,79 @@
1
+ 'use client';
2
+
3
+
4
+ import { AUTH_SUBMIT_ACTION, useAuthPending } from "../auth-pending/auth-pending-context.js";
5
+ import { AuthButton } from "../auth-pending/AuthButton.js";
6
+ import { AuthField } from "./AuthField.js";
7
+ import { validateEmailValue } from "../../utils/validate-email.js";
8
+ import { LegalNotice } from "../LegalNotice.js";
9
+ import { useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+
12
+ //#region src/components/forms/EmailRequestForm.tsx
13
+ /**
14
+ * A card body that collects one address and sends something to it.
15
+ *
16
+ * The magic-link and emailed-code routes ask for exactly the same thing and
17
+ * differ only in what lands in the inbox, so they share this rather than
18
+ * keeping two copies of the same field, validation and Terms line.
19
+ */
20
+ function EmailRequestForm({ fieldId, onSubmitEmail, submitLabel, submittingLabel, termsUrl, privacyPolicyUrl, privacyNotice }) {
21
+ const [email, setEmail] = useState("");
22
+ const [emailError, setEmailError] = useState("");
23
+ const pending = useAuthPending();
24
+ const isSubmitting = pending.pendingKey === AUTH_SUBMIT_ACTION;
25
+ const handleSubmit = (e) => {
26
+ e.preventDefault();
27
+ const emailMessage = validateEmailValue(email);
28
+ setEmailError(emailMessage ?? "");
29
+ if (emailMessage != null) return;
30
+ pending.run(AUTH_SUBMIT_ACTION, async () => onSubmitEmail(email));
31
+ };
32
+ return /* @__PURE__ */ jsxs("form", {
33
+ onSubmit: handleSubmit,
34
+ className: "space-y-4",
35
+ noValidate: true,
36
+ children: [
37
+ /* @__PURE__ */ jsx(AuthField, {
38
+ id: fieldId,
39
+ label: "Email",
40
+ type: "email",
41
+ value: email,
42
+ onChange: (e) => {
43
+ setEmail(e.target.value);
44
+ if (emailError) setEmailError("");
45
+ },
46
+ error: emailError,
47
+ required: true
48
+ }),
49
+ termsUrl != null && /* @__PURE__ */ jsxs("p", {
50
+ className: "text-muted-foreground text-xs",
51
+ children: [
52
+ "By continuing you accept the",
53
+ " ",
54
+ /* @__PURE__ */ jsx("a", {
55
+ href: termsUrl,
56
+ target: "_blank",
57
+ rel: "noopener noreferrer",
58
+ className: "text-primary underline",
59
+ children: "Terms of Service"
60
+ }),
61
+ ". If you don't have an account yet, one will be created for you."
62
+ ]
63
+ }),
64
+ (privacyNotice != null || privacyPolicyUrl != null) && /* @__PURE__ */ jsx(LegalNotice, {
65
+ privacyPolicyUrl,
66
+ notice: privacyNotice
67
+ }),
68
+ /* @__PURE__ */ jsx(AuthButton, {
69
+ type: "submit",
70
+ className: "mt-6 w-full",
71
+ actionKey: AUTH_SUBMIT_ACTION,
72
+ children: isSubmitting ? submittingLabel : submitLabel
73
+ })
74
+ ]
75
+ });
76
+ }
77
+
78
+ //#endregion
79
+ export { EmailRequestForm };
@@ -0,0 +1,79 @@
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_AuthField = require('./AuthField.cjs');
8
+ const require_validate_email = require('../../utils/validate-email.cjs');
9
+ const require_validate_password = require('../../utils/validate-password.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/forms/SignInCredentialsForm.tsx
16
+ /**
17
+ * The email-and-password half of the sign-in card.
18
+ *
19
+ * Its own component so the card is left holding only the choices it offers —
20
+ * providers, the passwordless routes, the step switches — and the credential
21
+ * fields keep their state and validation to themselves.
22
+ */
23
+ function SignInCredentialsForm({ onSignIn }) {
24
+ const [email, setEmail] = (0, react.useState)("");
25
+ const [password, setPassword] = (0, react.useState)("");
26
+ const [emailError, setEmailError] = (0, react.useState)("");
27
+ const [passwordError, setPasswordError] = (0, react.useState)("");
28
+ const pending = require_auth_pending_context.useAuthPending();
29
+ const isSubmitting = pending.pendingKey === require_auth_pending_context.AUTH_SUBMIT_ACTION;
30
+ const handleSubmit = (e) => {
31
+ e.preventDefault();
32
+ const emailMessage = require_validate_email.validateEmailValue(email);
33
+ setEmailError(emailMessage ?? "");
34
+ const passwordMessage = require_validate_password.validatePasswordValue(password);
35
+ setPasswordError(passwordMessage ?? "");
36
+ if (emailMessage != null || passwordMessage != null) return;
37
+ pending.run(require_auth_pending_context.AUTH_SUBMIT_ACTION, async () => onSignIn(email, password));
38
+ };
39
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
40
+ onSubmit: handleSubmit,
41
+ className: "space-y-4",
42
+ noValidate: true,
43
+ children: [
44
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthField.AuthField, {
45
+ id: "email",
46
+ label: "Email",
47
+ type: "email",
48
+ value: email,
49
+ onChange: (e) => {
50
+ setEmail(e.target.value);
51
+ if (emailError) setEmailError("");
52
+ },
53
+ error: emailError,
54
+ required: true
55
+ }),
56
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthField.AuthField, {
57
+ id: "password",
58
+ label: "Password",
59
+ type: "password",
60
+ value: password,
61
+ onChange: (e) => {
62
+ setPassword(e.target.value);
63
+ if (passwordError) setPasswordError("");
64
+ },
65
+ error: passwordError,
66
+ required: true
67
+ }),
68
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
69
+ type: "submit",
70
+ className: "mt-6 w-full",
71
+ actionKey: require_auth_pending_context.AUTH_SUBMIT_ACTION,
72
+ children: isSubmitting ? "Signing In..." : "Sign In"
73
+ })
74
+ ]
75
+ });
76
+ }
77
+
78
+ //#endregion
79
+ exports.SignInCredentialsForm = SignInCredentialsForm;
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
2
+
3
+ //#region src/components/forms/SignInCredentialsForm.d.ts
4
+ interface SignInCredentialsFormProps {
5
+ onSignIn: (email: string, password: string) => Promise<void>;
6
+ }
7
+ /**
8
+ * The email-and-password half of the sign-in card.
9
+ *
10
+ * Its own component so the card is left holding only the choices it offers —
11
+ * providers, the passwordless routes, the step switches — and the credential
12
+ * fields keep their state and validation to themselves.
13
+ */
14
+ declare function SignInCredentialsForm({
15
+ onSignIn
16
+ }: SignInCredentialsFormProps): react_jsx_runtime8.JSX.Element;
17
+ //#endregion
18
+ export { SignInCredentialsForm, SignInCredentialsFormProps };
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
2
+
3
+ //#region src/components/forms/SignInCredentialsForm.d.ts
4
+ interface SignInCredentialsFormProps {
5
+ onSignIn: (email: string, password: string) => Promise<void>;
6
+ }
7
+ /**
8
+ * The email-and-password half of the sign-in card.
9
+ *
10
+ * Its own component so the card is left holding only the choices it offers —
11
+ * providers, the passwordless routes, the step switches — and the credential
12
+ * fields keep their state and validation to themselves.
13
+ */
14
+ declare function SignInCredentialsForm({
15
+ onSignIn
16
+ }: SignInCredentialsFormProps): react_jsx_runtime8.JSX.Element;
17
+ //#endregion
18
+ export { SignInCredentialsForm, SignInCredentialsFormProps };
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+
3
+
4
+ import { AUTH_SUBMIT_ACTION, useAuthPending } from "../auth-pending/auth-pending-context.js";
5
+ import { AuthButton } from "../auth-pending/AuthButton.js";
6
+ import { AuthField } from "./AuthField.js";
7
+ import { validateEmailValue } from "../../utils/validate-email.js";
8
+ import { validatePasswordValue } from "../../utils/validate-password.js";
9
+ import { useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+
12
+ //#region src/components/forms/SignInCredentialsForm.tsx
13
+ /**
14
+ * The email-and-password half of the sign-in card.
15
+ *
16
+ * Its own component so the card is left holding only the choices it offers —
17
+ * providers, the passwordless routes, the step switches — and the credential
18
+ * fields keep their state and validation to themselves.
19
+ */
20
+ function SignInCredentialsForm({ onSignIn }) {
21
+ const [email, setEmail] = useState("");
22
+ const [password, setPassword] = useState("");
23
+ const [emailError, setEmailError] = useState("");
24
+ const [passwordError, setPasswordError] = useState("");
25
+ const pending = useAuthPending();
26
+ const isSubmitting = pending.pendingKey === AUTH_SUBMIT_ACTION;
27
+ const handleSubmit = (e) => {
28
+ e.preventDefault();
29
+ const emailMessage = validateEmailValue(email);
30
+ setEmailError(emailMessage ?? "");
31
+ const passwordMessage = validatePasswordValue(password);
32
+ setPasswordError(passwordMessage ?? "");
33
+ if (emailMessage != null || passwordMessage != null) return;
34
+ pending.run(AUTH_SUBMIT_ACTION, async () => onSignIn(email, password));
35
+ };
36
+ return /* @__PURE__ */ jsxs("form", {
37
+ onSubmit: handleSubmit,
38
+ className: "space-y-4",
39
+ noValidate: true,
40
+ children: [
41
+ /* @__PURE__ */ jsx(AuthField, {
42
+ id: "email",
43
+ label: "Email",
44
+ type: "email",
45
+ value: email,
46
+ onChange: (e) => {
47
+ setEmail(e.target.value);
48
+ if (emailError) setEmailError("");
49
+ },
50
+ error: emailError,
51
+ required: true
52
+ }),
53
+ /* @__PURE__ */ jsx(AuthField, {
54
+ id: "password",
55
+ label: "Password",
56
+ type: "password",
57
+ value: password,
58
+ onChange: (e) => {
59
+ setPassword(e.target.value);
60
+ if (passwordError) setPasswordError("");
61
+ },
62
+ error: passwordError,
63
+ required: true
64
+ }),
65
+ /* @__PURE__ */ jsx(AuthButton, {
66
+ type: "submit",
67
+ className: "mt-6 w-full",
68
+ actionKey: AUTH_SUBMIT_ACTION,
69
+ children: isSubmitting ? "Signing In..." : "Sign In"
70
+ })
71
+ ]
72
+ });
73
+ }
74
+
75
+ //#endregion
76
+ export { SignInCredentialsForm };
@@ -0,0 +1,130 @@
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_validation = require('../../constants/validation.cjs');
8
+ const require_AuthField = require('./AuthField.cjs');
9
+ const require_validate_email = require('../../utils/validate-email.cjs');
10
+ const require_LegalNotice = require('../LegalNotice.cjs');
11
+ const require_validate_password = require('../../utils/validate-password.cjs');
12
+ let react = require("react");
13
+ react = require_rolldown_runtime.__toESM(react);
14
+ let react_jsx_runtime = require("react/jsx-runtime");
15
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
16
+ let __wordrhyme_shadcn = require("@wordrhyme/shadcn");
17
+ __wordrhyme_shadcn = require_rolldown_runtime.__toESM(__wordrhyme_shadcn);
18
+
19
+ //#region src/components/forms/SignUpCredentialsForm.tsx
20
+ /** The account-details half of the sign-up card: credentials and the consent it needs. */
21
+ function SignUpCredentialsForm({ onSignUp, privacyPolicyUrl, privacyNotice, termsUrl, minimumAge = require_validation.DEFAULT_MINIMUM_AGE, onConsentGiven }) {
22
+ const [email, setEmail] = (0, react.useState)("");
23
+ const [password, setPassword] = (0, react.useState)("");
24
+ const [emailError, setEmailError] = (0, react.useState)("");
25
+ const [passwordError, setPasswordError] = (0, react.useState)("");
26
+ const [consentChecked, setConsentChecked] = (0, react.useState)(false);
27
+ const [consentError, setConsentError] = (0, react.useState)("");
28
+ const pending = require_auth_pending_context.useAuthPending();
29
+ const isSubmitting = pending.pendingKey === require_auth_pending_context.AUTH_SUBMIT_ACTION;
30
+ const handleSubmit = (e) => {
31
+ e.preventDefault();
32
+ const emailMessage = require_validate_email.validateEmailValue(email);
33
+ setEmailError(emailMessage ?? "");
34
+ const passwordMessage = require_validate_password.validatePasswordValue(password);
35
+ setPasswordError(passwordMessage ?? "");
36
+ if (emailMessage != null || passwordMessage != null) return;
37
+ if (!consentChecked) {
38
+ setConsentError("You must accept the Terms of Service to create an account.");
39
+ return;
40
+ }
41
+ setConsentError("");
42
+ onConsentGiven?.();
43
+ pending.run(require_auth_pending_context.AUTH_SUBMIT_ACTION, async () => onSignUp(email, password));
44
+ };
45
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
46
+ onSubmit: handleSubmit,
47
+ className: "space-y-4",
48
+ noValidate: true,
49
+ children: [
50
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthField.AuthField, {
51
+ id: "email",
52
+ label: "Email",
53
+ type: "email",
54
+ value: email,
55
+ onChange: (e) => {
56
+ setEmail(e.target.value);
57
+ if (emailError) setEmailError("");
58
+ },
59
+ error: emailError,
60
+ required: true
61
+ }),
62
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthField.AuthField, {
63
+ id: "password",
64
+ label: "Password",
65
+ type: "password",
66
+ value: password,
67
+ onChange: (e) => {
68
+ setPassword(e.target.value);
69
+ if (passwordError) setPasswordError("");
70
+ },
71
+ error: passwordError,
72
+ required: true
73
+ }),
74
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
75
+ className: "mt-4 flex items-start gap-2",
76
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
77
+ type: "checkbox",
78
+ id: "consent",
79
+ checked: consentChecked,
80
+ onChange: (e) => {
81
+ setConsentChecked(e.target.checked);
82
+ if (e.target.checked) setConsentError("");
83
+ },
84
+ disabled: pending.isBusy,
85
+ "aria-describedby": "consent-privacy-note",
86
+ "aria-invalid": consentError !== "",
87
+ className: "border-input text-primary focus-visible:ring-ring mt-1 h-4 w-4 shrink-0 rounded focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"
88
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.Label, {
89
+ htmlFor: "consent",
90
+ className: "block min-w-0 flex-1 text-sm leading-relaxed",
91
+ children: [
92
+ "I accept the",
93
+ " ",
94
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
95
+ href: termsUrl,
96
+ target: "_blank",
97
+ rel: "noopener noreferrer",
98
+ className: "text-primary underline",
99
+ children: "Terms of Service"
100
+ }),
101
+ " ",
102
+ "and confirm I am at least ",
103
+ minimumAge,
104
+ " years old."
105
+ ]
106
+ })]
107
+ }),
108
+ consentError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
109
+ className: "text-destructive text-sm",
110
+ role: "alert",
111
+ children: consentError
112
+ }),
113
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LegalNotice.LegalNotice, {
114
+ id: "consent-privacy-note",
115
+ privacyPolicyUrl,
116
+ notice: privacyNotice
117
+ }),
118
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
119
+ type: "submit",
120
+ className: "mt-6 w-full",
121
+ actionKey: require_auth_pending_context.AUTH_SUBMIT_ACTION,
122
+ disabled: !consentChecked,
123
+ children: isSubmitting ? "Signing Up..." : "Sign Up"
124
+ })
125
+ ]
126
+ });
127
+ }
128
+
129
+ //#endregion
130
+ exports.SignUpCredentialsForm = SignUpCredentialsForm;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import * as react_jsx_runtime9 from "react/jsx-runtime";
3
+
4
+ //#region src/components/forms/SignUpCredentialsForm.d.ts
5
+ interface SignUpCredentialsFormProps {
6
+ onSignUp: (email: string, password: string) => Promise<void>;
7
+ privacyPolicyUrl: string;
8
+ privacyNotice?: React.ReactNode;
9
+ termsUrl: string;
10
+ /** Minimum age stated by the Terms; shown in the acceptance line. */
11
+ minimumAge?: number;
12
+ onConsentGiven?: () => void;
13
+ }
14
+ /** The account-details half of the sign-up card: credentials and the consent it needs. */
15
+ declare function SignUpCredentialsForm({
16
+ onSignUp,
17
+ privacyPolicyUrl,
18
+ privacyNotice,
19
+ termsUrl,
20
+ minimumAge,
21
+ onConsentGiven
22
+ }: SignUpCredentialsFormProps): react_jsx_runtime9.JSX.Element;
23
+ //#endregion
24
+ export { SignUpCredentialsForm, SignUpCredentialsFormProps };