@main12/auth-login 0.4.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +54 -7
  2. package/dist/components/AuthCard.d.ts +41 -0
  3. package/dist/components/AuthCard.js +28 -0
  4. package/dist/components/AuthCardServer.d.ts +29 -0
  5. package/dist/components/AuthCardServer.js +57 -0
  6. package/dist/components/AuthLayout.d.ts +23 -13
  7. package/dist/components/AuthLayout.js +26 -87
  8. package/dist/components/AuthPages.d.ts +4 -29
  9. package/dist/components/AuthPages.js +23 -105
  10. package/dist/components/AuthPagesServer.d.ts +3 -4
  11. package/dist/components/AuthPagesServer.js +15 -8
  12. package/dist/components/auth-card/AuthCardShell.d.ts +21 -0
  13. package/dist/components/auth-card/AuthCardShell.js +104 -0
  14. package/dist/components/auth-card/FormRenderer.d.ts +32 -0
  15. package/dist/components/auth-card/FormRenderer.js +88 -0
  16. package/dist/components/auth-card/formConfigs.d.ts +25 -0
  17. package/dist/components/auth-card/formConfigs.js +56 -0
  18. package/dist/components/auth-card/index.d.ts +3 -0
  19. package/dist/components/auth-card/index.js +3 -0
  20. package/dist/components/forms/ForgotPasswordForm.d.ts +7 -0
  21. package/dist/components/forms/ForgotPasswordForm.js +56 -0
  22. package/dist/components/forms/LoginForm.d.ts +15 -0
  23. package/dist/components/forms/LoginForm.js +247 -0
  24. package/dist/components/forms/SetPasswordForm.d.ts +7 -0
  25. package/dist/components/forms/SetPasswordForm.js +75 -0
  26. package/dist/components/forms/SignupForm.d.ts +13 -0
  27. package/dist/components/forms/SignupForm.js +152 -0
  28. package/dist/components/forms/VerifyOtpForm.d.ts +9 -0
  29. package/dist/components/forms/VerifyOtpForm.js +107 -0
  30. package/dist/components/forms/index.d.ts +19 -0
  31. package/dist/components/forms/index.js +21 -0
  32. package/dist/components/pages/ForgotPasswordPage.d.ts +2 -1
  33. package/dist/components/pages/ForgotPasswordPageHero.d.ts +3 -2
  34. package/dist/components/pages/ForgotPasswordPageHero.js +70 -64
  35. package/dist/components/pages/ForgotPasswordPageTailwind.d.ts +3 -2
  36. package/dist/components/pages/ForgotPasswordPageTailwind.js +42 -36
  37. package/dist/components/pages/LoginPage.d.ts +2 -1
  38. package/dist/components/pages/LoginPageHero.d.ts +2 -1
  39. package/dist/components/pages/LoginPageHero.js +297 -291
  40. package/dist/components/pages/LoginPageTailwind.d.ts +2 -1
  41. package/dist/components/pages/LoginPageTailwind.js +197 -191
  42. package/dist/components/pages/SetPasswordPage.d.ts +2 -1
  43. package/dist/components/pages/SetPasswordPageHero.d.ts +3 -2
  44. package/dist/components/pages/SetPasswordPageHero.js +98 -92
  45. package/dist/components/pages/SetPasswordPageTailwind.d.ts +3 -2
  46. package/dist/components/pages/SetPasswordPageTailwind.js +63 -57
  47. package/dist/components/pages/SignupPage.d.ts +2 -1
  48. package/dist/components/pages/SignupPageHero.d.ts +3 -2
  49. package/dist/components/pages/SignupPageHero.js +139 -133
  50. package/dist/components/pages/SignupPageTailwind.d.ts +3 -2
  51. package/dist/components/pages/SignupPageTailwind.js +123 -117
  52. package/dist/components/pages/VerifyOtpPage.d.ts +2 -1
  53. package/dist/components/pages/VerifyOtpPageHero.d.ts +2 -1
  54. package/dist/components/pages/VerifyOtpPageHero.js +110 -104
  55. package/dist/components/pages/VerifyOtpPageTailwind.d.ts +2 -1
  56. package/dist/components/pages/VerifyOtpPageTailwind.js +60 -54
  57. package/dist/components/ui/translations.d.ts +9 -0
  58. package/dist/components/ui/translations.js +18 -0
  59. package/dist/config.d.ts +12 -0
  60. package/dist/config.js +11 -0
  61. package/dist/exports/client.d.ts +5 -0
  62. package/dist/exports/client.js +5 -0
  63. package/dist/exports/rsc.d.ts +7 -0
  64. package/dist/exports/rsc.js +8 -0
  65. package/dist/index.js +12 -2
  66. package/package.json +3 -2
@@ -5,8 +5,9 @@ import { useSearchParams } from 'next/navigation';
5
5
  import { Button, Input, Divider, Spinner } from '../ui/index.js';
6
6
  import { useLoginFlow } from '../../auth/application/hooks/useLoginFlow.js';
7
7
  import { AuthLayout } from '../AuthLayout.js';
8
+ import { AuthCard } from '../AuthCard.js';
8
9
  import { getUiTranslations } from '../ui/translations.js';
9
- function LoginContent({ onPasswordLogin, redirectTo = '/', showGoogleOAuth = true, signupUrl = '/signup', logo, poweredBy, cardClassName, backgroundClass, locale, messages }) {
10
+ function LoginContent({ onPasswordLogin, redirectTo = '/', showGoogleOAuth = true, signupUrl = '/signup', logo, poweredBy, cardClassName, removeBorder, removeShadow, mobileVariant, backgroundClass, locale, messages }) {
10
11
  const searchParams = useSearchParams();
11
12
  const resolvedRedirect = searchParams.get('redirect') || redirectTo;
12
13
  const t = getUiTranslations(locale, messages).login;
@@ -16,207 +17,212 @@ function LoginContent({ onPasswordLogin, redirectTo = '/', showGoogleOAuth = tru
16
17
  });
17
18
  const stepTitle = step === 'otp-prompt' ? t.otpPromptTitle : step === 'email' ? t.title : t.passwordStepTitle;
18
19
  const stepSubtitle = step === 'otp-prompt' ? t.otpPromptSubtitle : step === 'email' ? t.subtitle : t.passwordStepSubtitle;
19
- return /*#__PURE__*/ _jsxs(AuthLayout, {
20
- logo: logo,
21
- title: stepTitle,
22
- subtitle: stepSubtitle,
23
- poweredBy: poweredBy,
24
- cardClassName: cardClassName,
20
+ return /*#__PURE__*/ _jsx(AuthLayout, {
25
21
  backgroundClass: backgroundClass,
26
- footer: signupUrl ? /*#__PURE__*/ _jsxs("p", {
27
- className: "text-center text-gray-600 text-sm",
28
- children: [
29
- t.noAccount,
30
- ' ',
31
- /*#__PURE__*/ _jsx("a", {
32
- href: signupUrl,
33
- className: "text-gray-900 font-medium hover:underline",
34
- children: t.signUpLink
35
- })
36
- ]
37
- }) : undefined,
38
- children: [
39
- step === 'email' && /*#__PURE__*/ _jsxs("div", {
40
- className: "animate-[fadeIn_0.3s_ease-out]",
22
+ children: /*#__PURE__*/ _jsxs(AuthCard, {
23
+ logo: logo,
24
+ title: stepTitle,
25
+ subtitle: stepSubtitle,
26
+ poweredBy: poweredBy,
27
+ cardClassName: cardClassName,
28
+ removeBorder: removeBorder,
29
+ removeShadow: removeShadow,
30
+ mobileVariant: mobileVariant,
31
+ footer: signupUrl ? /*#__PURE__*/ _jsxs("p", {
32
+ className: "text-center text-gray-600 text-sm",
41
33
  children: [
42
- showGoogleOAuth && /*#__PURE__*/ _jsxs(_Fragment, {
43
- children: [
44
- /*#__PURE__*/ _jsxs(Button, {
45
- fullWidth: true,
46
- variant: "secondary",
47
- size: "lg",
48
- className: "mb-4",
49
- onPress: handleGoogleLogin,
50
- children: [
51
- /*#__PURE__*/ _jsxs("svg", {
52
- width: "20",
53
- height: "20",
54
- viewBox: "0 0 48 48",
55
- children: [
56
- /*#__PURE__*/ _jsx("path", {
57
- fill: "#EA4335",
58
- d: "M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"
59
- }),
60
- /*#__PURE__*/ _jsx("path", {
61
- fill: "#4285F4",
62
- d: "M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"
63
- }),
64
- /*#__PURE__*/ _jsx("path", {
65
- fill: "#FBBC05",
66
- d: "M10.53 28.59a14.5 14.5 0 0 1 0-9.18l-7.98-6.19a24.01 24.01 0 0 0 0 21.56l7.98-6.19z"
67
- }),
68
- /*#__PURE__*/ _jsx("path", {
69
- fill: "#34A853",
70
- d: "M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"
71
- })
72
- ]
73
- }),
74
- t.continueWithGoogle
75
- ]
76
- }),
77
- /*#__PURE__*/ _jsxs("div", {
78
- className: "flex items-center gap-4 my-4",
79
- children: [
80
- /*#__PURE__*/ _jsx(Divider, {
81
- className: "flex-1"
82
- }),
83
- /*#__PURE__*/ _jsx("span", {
84
- className: "text-gray-500 text-sm",
85
- children: t.or
86
- }),
87
- /*#__PURE__*/ _jsx(Divider, {
88
- className: "flex-1"
89
- })
90
- ]
91
- })
92
- ]
93
- }),
94
- /*#__PURE__*/ _jsxs("form", {
95
- onSubmit: handleEmailSubmit,
96
- className: "space-y-4",
97
- children: [
98
- error && /*#__PURE__*/ _jsx("div", {
99
- className: "bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm",
100
- children: error
101
- }),
102
- /*#__PURE__*/ _jsx(Input, {
103
- type: "email",
104
- label: t.emailLabel,
105
- value: email,
106
- onValueChange: setEmail,
107
- isRequired: true,
108
- variant: "secondary"
109
- }),
110
- /*#__PURE__*/ _jsx(Button, {
111
- type: "submit",
112
- variant: "primary",
113
- isLoading: isLoading,
114
- children: t.continue
115
- })
116
- ]
34
+ t.noAccount,
35
+ ' ',
36
+ /*#__PURE__*/ _jsx("a", {
37
+ href: signupUrl,
38
+ className: "text-gray-900 font-medium hover:underline",
39
+ children: t.signUpLink
117
40
  })
118
41
  ]
119
- }),
120
- step === 'password' && /*#__PURE__*/ _jsxs("div", {
121
- className: "animate-[fadeIn_0.3s_ease-out]",
122
- children: [
123
- /*#__PURE__*/ _jsxs("div", {
124
- className: "flex items-center justify-between border border-gray-300 rounded-xl px-4 py-3 mb-4",
125
- children: [
126
- /*#__PURE__*/ _jsx("span", {
127
- className: "text-gray-900 text-sm",
128
- children: email
129
- }),
130
- /*#__PURE__*/ _jsx("button", {
131
- type: "button",
132
- onClick: handleEditEmail,
133
- className: "text-gray-600 text-sm font-medium hover:text-gray-900",
134
- children: t.edit
135
- })
136
- ]
137
- }),
138
- /*#__PURE__*/ _jsxs("form", {
139
- onSubmit: handlePasswordSubmit,
140
- className: "space-y-4",
141
- children: [
142
- error && /*#__PURE__*/ _jsx("div", {
143
- className: "bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm",
144
- children: error
145
- }),
146
- /*#__PURE__*/ _jsx(Input, {
147
- type: showPassword ? 'text' : 'password',
148
- label: t.passwordLabel,
149
- value: password,
150
- onValueChange: setPassword,
151
- isRequired: true,
152
- autoFocus: true,
153
- variant: "secondary"
154
- }),
155
- /*#__PURE__*/ _jsx("div", {
156
- className: "text-left",
157
- children: /*#__PURE__*/ _jsx("a", {
158
- href: "/forgot-password",
159
- className: "text-sm text-gray-700 hover:text-gray-900 hover:underline",
160
- children: t.forgotPassword
42
+ }) : undefined,
43
+ children: [
44
+ step === 'email' && /*#__PURE__*/ _jsxs("div", {
45
+ className: "animate-[fadeIn_0.3s_ease-out]",
46
+ children: [
47
+ showGoogleOAuth && /*#__PURE__*/ _jsxs(_Fragment, {
48
+ children: [
49
+ /*#__PURE__*/ _jsxs(Button, {
50
+ fullWidth: true,
51
+ variant: "secondary",
52
+ size: "lg",
53
+ className: "mb-4",
54
+ onPress: handleGoogleLogin,
55
+ children: [
56
+ /*#__PURE__*/ _jsxs("svg", {
57
+ width: "20",
58
+ height: "20",
59
+ viewBox: "0 0 48 48",
60
+ children: [
61
+ /*#__PURE__*/ _jsx("path", {
62
+ fill: "#EA4335",
63
+ d: "M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"
64
+ }),
65
+ /*#__PURE__*/ _jsx("path", {
66
+ fill: "#4285F4",
67
+ d: "M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"
68
+ }),
69
+ /*#__PURE__*/ _jsx("path", {
70
+ fill: "#FBBC05",
71
+ d: "M10.53 28.59a14.5 14.5 0 0 1 0-9.18l-7.98-6.19a24.01 24.01 0 0 0 0 21.56l7.98-6.19z"
72
+ }),
73
+ /*#__PURE__*/ _jsx("path", {
74
+ fill: "#34A853",
75
+ d: "M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"
76
+ })
77
+ ]
78
+ }),
79
+ t.continueWithGoogle
80
+ ]
81
+ }),
82
+ /*#__PURE__*/ _jsxs("div", {
83
+ className: "flex items-center gap-4 my-4",
84
+ children: [
85
+ /*#__PURE__*/ _jsx(Divider, {
86
+ className: "flex-1"
87
+ }),
88
+ /*#__PURE__*/ _jsx("span", {
89
+ className: "text-gray-500 text-sm",
90
+ children: t.or
91
+ }),
92
+ /*#__PURE__*/ _jsx(Divider, {
93
+ className: "flex-1"
94
+ })
95
+ ]
161
96
  })
162
- }),
163
- /*#__PURE__*/ _jsx(Button, {
164
- type: "submit",
165
- variant: "primary",
166
- isLoading: isLoading,
167
- children: t.continue
168
- })
169
- ]
170
- })
171
- ]
172
- }),
173
- step === 'otp-prompt' && /*#__PURE__*/ _jsxs("div", {
174
- className: "animate-[fadeIn_0.3s_ease-out]",
175
- children: [
176
- /*#__PURE__*/ _jsxs("div", {
177
- className: "flex items-center justify-between border border-gray-300 rounded-xl px-4 py-3 mb-4",
178
- children: [
179
- /*#__PURE__*/ _jsx("span", {
180
- className: "text-gray-900 text-sm",
181
- children: email
182
- }),
183
- /*#__PURE__*/ _jsx("button", {
184
- type: "button",
185
- onClick: handleEditEmail,
186
- className: "text-gray-600 text-sm font-medium hover:text-gray-900",
187
- children: t.edit
188
- })
189
- ]
190
- }),
191
- error && /*#__PURE__*/ _jsx("div", {
192
- className: "bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm mb-4",
193
- children: error
194
- }),
195
- /*#__PURE__*/ _jsx("div", {
196
- className: "bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4",
197
- children: /*#__PURE__*/ _jsxs("div", {
198
- className: "flex gap-3",
97
+ ]
98
+ }),
99
+ /*#__PURE__*/ _jsxs("form", {
100
+ onSubmit: handleEmailSubmit,
101
+ className: "space-y-4",
102
+ children: [
103
+ error && /*#__PURE__*/ _jsx("div", {
104
+ className: "bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm",
105
+ children: error
106
+ }),
107
+ /*#__PURE__*/ _jsx(Input, {
108
+ type: "email",
109
+ label: t.emailLabel,
110
+ value: email,
111
+ onValueChange: setEmail,
112
+ isRequired: true,
113
+ variant: "secondary"
114
+ }),
115
+ /*#__PURE__*/ _jsx(Button, {
116
+ type: "submit",
117
+ variant: "primary",
118
+ isLoading: isLoading,
119
+ children: t.continue
120
+ })
121
+ ]
122
+ })
123
+ ]
124
+ }),
125
+ step === 'password' && /*#__PURE__*/ _jsxs("div", {
126
+ className: "animate-[fadeIn_0.3s_ease-out]",
127
+ children: [
128
+ /*#__PURE__*/ _jsxs("div", {
129
+ className: "flex items-center justify-between border border-gray-300 rounded-xl px-4 py-3 mb-4",
199
130
  children: [
200
131
  /*#__PURE__*/ _jsx("span", {
201
- className: "text-blue-500 text-lg",
202
- children: "✉"
132
+ className: "text-gray-900 text-sm",
133
+ children: email
134
+ }),
135
+ /*#__PURE__*/ _jsx("button", {
136
+ type: "button",
137
+ onClick: handleEditEmail,
138
+ className: "text-gray-600 text-sm font-medium hover:text-gray-900",
139
+ children: t.edit
140
+ })
141
+ ]
142
+ }),
143
+ /*#__PURE__*/ _jsxs("form", {
144
+ onSubmit: handlePasswordSubmit,
145
+ className: "space-y-4",
146
+ children: [
147
+ error && /*#__PURE__*/ _jsx("div", {
148
+ className: "bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm",
149
+ children: error
203
150
  }),
204
- /*#__PURE__*/ _jsx("p", {
205
- className: "text-sm text-blue-700",
206
- children: t.verificationNotice
151
+ /*#__PURE__*/ _jsx(Input, {
152
+ type: showPassword ? 'text' : 'password',
153
+ label: t.passwordLabel,
154
+ value: password,
155
+ onValueChange: setPassword,
156
+ isRequired: true,
157
+ autoFocus: true,
158
+ variant: "secondary"
159
+ }),
160
+ /*#__PURE__*/ _jsx("div", {
161
+ className: "text-left",
162
+ children: /*#__PURE__*/ _jsx("a", {
163
+ href: "/forgot-password",
164
+ className: "text-sm text-gray-700 hover:text-gray-900 hover:underline",
165
+ children: t.forgotPassword
166
+ })
167
+ }),
168
+ /*#__PURE__*/ _jsx(Button, {
169
+ type: "submit",
170
+ variant: "primary",
171
+ isLoading: isLoading,
172
+ children: t.continue
207
173
  })
208
174
  ]
209
175
  })
210
- }),
211
- /*#__PURE__*/ _jsx(Button, {
212
- variant: "primary",
213
- isLoading: isSendingOtp,
214
- onPress: handleSendOtp,
215
- children: isSendingOtp ? t.sendingCode : t.sendCode
216
- })
217
- ]
218
- })
219
- ]
176
+ ]
177
+ }),
178
+ step === 'otp-prompt' && /*#__PURE__*/ _jsxs("div", {
179
+ className: "animate-[fadeIn_0.3s_ease-out]",
180
+ children: [
181
+ /*#__PURE__*/ _jsxs("div", {
182
+ className: "flex items-center justify-between border border-gray-300 rounded-xl px-4 py-3 mb-4",
183
+ children: [
184
+ /*#__PURE__*/ _jsx("span", {
185
+ className: "text-gray-900 text-sm",
186
+ children: email
187
+ }),
188
+ /*#__PURE__*/ _jsx("button", {
189
+ type: "button",
190
+ onClick: handleEditEmail,
191
+ className: "text-gray-600 text-sm font-medium hover:text-gray-900",
192
+ children: t.edit
193
+ })
194
+ ]
195
+ }),
196
+ error && /*#__PURE__*/ _jsx("div", {
197
+ className: "bg-red-50 text-red-600 border border-red-200 rounded-lg p-3 text-sm mb-4",
198
+ children: error
199
+ }),
200
+ /*#__PURE__*/ _jsx("div", {
201
+ className: "bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4",
202
+ children: /*#__PURE__*/ _jsxs("div", {
203
+ className: "flex gap-3",
204
+ children: [
205
+ /*#__PURE__*/ _jsx("span", {
206
+ className: "text-blue-500 text-lg",
207
+ children: "✉"
208
+ }),
209
+ /*#__PURE__*/ _jsx("p", {
210
+ className: "text-sm text-blue-700",
211
+ children: t.verificationNotice
212
+ })
213
+ ]
214
+ })
215
+ }),
216
+ /*#__PURE__*/ _jsx(Button, {
217
+ variant: "primary",
218
+ isLoading: isSendingOtp,
219
+ onPress: handleSendOtp,
220
+ children: isSendingOtp ? t.sendingCode : t.sendCode
221
+ })
222
+ ]
223
+ })
224
+ ]
225
+ })
220
226
  });
221
227
  }
222
228
  export default function LoginPage(props) {
@@ -1,5 +1,6 @@
1
1
  import type { AuthLayoutConfig } from '../AuthLayout';
2
- export interface SetPasswordPageProps extends AuthLayoutConfig {
2
+ import type { AuthCardConfig } from '../AuthCard';
3
+ export interface SetPasswordPageProps extends AuthLayoutConfig, AuthCardConfig {
3
4
  redirectTo?: string;
4
5
  }
5
6
  export default function SetPasswordPage(props: SetPasswordPageProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { AuthLayoutConfig } from '../AuthLayout';
2
- export interface SetPasswordPageHeroProps extends AuthLayoutConfig {
2
+ import type { AuthCardConfig } from '../AuthCard';
3
+ export interface SetPasswordPageHeroProps extends AuthLayoutConfig, AuthCardConfig {
3
4
  redirectTo?: string;
4
5
  }
5
- export default function SetPasswordPageHero({ redirectTo, logo, poweredBy, cardClassName, backgroundClass, locale, messages }: SetPasswordPageHeroProps): import("react/jsx-runtime").JSX.Element;
6
+ export default function SetPasswordPageHero({ redirectTo, logo, poweredBy, cardClassName, removeBorder, removeShadow, mobileVariant, backgroundClass, locale, messages }: SetPasswordPageHeroProps): import("react/jsx-runtime").JSX.Element;