@main12/auth-login 0.3.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,179 @@
1
+ /**
2
+ * UI copy for the auth pages (login, signup, forgot-password, verify-otp, set-password).
3
+ *
4
+ * Built-in support for English (`en`) and Spanish (`es`) out of the box — no
5
+ * configuration required. Consumers can override any subset of keys, and/or add
6
+ * entirely new locales, via the `messages` prop on `<AuthPages />` / individual
7
+ * page components. Missing keys always fall back to the built-in English copy.
8
+ */ const en = {
9
+ login: {
10
+ title: 'Welcome Back',
11
+ subtitle: 'Sign in with your email to continue.',
12
+ passwordStepTitle: 'Enter Password',
13
+ passwordStepSubtitle: 'Enter your password to sign in.',
14
+ otpPromptTitle: 'Verify Identity',
15
+ otpPromptSubtitle: "We need to verify it's you.",
16
+ continueWithGoogle: 'Continue with Google',
17
+ or: 'or',
18
+ emailLabel: 'Email',
19
+ passwordLabel: 'Password',
20
+ continue: 'Continue',
21
+ forgotPassword: 'Forgot password?',
22
+ edit: 'Edit',
23
+ verificationNotice: "We'll send a verification code to this email.",
24
+ sendCode: 'Send Code',
25
+ sendingCode: 'Sending...',
26
+ noAccount: "Don't have an account?",
27
+ signUpLink: 'Sign up'
28
+ },
29
+ signup: {
30
+ title: 'Create Account',
31
+ subtitle: 'Enter your details to get started',
32
+ fullNameLabel: 'Full Name',
33
+ emailLabel: 'Email',
34
+ continueWithGoogle: 'Continue with Google',
35
+ or: 'or',
36
+ termsNotice: 'By signing up, you agree to our',
37
+ termsLink: 'Terms of Service',
38
+ andSeparator: 'and',
39
+ privacyLink: 'Privacy Policy',
40
+ createAccount: 'Create Account',
41
+ haveAccount: 'Already have an account?',
42
+ loginLink: 'Login'
43
+ },
44
+ forgotPassword: {
45
+ title: 'Forgot Password',
46
+ subtitle: "Enter your email and we'll send you a reset code",
47
+ emailLabel: 'Email',
48
+ sendResetCode: 'Send Reset Code',
49
+ backToLogin: 'Back to Login'
50
+ },
51
+ verifyOtp: {
52
+ title: 'Check Your Email',
53
+ passwordResetTitle: 'Reset Password',
54
+ subtitle: 'We sent a 6-digit code to',
55
+ passwordResetSubtitle: 'Enter the code to reset your password',
56
+ verify: 'Verify',
57
+ noCodeReceived: "Didn't receive a code?",
58
+ resendCode: 'Resend Code',
59
+ resending: 'Sending...',
60
+ resendIn: 'Resend in {seconds}s',
61
+ backToLogin: 'Back to Login'
62
+ },
63
+ setPassword: {
64
+ title: 'Set Your Password',
65
+ subtitle: 'Create a secure password for your account',
66
+ newPasswordLabel: 'New Password',
67
+ confirmPasswordLabel: 'Confirm Password',
68
+ passwordRequirements: 'At least 8 chars with 3 of: uppercase, lowercase, number, special character',
69
+ setPassword: 'Set Password'
70
+ }
71
+ };
72
+ const es = {
73
+ login: {
74
+ title: 'Bienvenido de Nuevo',
75
+ subtitle: 'Inicia sesión con tu correo para continuar.',
76
+ passwordStepTitle: 'Ingresa tu Contraseña',
77
+ passwordStepSubtitle: 'Ingresa tu contraseña para iniciar sesión.',
78
+ otpPromptTitle: 'Verificar Identidad',
79
+ otpPromptSubtitle: 'Necesitamos verificar que eres tú.',
80
+ continueWithGoogle: 'Continuar con Google',
81
+ or: 'o',
82
+ emailLabel: 'Correo electrónico',
83
+ passwordLabel: 'Contraseña',
84
+ continue: 'Continuar',
85
+ forgotPassword: '¿Olvidaste tu contraseña?',
86
+ edit: 'Editar',
87
+ verificationNotice: 'Enviaremos un código de verificación a este correo.',
88
+ sendCode: 'Enviar Código',
89
+ sendingCode: 'Enviando...',
90
+ noAccount: '¿No tienes una cuenta?',
91
+ signUpLink: 'Regístrate'
92
+ },
93
+ signup: {
94
+ title: 'Crear Cuenta',
95
+ subtitle: 'Ingresa tus datos para comenzar',
96
+ fullNameLabel: 'Nombre Completo',
97
+ emailLabel: 'Correo electrónico',
98
+ continueWithGoogle: 'Continuar con Google',
99
+ or: 'o',
100
+ termsNotice: 'Al registrarte, aceptas nuestros',
101
+ termsLink: 'Términos de Servicio',
102
+ andSeparator: 'y',
103
+ privacyLink: 'Política de Privacidad',
104
+ createAccount: 'Crear Cuenta',
105
+ haveAccount: '¿Ya tienes una cuenta?',
106
+ loginLink: 'Inicia sesión'
107
+ },
108
+ forgotPassword: {
109
+ title: 'Recuperar Contraseña',
110
+ subtitle: 'Ingresa tu correo y te enviaremos un código para restablecerla',
111
+ emailLabel: 'Correo electrónico',
112
+ sendResetCode: 'Enviar Código',
113
+ backToLogin: 'Volver al Inicio de Sesión'
114
+ },
115
+ verifyOtp: {
116
+ title: 'Revisa tu Correo',
117
+ passwordResetTitle: 'Restablecer Contraseña',
118
+ subtitle: 'Enviamos un código de 6 dígitos a',
119
+ passwordResetSubtitle: 'Ingresa el código para restablecer tu contraseña',
120
+ verify: 'Verificar',
121
+ noCodeReceived: '¿No recibiste el código?',
122
+ resendCode: 'Reenviar Código',
123
+ resending: 'Enviando...',
124
+ resendIn: 'Reenviar en {seconds}s',
125
+ backToLogin: 'Volver al Inicio de Sesión'
126
+ },
127
+ setPassword: {
128
+ title: 'Establece tu Contraseña',
129
+ subtitle: 'Crea una contraseña segura para tu cuenta',
130
+ newPasswordLabel: 'Nueva Contraseña',
131
+ confirmPasswordLabel: 'Confirmar Contraseña',
132
+ passwordRequirements: 'Al menos 8 caracteres con 3 de: mayúscula, minúscula, número, carácter especial',
133
+ setPassword: 'Establecer Contraseña'
134
+ }
135
+ };
136
+ /** Built-in dictionaries. Consumers can add more locales via the `messages` prop. */ export const uiTranslations = {
137
+ en,
138
+ es
139
+ };
140
+ function isPlainObject(value) {
141
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
142
+ }
143
+ function deepMerge(base, override) {
144
+ if (!override) return base;
145
+ const result = {
146
+ ...base
147
+ };
148
+ for(const key in override){
149
+ const overrideValue = override[key];
150
+ const baseValue = base[key];
151
+ if (isPlainObject(overrideValue) && isPlainObject(baseValue)) {
152
+ result[key] = deepMerge(baseValue, overrideValue);
153
+ } else if (overrideValue !== undefined) {
154
+ result[key] = overrideValue;
155
+ }
156
+ }
157
+ return result;
158
+ }
159
+ /**
160
+ * Resolve the final UI translations for a given locale, applying any consumer
161
+ * overrides on top of the built-in dictionaries.
162
+ *
163
+ * Resolution order per key: `messages[locale]` → `messages.en` → built-in
164
+ * `[locale]` → built-in `en`. Consumers may pass a partial override object —
165
+ * any key they don't specify falls back automatically.
166
+ *
167
+ * @param locale - Target locale, e.g. 'en', 'es', or any custom locale defined in `messages`.
168
+ * @param messages - Optional map of locale -> partial translation overrides. Can also
169
+ * introduce brand-new locales not built into the plugin.
170
+ */ export function getUiTranslations(locale = 'en', messages) {
171
+ // Layer, in order: built-in en -> built-in locale -> consumer en override -> consumer locale override
172
+ let result = uiTranslations.en;
173
+ if (locale !== 'en' && uiTranslations[locale]) {
174
+ result = deepMerge(result, uiTranslations[locale]);
175
+ }
176
+ if (messages?.en) result = deepMerge(result, messages.en);
177
+ if (locale !== 'en' && messages?.[locale]) result = deepMerge(result, messages[locale]);
178
+ return result;
179
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@main12/auth-login",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
4
4
  "description": "Reusable Payload CMS auth plugin — login, signup, OTP, forgot password, branded emails, Powered by Main12",
5
5
  "license": "MIT",
6
6
  "type": "module",