@asteby/storefront-react 0.12.0 → 0.13.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,432 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ // src/account/account-auth.tsx
7
+ var ES = {
8
+ valueMissing: "Completa este campo.",
9
+ choiceMissing: "Elige una opci\xF3n.",
10
+ email: "Escribe un correo v\xE1lido, por ejemplo nombre@correo.com.",
11
+ tel: "Escribe un tel\xE9fono v\xE1lido.",
12
+ pattern: "Revisa el formato.",
13
+ tooShort: "Escribe al menos {n} caracteres.",
14
+ server: "Revisa este campo.",
15
+ summaryOne: "Revisa 1 campo para continuar",
16
+ summaryMany: "Revisa {n} campos para continuar",
17
+ optional: "(opcional)"
18
+ };
19
+ var EN = {
20
+ valueMissing: "Fill in this field.",
21
+ choiceMissing: "Choose an option.",
22
+ email: "Enter a valid email, like name@example.com.",
23
+ tel: "Enter a valid phone number.",
24
+ pattern: "Check the format.",
25
+ tooShort: "Enter at least {n} characters.",
26
+ server: "Check this field.",
27
+ summaryOne: "Check 1 field to continue",
28
+ summaryMany: "Check {n} fields to continue",
29
+ optional: "(optional)"
30
+ };
31
+ function fieldMessages(locale, overrides) {
32
+ const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN : ES;
33
+ return overrides ? { ...base, ...overrides } : base;
34
+ }
35
+ var isControl = (el) => !!el && typeof el.tagName === "string" && ["INPUT", "SELECT", "TEXTAREA"].includes(el.tagName) && !!el.name;
36
+ function validationMessage(el, m = ES) {
37
+ const v = el.validity;
38
+ if (!v || v.valid) return null;
39
+ const own = el.getAttribute("data-sf-error");
40
+ if (own) return own;
41
+ if (v.valueMissing) return el instanceof HTMLInputElement && (el.type === "radio" || el.type === "checkbox") ? m.choiceMissing : m.valueMissing;
42
+ if (v.typeMismatch && el instanceof HTMLInputElement) return el.type === "email" ? m.email : el.type === "tel" ? m.tel : m.pattern;
43
+ if (v.patternMismatch) return el.getAttribute("title") || (el instanceof HTMLInputElement && el.type === "tel" ? m.tel : m.pattern);
44
+ if (v.tooShort && el instanceof HTMLInputElement) return m.tooShort.replace("{n}", String(el.minLength));
45
+ return el.validationMessage || m.pattern;
46
+ }
47
+ function labelOf(el) {
48
+ if (el instanceof HTMLInputElement && el.type === "radio") {
49
+ const legend = el.closest("fieldset")?.querySelector("legend");
50
+ if (legend?.textContent) return legend.textContent.trim();
51
+ }
52
+ const text = el.labels?.[0]?.getAttribute("data-sf-label") ?? el.labels?.[0]?.textContent ?? el.getAttribute("aria-label") ?? el.name;
53
+ return text.trim();
54
+ }
55
+ function useFieldErrors(formRef, options = {}) {
56
+ const m = fieldMessages(options.locale, options.messages);
57
+ const live = react.useRef(m);
58
+ live.current = m;
59
+ const server = [...options.serverFields ?? []];
60
+ const serverKey = server.join("|");
61
+ const [errors, setErrors] = react.useState(() => Object.fromEntries(server.map((n) => [n, options.serverMessages?.[n] ?? m.server])));
62
+ const [summary, setSummary] = react.useState(null);
63
+ const [summaryKey, setSummaryKey] = react.useState(0);
64
+ react.useEffect(() => {
65
+ if (!server.length) return;
66
+ const form = formRef.current;
67
+ const items = [];
68
+ const next = {};
69
+ for (const name of server) {
70
+ const msg = options.serverMessages?.[name] ?? live.current.server;
71
+ next[name] = msg;
72
+ const el = form?.elements.namedItem(name);
73
+ const ctl = el && "length" in el && !(el instanceof HTMLSelectElement) ? el[0] : el;
74
+ if (ctl) items.push({ name, id: ctl.id || name, label: labelOf(ctl), message: msg });
75
+ }
76
+ setErrors((e) => ({ ...e, ...next }));
77
+ if (items.length) {
78
+ setSummary(items);
79
+ setSummaryKey((k) => k + 1);
80
+ }
81
+ }, [serverKey]);
82
+ react.useEffect(() => {
83
+ const form = formRef.current;
84
+ if (!form) return;
85
+ let batch = null;
86
+ const set = (name, msg) => setErrors((e) => {
87
+ if (msg === null) {
88
+ if (!(name in e)) return e;
89
+ const { [name]: _gone, ...rest } = e;
90
+ return rest;
91
+ }
92
+ return e[name] === msg ? e : { ...e, [name]: msg };
93
+ });
94
+ const onBlur = (ev) => {
95
+ const el = ev.target;
96
+ if (!isControl(el) || el instanceof HTMLInputElement && (el.type === "radio" || el.type === "checkbox" || el.type === "hidden")) return;
97
+ if (!el.value) return;
98
+ set(el.name, validationMessage(el, live.current));
99
+ };
100
+ const onInput = (ev) => {
101
+ const el = ev.target;
102
+ if (!isControl(el)) return;
103
+ setErrors((e) => {
104
+ if (!(el.name in e)) return e;
105
+ const msg = el.validity.valid ? null : validationMessage(el, live.current);
106
+ if (msg !== null) return e;
107
+ const { [el.name]: _gone, ...rest } = e;
108
+ return rest;
109
+ });
110
+ };
111
+ const onInvalid = (ev) => {
112
+ const el = ev.target;
113
+ if (!isControl(el)) return;
114
+ ev.preventDefault();
115
+ if (!batch) {
116
+ batch = [];
117
+ queueMicrotask(() => {
118
+ const list = batch ?? [];
119
+ batch = null;
120
+ const seen = /* @__PURE__ */ new Set();
121
+ const items = [];
122
+ const next = {};
123
+ for (const c of list) {
124
+ if (seen.has(c.name)) continue;
125
+ seen.add(c.name);
126
+ const msg = validationMessage(c, live.current) ?? live.current.valueMissing;
127
+ next[c.name] = msg;
128
+ items.push({ name: c.name, id: c.id || c.name, label: labelOf(c), message: msg });
129
+ }
130
+ setErrors((e) => ({ ...e, ...next }));
131
+ setSummary(items);
132
+ setSummaryKey((k) => k + 1);
133
+ });
134
+ }
135
+ batch.push(el);
136
+ };
137
+ form.addEventListener("focusout", onBlur);
138
+ form.addEventListener("input", onInput);
139
+ form.addEventListener("change", onInput);
140
+ form.addEventListener("invalid", onInvalid, true);
141
+ return () => {
142
+ form.removeEventListener("focusout", onBlur);
143
+ form.removeEventListener("input", onInput);
144
+ form.removeEventListener("change", onInput);
145
+ form.removeEventListener("invalid", onInvalid, true);
146
+ };
147
+ }, [formRef]);
148
+ const shown = summary ? summary.filter((s) => s.name in errors).map((s) => ({ ...s, message: errors[s.name] })) : null;
149
+ return {
150
+ errors,
151
+ summary: shown && shown.length ? shown : null,
152
+ summaryKey,
153
+ clear: () => {
154
+ setErrors({});
155
+ setSummary(null);
156
+ }
157
+ };
158
+ }
159
+ function ErrorSummary({ items, focusKey, locale, messages, title, className, classNames: cx = {} }) {
160
+ const ref = react.useRef(null);
161
+ const m = fieldMessages(locale, messages);
162
+ const has = !!items && items.length > 0;
163
+ react.useEffect(() => {
164
+ if (has) ref.current?.focus();
165
+ }, [focusKey]);
166
+ if (!has) return null;
167
+ const n = items.length;
168
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, role: "alert", tabIndex: -1, className, "data-sf-error-summary": true, "aria-labelledby": "sf-error-summary-title", children: [
169
+ /* @__PURE__ */ jsxRuntime.jsx("p", { id: "sf-error-summary-title", className: cx.title, "data-sf-error-summary-title": true, children: title ?? (n === 1 ? m.summaryOne : m.summaryMany.replace("{n}", String(n))) }),
170
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, children: items.map((it) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
171
+ "a",
172
+ {
173
+ href: `#${it.id}`,
174
+ className: cx.link,
175
+ onClick: (e) => {
176
+ const el = document.getElementById(it.id);
177
+ if (!el) return;
178
+ e.preventDefault();
179
+ el.focus();
180
+ el.scrollIntoView?.({ block: "center" });
181
+ },
182
+ children: [
183
+ it.label,
184
+ ": ",
185
+ it.message
186
+ ]
187
+ }
188
+ ) }, it.name)) })
189
+ ] });
190
+ }
191
+ function CheckoutField(props) {
192
+ const { name, label, id = name, error, hint, optional = false, classNames: cx = {}, locale, messages, ...rest } = props;
193
+ const m = fieldMessages(locale, messages);
194
+ const hintId = hint ? `${id}-hint` : void 0;
195
+ const errorId = `${id}-error`;
196
+ const describedBy = [hintId, error ? errorId : void 0].filter(Boolean).join(" ") || void 0;
197
+ const common = {
198
+ id,
199
+ name,
200
+ required: !optional,
201
+ "aria-invalid": error ? true : void 0,
202
+ "aria-describedby": describedBy,
203
+ className: cx.input,
204
+ "data-sf-field-control": ""
205
+ };
206
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.root, "data-sf-field": true, "data-invalid": error ? "" : void 0, children: [
207
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: id, className: cx.label, "data-sf-label": label, children: [
208
+ label,
209
+ optional ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.optional, "data-sf-field-optional": true, children: [
210
+ " ",
211
+ m.optional
212
+ ] }) : null
213
+ ] }),
214
+ hint ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: hintId, className: cx.hint, "data-sf-field-hint": true, children: hint }) : null,
215
+ rest.as === "select" ? (() => {
216
+ const { as: _as, children, ...select } = rest;
217
+ return /* @__PURE__ */ jsxRuntime.jsx("select", { ...select, ...common, children });
218
+ })() : (() => {
219
+ const { as: _as, ...input } = rest;
220
+ return /* @__PURE__ */ jsxRuntime.jsx("input", { ...input, ...common });
221
+ })(),
222
+ error ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: cx.error, "data-sf-field-error": true, children: error }) : null
223
+ ] });
224
+ }
225
+ var ES2 = {
226
+ titles: {
227
+ login: "Entrar a tu cuenta",
228
+ register: "Crear una cuenta",
229
+ verify: "Confirma tu correo",
230
+ "otp-email": "Entrar con un c\xF3digo",
231
+ otp: "Escribe tu c\xF3digo",
232
+ forgot: "Recuperar contrase\xF1a",
233
+ reset: "Elige una contrase\xF1a nueva"
234
+ },
235
+ email: "Correo electr\xF3nico",
236
+ password: "Contrase\xF1a",
237
+ newPassword: "Contrase\xF1a nueva",
238
+ passwordHint: "Entre 10 y 128 caracteres.",
239
+ firstName: "Nombre",
240
+ lastName: "Apellido",
241
+ code: "C\xF3digo",
242
+ codeSentTo: "Enviamos un c\xF3digo a {email}. Puede tardar un minuto.",
243
+ submit: {
244
+ login: "Entrar",
245
+ register: "Crear cuenta",
246
+ verify: "Confirmar",
247
+ "otp-email": "Enviarme el c\xF3digo",
248
+ otp: "Entrar",
249
+ forgot: "Enviarme el c\xF3digo",
250
+ reset: "Guardar y entrar"
251
+ },
252
+ resend: "Reenviar c\xF3digo",
253
+ forgotLink: "\xBFOlvidaste tu contrase\xF1a?",
254
+ registerLink: "Crear una cuenta",
255
+ loginLink: "Ya tengo cuenta",
256
+ otpLink: "Entrar con un c\xF3digo por correo",
257
+ backToLogin: "Volver a entrar con contrase\xF1a",
258
+ nothingAvailable: "Esta tienda no admite iniciar sesi\xF3n por ahora.",
259
+ errors: {
260
+ invalid_credentials: "El correo o la contrase\xF1a no coinciden.",
261
+ invalid_code: "El c\xF3digo no es v\xE1lido o ya venci\xF3.",
262
+ email_taken: "Ya existe una cuenta con este correo. Entra o recupera tu contrase\xF1a.",
263
+ rate_limited: "Demasiados intentos. Espera unos minutos e int\xE9ntalo de nuevo.",
264
+ validation: "Revisa los datos e int\xE9ntalo de nuevo.",
265
+ unsupported: "Esta forma de entrar no est\xE1 disponible en esta tienda.",
266
+ unavailable: "No pudimos completar la acci\xF3n. Int\xE9ntalo de nuevo en un momento."
267
+ }
268
+ };
269
+ var EN2 = {
270
+ titles: {
271
+ login: "Sign in",
272
+ register: "Create an account",
273
+ verify: "Confirm your email",
274
+ "otp-email": "Sign in with a code",
275
+ otp: "Enter your code",
276
+ forgot: "Reset your password",
277
+ reset: "Choose a new password"
278
+ },
279
+ email: "Email",
280
+ password: "Password",
281
+ newPassword: "New password",
282
+ passwordHint: "Between 10 and 128 characters.",
283
+ firstName: "First name",
284
+ lastName: "Last name",
285
+ code: "Code",
286
+ codeSentTo: "We sent a code to {email}. It can take a minute.",
287
+ submit: {
288
+ login: "Sign in",
289
+ register: "Create account",
290
+ verify: "Confirm",
291
+ "otp-email": "Email me the code",
292
+ otp: "Sign in",
293
+ forgot: "Email me the code",
294
+ reset: "Save and sign in"
295
+ },
296
+ resend: "Resend code",
297
+ forgotLink: "Forgot your password?",
298
+ registerLink: "Create an account",
299
+ loginLink: "I already have an account",
300
+ otpLink: "Sign in with an emailed code",
301
+ backToLogin: "Back to password sign-in",
302
+ nothingAvailable: "This store does not support signing in right now.",
303
+ errors: {
304
+ invalid_credentials: "The email and password do not match.",
305
+ invalid_code: "The code is not valid or has expired.",
306
+ email_taken: "An account with this email already exists. Sign in or reset your password.",
307
+ rate_limited: "Too many attempts. Wait a few minutes and try again.",
308
+ validation: "Check the details and try again.",
309
+ unsupported: "This way of signing in is not available in this store.",
310
+ unavailable: "We could not complete that. Try again in a moment."
311
+ }
312
+ };
313
+ function accountAuthMessages(locale, overrides) {
314
+ const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN2 : ES2;
315
+ if (!overrides) return base;
316
+ return {
317
+ ...base,
318
+ ...overrides,
319
+ titles: { ...base.titles, ...overrides.titles },
320
+ submit: { ...base.submit, ...overrides.submit },
321
+ errors: { ...base.errors, ...overrides.errors }
322
+ };
323
+ }
324
+ var initialOf = (caps, initialView) => initialView ?? (caps.password ? "login" : caps.otp_channels.includes("email") ? "otp-email" : "login");
325
+ function AccountAuth({ capabilities, data, next, pending = false, initialView, form: FormTag = "form", action, locale, messages, classNames: cx = {}, header }) {
326
+ const m = accountAuthMessages(locale, messages);
327
+ const passwordOn = capabilities.password;
328
+ const otpOn = capabilities.otp_channels.includes("email");
329
+ const [view, setView] = react.useState(() => data?.step ?? initialOf(capabilities, initialView));
330
+ const [email, setEmail] = react.useState(data?.email ?? "");
331
+ const ref = react.useRef(null);
332
+ const serverFields = data?.error?.field ? [data.error.field] : null;
333
+ const errorText = data?.error ? m.errors[data.error.code] : null;
334
+ const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields, serverMessages: data?.error?.field && errorText ? { [data.error.field]: errorText } : null });
335
+ react.useEffect(() => {
336
+ if (data?.step) setView(data.step);
337
+ if (data?.email) setEmail(data.email);
338
+ }, [data]);
339
+ const go = (to) => {
340
+ v.clear();
341
+ setView(to);
342
+ };
343
+ const fieldProps = { classNames: cx.field, ...locale ? { locale } : {} };
344
+ const emailField = /* @__PURE__ */ jsxRuntime.jsx(CheckoutField, { ...fieldProps, name: "email", type: "email", label: m.email, autoComplete: "email", inputMode: "email", value: email, onChange: (e) => setEmail(e.currentTarget.value), error: v.errors.email ?? null });
345
+ const codeField = /* @__PURE__ */ jsxRuntime.jsx(CheckoutField, { ...fieldProps, name: "code", label: m.code, autoComplete: "one-time-code", inputMode: "numeric", pattern: "[0-9]*", error: v.errors.code ?? null });
346
+ const passwordField = (label, autoComplete, newPassword) => /* @__PURE__ */ jsxRuntime.jsx(
347
+ CheckoutField,
348
+ {
349
+ ...fieldProps,
350
+ name: "password",
351
+ type: "password",
352
+ label,
353
+ autoComplete,
354
+ error: v.errors.password ?? null,
355
+ ...newPassword ? { minLength: 10, maxLength: 128, hint: m.passwordHint } : {}
356
+ }
357
+ );
358
+ const link = (to, text) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.link, "data-sf-account-link": to, onClick: () => go(to), children: text });
359
+ let body;
360
+ let links = null;
361
+ switch (view) {
362
+ case "register":
363
+ body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
364
+ /* @__PURE__ */ jsxRuntime.jsx(CheckoutField, { ...fieldProps, name: "first_name", label: m.firstName, autoComplete: "given-name", optional: true }),
365
+ /* @__PURE__ */ jsxRuntime.jsx(CheckoutField, { ...fieldProps, name: "last_name", label: m.lastName, autoComplete: "family-name", optional: true }),
366
+ emailField,
367
+ passwordField(m.password, "new-password", true)
368
+ ] });
369
+ links = link("login", m.loginLink);
370
+ break;
371
+ case "verify":
372
+ case "otp":
373
+ body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
374
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.notice, "data-sf-account-notice": true, children: m.codeSentTo.replace("{email}", email) }),
375
+ /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "email", value: email }),
376
+ codeField
377
+ ] });
378
+ links = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
379
+ view === "otp" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", name: "intent", value: "otp-request", formNoValidate: true, className: cx.link, "data-sf-account-link": "resend", children: m.resend }) : null,
380
+ link("login", m.backToLogin)
381
+ ] });
382
+ break;
383
+ case "otp-email":
384
+ case "forgot":
385
+ body = emailField;
386
+ links = link("login", m.backToLogin);
387
+ break;
388
+ case "reset":
389
+ body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
390
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.notice, "data-sf-account-notice": true, children: m.codeSentTo.replace("{email}", email) }),
391
+ /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "email", value: email }),
392
+ codeField,
393
+ passwordField(m.newPassword, "new-password", true)
394
+ ] });
395
+ links = link("login", m.backToLogin);
396
+ break;
397
+ default:
398
+ body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
399
+ emailField,
400
+ passwordField(m.password, "current-password", false)
401
+ ] });
402
+ links = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
403
+ otpOn ? link("forgot", m.forgotLink) : null,
404
+ link("register", m.registerLink),
405
+ otpOn ? link("otp-email", m.otpLink) : null
406
+ ] });
407
+ }
408
+ const intent = { login: "login", register: "register", verify: "verify", "otp-email": "otp-request", otp: "otp-login", forgot: "forgot", reset: "reset" }[view];
409
+ const available = view === "login" || view === "register" || view === "forgot" || view === "reset" || view === "verify" ? passwordOn : otpOn;
410
+ const showSummary = !data?.error?.field;
411
+ const title = m.titles[view];
412
+ if (!available && !passwordOn && !otpOn) {
413
+ return /* @__PURE__ */ jsxRuntime.jsx("section", { className: cx.root, "data-sf-account-auth": true, "data-sf-account-view": "unavailable", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.notice, role: "status", children: m.nothingAvailable }) });
414
+ }
415
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "data-sf-account-auth": true, "data-sf-account-view": view, "aria-labelledby": "sf-account-title", children: [
416
+ header,
417
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { id: "sf-account-title", className: cx.title, children: title }),
418
+ /* @__PURE__ */ jsxRuntime.jsxs(FormTag, { ref, method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": true, children: [
419
+ /* @__PURE__ */ jsxRuntime.jsx(ErrorSummary, { items: v.summary, focusKey: v.summaryKey, ...locale ? { locale } : {} }),
420
+ errorText && showSummary ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: cx.error, "data-sf-account-error": data.error.code, children: errorText }) : null,
421
+ next ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "next", value: next }) : null,
422
+ body,
423
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.actions, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", name: "intent", value: intent, disabled: pending, className: cx.submit, "data-sf-account-submit": true, children: m.submit[view] }) }),
424
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.links, "data-sf-account-links": true, children: links })
425
+ ] })
426
+ ] });
427
+ }
428
+
429
+ exports.AccountAuth = AccountAuth;
430
+ exports.accountAuthMessages = accountAuthMessages;
431
+ //# sourceMappingURL=account.cjs.map
432
+ //# sourceMappingURL=account.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/checkout/fields.tsx","../src/account/account-auth.tsx"],"names":["useRef","useState","useEffect","jsxs","jsx","ES","EN","Fragment"],"mappings":";;;;;;AA6BA,IAAM,EAAA,GAAoB;AAAA,EACxB,YAAA,EAAc,sBAAA;AAAA,EACd,aAAA,EAAe,sBAAA;AAAA,EACf,KAAA,EAAO,6DAAA;AAAA,EACP,GAAA,EAAK,mCAAA;AAAA,EACL,OAAA,EAAS,oBAAA;AAAA,EACT,QAAA,EAAU,kCAAA;AAAA,EACV,MAAA,EAAQ,oBAAA;AA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AA,EAAI,SAAA,EAAW,GAAG,KAAA,EAAO,uBAAA,EAAqB,MAC5C,QAAA,EAAA,KAAA,EACH;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"account.cjs","sourcesContent":["/**\n * Form fields of a checkout with inline validation: a labelled field that shows its own error under it, a focusable\n * error summary for the submit, and one hook that reads the browser's own constraint validation (`required`, `type`,\n * `pattern`, `minLength`...) so the rules stay in the HTML and the page keeps working without JavaScript (then the\n * browser explains the errors itself).\n *\n * WCAG 2.2: errors are identified in text next to the field (3.3.1), linked with `aria-describedby` and `aria-invalid`,\n * and the summary takes focus and links to every field (3.3.1 / 2.4.3). Validation runs when the buyer leaves a field\n * that has a value, and clears as soon as it is fixed: it never nags while typing.\n */\nimport { useEffect, useRef, useState, type InputHTMLAttributes, type ReactNode, type RefObject, type SelectHTMLAttributes } from 'react'\n\nexport type FieldMessages = {\n valueMissing: string\n /** Required radio group (delivery, payment). */\n choiceMissing: string\n email: string\n tel: string\n pattern: string\n /** `{n}` = minimum length. */\n tooShort: string\n /** A field the server rejected. */\n server: string\n /** Error summary title, `{n}` = number of fields. */\n summaryOne: string\n summaryMany: string\n optional: string\n}\n\nconst ES: FieldMessages = {\n valueMissing: 'Completa este campo.',\n choiceMissing: 'Elige una opción.',\n email: 'Escribe un correo válido, por ejemplo nombre@correo.com.',\n tel: 'Escribe un teléfono válido.',\n pattern: 'Revisa el formato.',\n tooShort: 'Escribe al menos {n} caracteres.',\n server: 'Revisa este campo.',\n summaryOne: 'Revisa 1 campo para continuar',\n summaryMany: 'Revisa {n} campos para continuar',\n optional: '(opcional)',\n}\n\nconst EN: FieldMessages = {\n valueMissing: 'Fill in this field.',\n choiceMissing: 'Choose an option.',\n email: 'Enter a valid email, like name@example.com.',\n tel: 'Enter a valid phone number.',\n pattern: 'Check the format.',\n tooShort: 'Enter at least {n} characters.',\n server: 'Check this field.',\n summaryOne: 'Check 1 field to continue',\n summaryMany: 'Check {n} fields to continue',\n optional: '(optional)',\n}\n\n/** Messages for a locale (`es*` default, `en*`), with optional overrides. */\nexport function fieldMessages(locale?: string | null, overrides?: Partial<FieldMessages> | null): FieldMessages {\n const base = (locale ?? 'es-MX').toLowerCase().startsWith('en') ? EN : ES\n return overrides ? { ...base, ...overrides } : base\n}\n\n/** Field name -> error text. */\nexport type FieldErrors = Record<string, string>\n\nexport type ErrorSummaryItem = { name: string; id: string; label: string; message: string }\n\ntype Control = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement\n\nconst isControl = (el: EventTarget | null): el is Control =>\n !!el && typeof (el as Element).tagName === 'string' && ['INPUT', 'SELECT', 'TEXTAREA'].includes((el as Element).tagName) && !!(el as Control).name\n\n/**\n * The error text for a control, from its validity. A control can bring its own text with `data-sf-error` (any\n * failure) or `title` (pattern mismatch, the HTML convention).\n */\nexport function validationMessage(el: Control, m: FieldMessages = ES): string | null {\n const v = el.validity\n if (!v || v.valid) return null\n const own = el.getAttribute('data-sf-error')\n if (own) return own\n if (v.valueMissing) return el instanceof HTMLInputElement && (el.type === 'radio' || el.type === 'checkbox') ? m.choiceMissing : m.valueMissing\n if (v.typeMismatch && el instanceof HTMLInputElement) return el.type === 'email' ? m.email : el.type === 'tel' ? m.tel : m.pattern\n if (v.patternMismatch) return el.getAttribute('title') || (el instanceof HTMLInputElement && el.type === 'tel' ? m.tel : m.pattern)\n if (v.tooShort && el instanceof HTMLInputElement) return m.tooShort.replace('{n}', String(el.minLength))\n return el.validationMessage || m.pattern\n}\n\n/** Visible name of a control: its `<label>`, `aria-label`, or the legend of its group (radios). */\nfunction labelOf(el: Control): string {\n if (el instanceof HTMLInputElement && el.type === 'radio') {\n const legend = el.closest('fieldset')?.querySelector('legend')\n if (legend?.textContent) return legend.textContent.trim()\n }\n const text = el.labels?.[0]?.getAttribute('data-sf-label') ?? el.labels?.[0]?.textContent ?? el.getAttribute('aria-label') ?? el.name\n return text.trim()\n}\n\nexport type UseFieldErrorsOptions = {\n locale?: string\n messages?: Partial<FieldMessages>\n /** Fields the server rejected (e.g. from the action), shown with `serverMessages[name]` or the generic text. */\n serverFields?: Iterable<string> | null\n serverMessages?: Record<string, string> | null\n}\n\nexport type FieldErrorsState = {\n errors: FieldErrors\n /** Non-null after a submit with problems (or with server errors): render it in `<ErrorSummary>`. */\n summary: ErrorSummaryItem[] | null\n /** Changes every time a new summary appears, so `<ErrorSummary>` focuses it again. */\n summaryKey: number\n clear: () => void\n}\n\n/**\n * Inline validation for the page `<form>`. Listens to the form (no wrapping component): leaving a field with a value\n * checks it; typing in a field with an error clears it when fixed; a submit or `reportValidity()` with problems\n * collects them (the browser's bubbles are replaced by the inline texts) for the summary.\n */\nexport function useFieldErrors(formRef: RefObject<HTMLFormElement | null>, options: UseFieldErrorsOptions = {}): FieldErrorsState {\n const m = fieldMessages(options.locale, options.messages)\n const live = useRef(m)\n live.current = m\n const server = [...(options.serverFields ?? [])]\n const serverKey = server.join('|')\n const [errors, setErrors] = useState<FieldErrors>(() => Object.fromEntries(server.map((n) => [n, options.serverMessages?.[n] ?? m.server])))\n const [summary, setSummary] = useState<ErrorSummaryItem[] | null>(null)\n const [summaryKey, setSummaryKey] = useState(0)\n\n // Server errors (a new action result): inline texts plus a summary.\n useEffect(() => {\n if (!server.length) return\n const form = formRef.current\n const items: ErrorSummaryItem[] = []\n const next: FieldErrors = {}\n for (const name of server) {\n const msg = options.serverMessages?.[name] ?? live.current.server\n next[name] = msg\n const el = form?.elements.namedItem(name)\n const ctl = el && 'length' in el && !(el instanceof HTMLSelectElement) ? ((el as RadioNodeList)[0] as Control | undefined) : (el as Control | null)\n if (ctl) items.push({ name, id: ctl.id || name, label: labelOf(ctl), message: msg })\n }\n setErrors((e) => ({ ...e, ...next }))\n if (items.length) {\n setSummary(items)\n setSummaryKey((k) => k + 1)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [serverKey])\n\n useEffect(() => {\n const form = formRef.current\n if (!form) return\n let batch: Control[] | null = null\n const set = (name: string, msg: string | null) =>\n setErrors((e) => {\n if (msg === null) {\n if (!(name in e)) return e\n const { [name]: _gone, ...rest } = e\n return rest\n }\n return e[name] === msg ? e : { ...e, [name]: msg }\n })\n const onBlur = (ev: FocusEvent) => {\n const el = ev.target\n if (!isControl(el) || (el instanceof HTMLInputElement && (el.type === 'radio' || el.type === 'checkbox' || el.type === 'hidden'))) return\n // Leaving an empty field you only tabbed through is not an error yet; it is at submit.\n if (!el.value) return\n set(el.name, validationMessage(el, live.current))\n }\n const onInput = (ev: Event) => {\n const el = ev.target\n if (!isControl(el)) return\n setErrors((e) => {\n if (!(el.name in e)) return e\n const msg = el.validity.valid ? null : validationMessage(el, live.current)\n if (msg !== null) return e // keep the text until the field is fixed (no flicker while typing)\n const { [el.name]: _gone, ...rest } = e\n return rest\n })\n }\n const onInvalid = (ev: Event) => {\n const el = ev.target\n if (!isControl(el)) return\n ev.preventDefault() // the inline text replaces the browser bubble\n if (!batch) {\n batch = []\n queueMicrotask(() => {\n const list = batch ?? []\n batch = null\n const seen = new Set<string>()\n const items: ErrorSummaryItem[] = []\n const next: FieldErrors = {}\n for (const c of list) {\n if (seen.has(c.name)) continue\n seen.add(c.name)\n const msg = validationMessage(c, live.current) ?? live.current.valueMissing\n next[c.name] = msg\n items.push({ name: c.name, id: c.id || c.name, label: labelOf(c), message: msg })\n }\n setErrors((e) => ({ ...e, ...next }))\n setSummary(items)\n setSummaryKey((k) => k + 1)\n })\n }\n batch.push(el)\n }\n form.addEventListener('focusout', onBlur)\n form.addEventListener('input', onInput)\n form.addEventListener('change', onInput)\n form.addEventListener('invalid', onInvalid, true)\n return () => {\n form.removeEventListener('focusout', onBlur)\n form.removeEventListener('input', onInput)\n form.removeEventListener('change', onInput)\n form.removeEventListener('invalid', onInvalid, true)\n }\n }, [formRef])\n\n // The summary follows the fixes: a field fixed after the submit leaves the list.\n const shown = summary ? summary.filter((s) => s.name in errors).map((s) => ({ ...s, message: errors[s.name]! })) : null\n return {\n errors,\n summary: shown && shown.length ? shown : null,\n summaryKey,\n clear: () => {\n setErrors({})\n setSummary(null)\n },\n }\n}\n\nexport type ErrorSummaryProps = {\n items: readonly ErrorSummaryItem[] | null\n /** Changes when a new summary must take focus (`useFieldErrors().summaryKey`). */\n focusKey?: number\n locale?: string\n messages?: Partial<FieldMessages>\n title?: ReactNode\n className?: string\n classNames?: Partial<Record<'title' | 'list' | 'link', string>>\n}\n\n/**\n * The list of problems after a submit, above the form: `role=\"alert\"`, takes focus, one link per field (moves the\n * focus to it). Renders nothing without items.\n */\nexport function ErrorSummary({ items, focusKey, locale, messages, title, className, classNames: cx = {} }: ErrorSummaryProps) {\n const ref = useRef<HTMLDivElement>(null)\n const m = fieldMessages(locale, messages)\n const has = !!items && items.length > 0\n useEffect(() => {\n if (has) ref.current?.focus()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [focusKey])\n if (!has) return null\n const n = items!.length\n return (\n <div ref={ref} role=\"alert\" tabIndex={-1} className={className} data-sf-error-summary aria-labelledby=\"sf-error-summary-title\">\n <p id=\"sf-error-summary-title\" className={cx.title} data-sf-error-summary-title>\n {title ?? (n === 1 ? m.summaryOne : m.summaryMany.replace('{n}', String(n)))}\n </p>\n <ul className={cx.list}>\n {items!.map((it) => (\n <li key={it.name}>\n <a\n href={`#${it.id}`}\n className={cx.link}\n onClick={(e) => {\n const el = document.getElementById(it.id)\n if (!el) return\n e.preventDefault()\n el.focus()\n el.scrollIntoView?.({ block: 'center' })\n }}\n >\n {it.label}: {it.message}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )\n}\n\nexport type CheckoutFieldClassNames = Partial<Record<'root' | 'label' | 'optional' | 'input' | 'hint' | 'error', string>>\n\ntype BaseFieldProps = {\n name: string\n label: string\n /** Field id. Default: the name. */\n id?: string\n /** Error text (from `useFieldErrors().errors[name]` or the server). */\n error?: string | null\n /** Help under the label (\"we only use it for the delivery\"). */\n hint?: ReactNode\n /** Marks the label \"(optional)\" and drops `required`. */\n optional?: boolean\n classNames?: CheckoutFieldClassNames\n locale?: string\n messages?: Partial<FieldMessages>\n}\n\nexport type CheckoutFieldProps = BaseFieldProps & Omit<InputHTMLAttributes<HTMLInputElement>, 'name' | 'id'> & { as?: 'input' }\nexport type CheckoutSelectProps = BaseFieldProps & Omit<SelectHTMLAttributes<HTMLSelectElement>, 'name' | 'id'> & { as: 'select'; children: ReactNode }\n\n/**\n * One labelled field: label (with \"(optional)\"), hint, the control and its error text, wired with `aria-describedby`\n * and `aria-invalid`. Required unless `optional`. `as=\"select\"` renders a `<select>` with the given options.\n */\nexport function CheckoutField(props: CheckoutFieldProps | CheckoutSelectProps) {\n const { name, label, id = name, error, hint, optional = false, classNames: cx = {}, locale, messages, ...rest } = props\n const m = fieldMessages(locale, messages)\n const hintId = hint ? `${id}-hint` : undefined\n const errorId = `${id}-error`\n const describedBy = [hintId, error ? errorId : undefined].filter(Boolean).join(' ') || undefined\n const common = {\n id,\n name,\n required: !optional,\n 'aria-invalid': error ? true : undefined,\n 'aria-describedby': describedBy,\n className: cx.input,\n 'data-sf-field-control': '',\n } as const\n return (\n <div className={cx.root} data-sf-field data-invalid={error ? '' : undefined}>\n <label htmlFor={id} className={cx.label} data-sf-label={label}>\n {label}\n {optional ? (\n <span className={cx.optional} data-sf-field-optional>\n {' '}\n {m.optional}\n </span>\n ) : null}\n </label>\n {hint ? (\n <p id={hintId} className={cx.hint} data-sf-field-hint>\n {hint}\n </p>\n ) : null}\n {rest.as === 'select' ? (\n (() => {\n const { as: _as, children, ...select } = rest\n return (\n <select {...select} {...common}>\n {children}\n </select>\n )\n })()\n ) : (\n (() => {\n const { as: _as, ...input } = rest as CheckoutFieldProps\n return <input {...input} {...common} />\n })()\n )}\n {/* Reserved only when there is an error: the text sits right under its field. */}\n {error ? (\n <p id={errorId} className={cx.error} data-sf-field-error>\n {error}\n </p>\n ) : null}\n </div>\n )\n}\n","/**\n * The account screen: sign in with password, create an account, verify the emailed code, sign in with a code and\n * recover a forgotten password, in one `<form method=\"post\">` driven by `createAuthAction` (`./server`). What the store\n * offers comes from `loadAuthCapabilities`; the form shows only that. Plain HTML: it works without JavaScript for the\n * password sign-in and the steps the action sends back; the view switches (links) need JavaScript.\n *\n * Styling: `data-sf-account-*` attributes and `classNames` slots, fields reuse `CheckoutField` (and `checkout.css`);\n * `account.css` is an optional neutral sheet. Texts are Spanish by default, English with `locale=\"en\"`, any with `messages`.\n */\nimport { useEffect, useRef, useState, type ComponentType, type FormHTMLAttributes, type ReactNode, type Ref } from 'react'\nimport type { CustomerCapabilities } from '@asteby/storefront'\nimport { CheckoutField, ErrorSummary, useFieldErrors, type CheckoutFieldClassNames } from '../checkout/fields.js'\nimport type { AuthActionData, AuthErrorCode, AuthStep } from './types.js'\n\nexport type AccountAuthView = 'login' | 'register' | 'otp-email' | 'forgot' | AuthStep\n\nexport type AccountAuthMessages = {\n titles: Record<AccountAuthView, string>\n email: string\n password: string\n newPassword: string\n passwordHint: string\n firstName: string\n lastName: string\n code: string\n codeSentTo: string\n submit: Record<AccountAuthView, string>\n resend: string\n forgotLink: string\n registerLink: string\n loginLink: string\n otpLink: string\n backToLogin: string\n nothingAvailable: string\n errors: Record<AuthErrorCode, string>\n}\n\nconst ES: AccountAuthMessages = {\n titles: {\n login: 'Entrar a tu cuenta',\n register: 'Crear una cuenta',\n verify: 'Confirma tu correo',\n 'otp-email': 'Entrar con un código',\n otp: 'Escribe tu código',\n forgot: 'Recuperar contraseña',\n reset: 'Elige una contraseña nueva',\n },\n email: 'Correo electrónico',\n password: 'Contraseña',\n newPassword: 'Contraseña nueva',\n passwordHint: 'Entre 10 y 128 caracteres.',\n firstName: 'Nombre',\n lastName: 'Apellido',\n code: 'Código',\n codeSentTo: 'Enviamos un código a {email}. Puede tardar un minuto.',\n submit: {\n login: 'Entrar',\n register: 'Crear cuenta',\n verify: 'Confirmar',\n 'otp-email': 'Enviarme el código',\n otp: 'Entrar',\n forgot: 'Enviarme el código',\n reset: 'Guardar y entrar',\n },\n resend: 'Reenviar código',\n forgotLink: '¿Olvidaste tu contraseña?',\n registerLink: 'Crear una cuenta',\n loginLink: 'Ya tengo cuenta',\n otpLink: 'Entrar con un código por correo',\n backToLogin: 'Volver a entrar con contraseña',\n nothingAvailable: 'Esta tienda no admite iniciar sesión por ahora.',\n errors: {\n invalid_credentials: 'El correo o la contraseña no coinciden.',\n invalid_code: 'El código no es válido o ya venció.',\n email_taken: 'Ya existe una cuenta con este correo. Entra o recupera tu contraseña.',\n rate_limited: 'Demasiados intentos. Espera unos minutos e inténtalo de nuevo.',\n validation: 'Revisa los datos e inténtalo de nuevo.',\n unsupported: 'Esta forma de entrar no está disponible en esta tienda.',\n unavailable: 'No pudimos completar la acción. Inténtalo de nuevo en un momento.',\n },\n}\n\nconst EN: AccountAuthMessages = {\n titles: {\n login: 'Sign in',\n register: 'Create an account',\n verify: 'Confirm your email',\n 'otp-email': 'Sign in with a code',\n otp: 'Enter your code',\n forgot: 'Reset your password',\n reset: 'Choose a new password',\n },\n email: 'Email',\n password: 'Password',\n newPassword: 'New password',\n passwordHint: 'Between 10 and 128 characters.',\n firstName: 'First name',\n lastName: 'Last name',\n code: 'Code',\n codeSentTo: 'We sent a code to {email}. It can take a minute.',\n submit: {\n login: 'Sign in',\n register: 'Create account',\n verify: 'Confirm',\n 'otp-email': 'Email me the code',\n otp: 'Sign in',\n forgot: 'Email me the code',\n reset: 'Save and sign in',\n },\n resend: 'Resend code',\n forgotLink: 'Forgot your password?',\n registerLink: 'Create an account',\n loginLink: 'I already have an account',\n otpLink: 'Sign in with an emailed code',\n backToLogin: 'Back to password sign-in',\n nothingAvailable: 'This store does not support signing in right now.',\n errors: {\n invalid_credentials: 'The email and password do not match.',\n invalid_code: 'The code is not valid or has expired.',\n email_taken: 'An account with this email already exists. Sign in or reset your password.',\n rate_limited: 'Too many attempts. Wait a few minutes and try again.',\n validation: 'Check the details and try again.',\n unsupported: 'This way of signing in is not available in this store.',\n unavailable: 'We could not complete that. Try again in a moment.',\n },\n}\n\n/** Messages for a locale (`es*` default, `en*`), with optional overrides (nested `titles`/`submit`/`errors` merge). */\nexport function accountAuthMessages(locale?: string | null, overrides?: DeepPartial<AccountAuthMessages> | null): AccountAuthMessages {\n const base = (locale ?? 'es-MX').toLowerCase().startsWith('en') ? EN : ES\n if (!overrides) return base\n return {\n ...base,\n ...(overrides as Partial<AccountAuthMessages>),\n titles: { ...base.titles, ...overrides.titles },\n submit: { ...base.submit, ...overrides.submit },\n errors: { ...base.errors, ...overrides.errors },\n }\n}\n\ntype DeepPartial<T> = { [K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K] }\n\nexport type AccountAuthClassNames = Partial<Record<'root' | 'title' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'links' | 'link', string>> & {\n field?: CheckoutFieldClassNames\n}\n\nexport type AccountAuthProps = {\n /** From `loadAuthCapabilities` (the loader). */\n capabilities: CustomerCapabilities\n /** What the action returned (`useActionData()`); drives the next screen and the errors. */\n data?: AuthActionData | null\n /** Where to go after signing in (sent as `next`; the server validates it). */\n next?: string | null\n /** A submit is in flight (`navigation.state !== 'idle'`): disables the buttons. */\n pending?: boolean\n /** First screen. Default `login`, or `otp-email` when the store has no password sign-in. */\n initialView?: AccountAuthView\n /** Form component, e.g. React Router's `Form`, to submit without a reload. It must forward `ref` to the `<form>` (React 19: a prop). Default: the HTML `<form>`. */\n form?: 'form' | ComponentType<FormHTMLAttributes<HTMLFormElement> & { ref?: Ref<HTMLFormElement> }>\n /** `action` of the form (default: the current URL). */\n action?: string\n locale?: string\n messages?: DeepPartial<AccountAuthMessages>\n classNames?: AccountAuthClassNames\n /** Shown above the form (a logo, a welcome text). */\n header?: ReactNode\n}\n\nconst initialOf = (caps: CustomerCapabilities, initialView?: AccountAuthView): AccountAuthView =>\n initialView ?? (caps.password ? 'login' : caps.otp_channels.includes('email') ? 'otp-email' : 'login')\n\n/**\n * The whole account screen. Headless enough to restyle, complete enough to drop in:\n * `export default function Account() { return <AccountAuth capabilities={useLoaderData()} data={useActionData()} form={Form} /> }`.\n */\nexport function AccountAuth({ capabilities, data, next, pending = false, initialView, form: FormTag = 'form', action, locale, messages, classNames: cx = {}, header }: AccountAuthProps) {\n const m = accountAuthMessages(locale, messages)\n const passwordOn = capabilities.password\n const otpOn = capabilities.otp_channels.includes('email')\n const [view, setView] = useState<AccountAuthView>(() => data?.step ?? initialOf(capabilities, initialView))\n const [email, setEmail] = useState(data?.email ?? '')\n const ref = useRef<HTMLFormElement>(null)\n const serverFields = data?.error?.field ? [data.error.field] : null\n const errorText = data?.error ? m.errors[data.error.code] : null\n const v = useFieldErrors(ref, { ...(locale ? { locale } : {}), serverFields, serverMessages: data?.error?.field && errorText ? { [data.error.field]: errorText } : null })\n\n // The action decides the next screen; the email it carries survives it.\n useEffect(() => {\n if (data?.step) setView(data.step)\n if (data?.email) setEmail(data.email)\n }, [data])\n\n const go = (to: AccountAuthView) => {\n v.clear()\n setView(to)\n }\n const fieldProps = { classNames: cx.field, ...(locale ? { locale } : {}) }\n const emailField = (\n <CheckoutField {...fieldProps} name=\"email\" type=\"email\" label={m.email} autoComplete=\"email\" inputMode=\"email\" value={email} onChange={(e) => setEmail(e.currentTarget.value)} error={v.errors.email ?? null} />\n )\n const codeField = (\n <CheckoutField {...fieldProps} name=\"code\" label={m.code} autoComplete=\"one-time-code\" inputMode=\"numeric\" pattern=\"[0-9]*\" error={v.errors.code ?? null} />\n )\n const passwordField = (label: string, autoComplete: string, newPassword: boolean) => (\n <CheckoutField\n {...fieldProps}\n name=\"password\"\n type=\"password\"\n label={label}\n autoComplete={autoComplete}\n error={v.errors.password ?? null}\n {...(newPassword ? { minLength: 10, maxLength: 128, hint: m.passwordHint } : {})}\n />\n )\n const link = (to: AccountAuthView, text: string) => (\n <button type=\"button\" className={cx.link} data-sf-account-link={to} onClick={() => go(to)}>\n {text}\n </button>\n )\n\n let body: ReactNode\n let links: ReactNode = null\n switch (view) {\n case 'register':\n body = (\n <>\n <CheckoutField {...fieldProps} name=\"first_name\" label={m.firstName} autoComplete=\"given-name\" optional />\n <CheckoutField {...fieldProps} name=\"last_name\" label={m.lastName} autoComplete=\"family-name\" optional />\n {emailField}\n {passwordField(m.password, 'new-password', true)}\n </>\n )\n links = link('login', m.loginLink)\n break\n case 'verify':\n case 'otp':\n body = (\n <>\n <p className={cx.notice} data-sf-account-notice>\n {m.codeSentTo.replace('{email}', email)}\n </p>\n <input type=\"hidden\" name=\"email\" value={email} />\n {codeField}\n </>\n )\n links = (\n <>\n {view === 'otp' ? (\n <button type=\"submit\" name=\"intent\" value=\"otp-request\" formNoValidate className={cx.link} data-sf-account-link=\"resend\">\n {m.resend}\n </button>\n ) : null}\n {link('login', m.backToLogin)}\n </>\n )\n break\n case 'otp-email':\n case 'forgot':\n body = emailField\n links = link('login', m.backToLogin)\n break\n case 'reset':\n body = (\n <>\n <p className={cx.notice} data-sf-account-notice>\n {m.codeSentTo.replace('{email}', email)}\n </p>\n <input type=\"hidden\" name=\"email\" value={email} />\n {codeField}\n {passwordField(m.newPassword, 'new-password', true)}\n </>\n )\n links = link('login', m.backToLogin)\n break\n default:\n body = (\n <>\n {emailField}\n {passwordField(m.password, 'current-password', false)}\n </>\n )\n links = (\n <>\n {otpOn ? link('forgot', m.forgotLink) : null}\n {link('register', m.registerLink)}\n {otpOn ? link('otp-email', m.otpLink) : null}\n </>\n )\n }\n\n const intent = { login: 'login', register: 'register', verify: 'verify', 'otp-email': 'otp-request', otp: 'otp-login', forgot: 'forgot', reset: 'reset' }[view]\n // Without password accounts the password views do not exist; only the code sign-in does.\n const available = view === 'login' || view === 'register' || view === 'forgot' || view === 'reset' || view === 'verify' ? passwordOn : otpOn\n const showSummary = !data?.error?.field\n const title = m.titles[view]\n if (!available && !passwordOn && !otpOn) {\n return (\n <section className={cx.root} data-sf-account-auth data-sf-account-view=\"unavailable\">\n <p className={cx.notice} role=\"status\">\n {m.nothingAvailable}\n </p>\n </section>\n )\n }\n return (\n <section className={cx.root} data-sf-account-auth data-sf-account-view={view} aria-labelledby=\"sf-account-title\">\n {header}\n <h1 id=\"sf-account-title\" className={cx.title}>\n {title}\n </h1>\n <FormTag ref={ref as never} method=\"post\" {...(action ? { action } : {})} className={cx.form} data-sf-account-form>\n <ErrorSummary items={v.summary} focusKey={v.summaryKey} {...(locale ? { locale } : {})} />\n {errorText && showSummary ? (\n <p role=\"alert\" className={cx.error} data-sf-account-error={data!.error!.code}>\n {errorText}\n </p>\n ) : null}\n {next ? <input type=\"hidden\" name=\"next\" value={next} /> : null}\n {body}\n <div className={cx.actions}>\n <button type=\"submit\" name=\"intent\" value={intent} disabled={pending} className={cx.submit} data-sf-account-submit>\n {m.submit[view]}\n </button>\n </div>\n <div className={cx.links} data-sf-account-links>\n {links}\n </div>\n </FormTag>\n </section>\n )\n}\n"]}
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Default sheet for <AccountAuth> (`@asteby/storefront-react/account.css`). Optional and neutral; the fields come from
3
+ * `checkout.css`. Variables: --sf-account-max (form width, default 26rem), --sf-account-gap, --sf-account-muted,
4
+ * --sf-field-error (error color, shared with the checkout fields).
5
+ */
6
+ [data-sf-account-auth] {
7
+ max-width: var(--sf-account-max, 26rem);
8
+ margin-inline: auto;
9
+ }
10
+ [data-sf-account-form] {
11
+ display: grid;
12
+ gap: var(--sf-account-gap, 1rem);
13
+ }
14
+ [data-sf-account-error] {
15
+ margin: 0;
16
+ color: var(--sf-field-error, #b42318);
17
+ }
18
+ [data-sf-account-notice] {
19
+ margin: 0;
20
+ color: var(--sf-account-muted, color-mix(in srgb, currentColor 72%, transparent));
21
+ }
22
+ [data-sf-account-submit] {
23
+ min-height: 44px;
24
+ width: 100%;
25
+ }
26
+ [data-sf-account-links] {
27
+ display: flex;
28
+ flex-wrap: wrap;
29
+ gap: 0.5rem 1rem;
30
+ }
31
+ [data-sf-account-link] {
32
+ min-height: 44px;
33
+ padding: 0;
34
+ border: 0;
35
+ background: none;
36
+ color: inherit;
37
+ text-decoration: underline;
38
+ cursor: pointer;
39
+ font: inherit;
40
+ }
@@ -0,0 +1,66 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, FormHTMLAttributes, Ref, ReactNode } from 'react';
3
+ import { CustomerCapabilities } from '@asteby/storefront';
4
+ import { a as CheckoutFieldClassNames } from './fields-vnMUi2HB.cjs';
5
+ import { A as AuthActionData, c as AuthStep, a as AuthErrorCode } from './types-HcEUd9hW.cjs';
6
+ export { b as AuthIntent } from './types-HcEUd9hW.cjs';
7
+
8
+ type AccountAuthView = 'login' | 'register' | 'otp-email' | 'forgot' | AuthStep;
9
+ type AccountAuthMessages = {
10
+ titles: Record<AccountAuthView, string>;
11
+ email: string;
12
+ password: string;
13
+ newPassword: string;
14
+ passwordHint: string;
15
+ firstName: string;
16
+ lastName: string;
17
+ code: string;
18
+ codeSentTo: string;
19
+ submit: Record<AccountAuthView, string>;
20
+ resend: string;
21
+ forgotLink: string;
22
+ registerLink: string;
23
+ loginLink: string;
24
+ otpLink: string;
25
+ backToLogin: string;
26
+ nothingAvailable: string;
27
+ errors: Record<AuthErrorCode, string>;
28
+ };
29
+ /** Messages for a locale (`es*` default, `en*`), with optional overrides (nested `titles`/`submit`/`errors` merge). */
30
+ declare function accountAuthMessages(locale?: string | null, overrides?: DeepPartial<AccountAuthMessages> | null): AccountAuthMessages;
31
+ type DeepPartial<T> = {
32
+ [K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K];
33
+ };
34
+ type AccountAuthClassNames = Partial<Record<'root' | 'title' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'links' | 'link', string>> & {
35
+ field?: CheckoutFieldClassNames;
36
+ };
37
+ type AccountAuthProps = {
38
+ /** From `loadAuthCapabilities` (the loader). */
39
+ capabilities: CustomerCapabilities;
40
+ /** What the action returned (`useActionData()`); drives the next screen and the errors. */
41
+ data?: AuthActionData | null;
42
+ /** Where to go after signing in (sent as `next`; the server validates it). */
43
+ next?: string | null;
44
+ /** A submit is in flight (`navigation.state !== 'idle'`): disables the buttons. */
45
+ pending?: boolean;
46
+ /** First screen. Default `login`, or `otp-email` when the store has no password sign-in. */
47
+ initialView?: AccountAuthView;
48
+ /** Form component, e.g. React Router's `Form`, to submit without a reload. It must forward `ref` to the `<form>` (React 19: a prop). Default: the HTML `<form>`. */
49
+ form?: 'form' | ComponentType<FormHTMLAttributes<HTMLFormElement> & {
50
+ ref?: Ref<HTMLFormElement>;
51
+ }>;
52
+ /** `action` of the form (default: the current URL). */
53
+ action?: string;
54
+ locale?: string;
55
+ messages?: DeepPartial<AccountAuthMessages>;
56
+ classNames?: AccountAuthClassNames;
57
+ /** Shown above the form (a logo, a welcome text). */
58
+ header?: ReactNode;
59
+ };
60
+ /**
61
+ * The whole account screen. Headless enough to restyle, complete enough to drop in:
62
+ * `export default function Account() { return <AccountAuth capabilities={useLoaderData()} data={useActionData()} form={Form} /> }`.
63
+ */
64
+ declare function AccountAuth({ capabilities, data, next, pending, initialView, form: FormTag, action, locale, messages, classNames: cx, header }: AccountAuthProps): react.JSX.Element;
65
+
66
+ export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, AuthActionData, AuthErrorCode, AuthStep, accountAuthMessages };