@asteby/storefront-react 0.17.0 → 0.19.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.
- package/README.md +19 -0
- package/dist/account.cjs +114 -0
- package/dist/account.cjs.map +1 -1
- package/dist/account.d.cts +60 -4
- package/dist/account.d.ts +60 -4
- package/dist/account.js +113 -1
- package/dist/account.js.map +1 -1
- package/dist/checkout.cjs +65 -14
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +7 -0
- package/dist/checkout.d.ts +7 -0
- package/dist/checkout.js +65 -14
- package/dist/checkout.js.map +1 -1
- package/dist/payments.cjs +86 -15
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.css +65 -0
- package/dist/payments.d.cts +24 -3
- package/dist/payments.d.ts +24 -3
- package/dist/payments.js +86 -15
- package/dist/payments.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -797,6 +797,25 @@ export default function Login() {
|
|
|
797
797
|
- `<AccountAuth>`: `classNames` por pieza, atributos `data-sf-account-*`, `locale` (`es` por omisión, `en`), `messages` para cambiar cualquier texto, `form` para el `Form` del router. Con el mock (`createMockStorefront`) funciona entera: código `000000`.
|
|
798
798
|
- Sin JavaScript funciona el inicio de sesión con contraseña y los pasos que devuelve la action; el cambio entre pantallas (enlaces) necesita JavaScript.
|
|
799
799
|
|
|
800
|
+
### Invitación posterior a la compra (`/pagar/gracias`)
|
|
801
|
+
|
|
802
|
+
`<PostPurchaseAccountPrompt>` (`@asteby/storefront-react/account`) invita al invitado a crear cuenta justo después de pagar. Sin estilos propios: `data-sf-ppa-*`, `classNames`, `locale`, `messages`, `form`, `headingLevel`. La tienda lo compone con su diseño y apunta su `action` a la ruta que monta `createAuthAction`.
|
|
803
|
+
|
|
804
|
+
```tsx
|
|
805
|
+
<PostPurchaseAccountPrompt
|
|
806
|
+
email={receipt.email} // del comprobante de la sesión, leído en el servidor
|
|
807
|
+
capabilities={capabilities} // loadAuthCapabilities
|
|
808
|
+
data={actionData} // resultado de createAuthAction
|
|
809
|
+
next="/cuenta/pedidos"
|
|
810
|
+
action="/cuenta/entrar"
|
|
811
|
+
form={Form}
|
|
812
|
+
/>
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
- El correo viaja como campo oculto y no se edita; solo se pide contraseña (o el código por correo si la tienda no tiene contraseñas). No pide dirección ni teléfono.
|
|
816
|
+
- Sin correo válido o sin forma de registrarse no pinta nada. Con verificación de correo la respuesta es la misma exista o no la cuenta (no enumera).
|
|
817
|
+
- El pedido de invitado hecho con ese correo (y su pago pendiente por ficha) aparece en «Mis pedidos» cuando el buzón queda verificado: `storefront_customers` filtra por `customer_id` o por correo VERIFICADO. En una tienda sin verificación de correo la cuenta nace sin verificar y no ve pedidos de invitado; el texto entonces no lo promete.
|
|
818
|
+
|
|
800
819
|
## Facturación y constancia fiscal (`/fiscal`)
|
|
801
820
|
|
|
802
821
|
Subruta `@asteby/storefront-react/fiscal` (+ `/fiscal/server`, + `fiscal.css` opcional). Todo sale de `Region.fiscal_id` (etiquetas, formato, regímenes, usos, documentos); el núcleo no sabe de ningún país. Textos es-MX por omisión, `locale="en"` o `messages` para otros.
|
package/dist/account.cjs
CHANGED
|
@@ -427,8 +427,122 @@ function AccountAuth({ capabilities, data, next, pending = false, initialView, f
|
|
|
427
427
|
] })
|
|
428
428
|
] });
|
|
429
429
|
}
|
|
430
|
+
var ES3 = {
|
|
431
|
+
title: "Crea tu cuenta para seguir tu pedido",
|
|
432
|
+
benefit: "Con {email} ver\xE1s aqu\xED tu pedido y su env\xEDo, y la pr\xF3xima compra ser\xE1 m\xE1s r\xE1pida. No te pedimos tu direcci\xF3n ni tu tel\xE9fono otra vez.",
|
|
433
|
+
benefitBasic: "Guarda tus datos para que la pr\xF3xima compra sea m\xE1s r\xE1pida.",
|
|
434
|
+
accountFor: "Cuenta para {email}",
|
|
435
|
+
password: "Contrase\xF1a",
|
|
436
|
+
passwordHint: "Entre 10 y 128 caracteres.",
|
|
437
|
+
code: "C\xF3digo",
|
|
438
|
+
codeSentTo: "Enviamos un c\xF3digo a {email}. Puede tardar un minuto.",
|
|
439
|
+
submit: "Crear cuenta",
|
|
440
|
+
submitOtp: "Enviarme un c\xF3digo",
|
|
441
|
+
submitCode: "Confirmar",
|
|
442
|
+
skipNote: "Si no quieres cuenta, no pasa nada: te avisaremos por correo de tu pedido.",
|
|
443
|
+
loginLink: "Ya tengo cuenta",
|
|
444
|
+
errors: {
|
|
445
|
+
invalid_credentials: "El correo o la contrase\xF1a no coinciden.",
|
|
446
|
+
invalid_code: "El c\xF3digo no es v\xE1lido o ya venci\xF3.",
|
|
447
|
+
email_taken: "Ya existe una cuenta con este correo. Entra para ver tu pedido.",
|
|
448
|
+
rate_limited: "Demasiados intentos. Espera unos minutos e int\xE9ntalo de nuevo.",
|
|
449
|
+
validation: "Revisa los datos e int\xE9ntalo de nuevo.",
|
|
450
|
+
unsupported: "Esta tienda no permite crear cuentas por ahora.",
|
|
451
|
+
store_misconfigured: "No pudimos crear tu cuenta por un problema de configuraci\xF3n de la tienda. Tu pedido sigue en pie.",
|
|
452
|
+
unavailable: "No pudimos completar la acci\xF3n. Int\xE9ntalo de nuevo en un momento."
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
var EN3 = {
|
|
456
|
+
title: "Create your account to follow your order",
|
|
457
|
+
benefit: "With {email} you will see your order and its shipment here, and your next purchase will be faster. We will not ask for your address or phone again.",
|
|
458
|
+
benefitBasic: "Save your details so your next purchase is faster.",
|
|
459
|
+
accountFor: "Account for {email}",
|
|
460
|
+
password: "Password",
|
|
461
|
+
passwordHint: "Between 10 and 128 characters.",
|
|
462
|
+
code: "Code",
|
|
463
|
+
codeSentTo: "We sent a code to {email}. It can take a minute.",
|
|
464
|
+
submit: "Create account",
|
|
465
|
+
submitOtp: "Email me a code",
|
|
466
|
+
submitCode: "Confirm",
|
|
467
|
+
skipNote: "If you do not want an account, that is fine: we will email you about your order.",
|
|
468
|
+
loginLink: "I already have an account",
|
|
469
|
+
errors: {
|
|
470
|
+
invalid_credentials: "The email and password do not match.",
|
|
471
|
+
invalid_code: "The code is not valid or has expired.",
|
|
472
|
+
email_taken: "An account with this email already exists. Sign in to see your order.",
|
|
473
|
+
rate_limited: "Too many attempts. Wait a few minutes and try again.",
|
|
474
|
+
validation: "Check the details and try again.",
|
|
475
|
+
unsupported: "This store does not allow creating accounts right now.",
|
|
476
|
+
store_misconfigured: "We could not create your account because of a store configuration problem. Your order is safe.",
|
|
477
|
+
unavailable: "We could not complete that. Try again in a moment."
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
function postPurchaseAccountPromptMessages(locale, overrides) {
|
|
481
|
+
const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN3 : ES3;
|
|
482
|
+
if (!overrides) return base;
|
|
483
|
+
return { ...base, ...overrides, errors: { ...base.errors, ...overrides.errors } };
|
|
484
|
+
}
|
|
485
|
+
var validEmail = (v) => typeof v === "string" && v.length <= 254 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim());
|
|
486
|
+
function PostPurchaseAccountPrompt({
|
|
487
|
+
email,
|
|
488
|
+
capabilities,
|
|
489
|
+
data,
|
|
490
|
+
next,
|
|
491
|
+
pending = false,
|
|
492
|
+
form: FormTag = "form",
|
|
493
|
+
action,
|
|
494
|
+
headingLevel = 2,
|
|
495
|
+
loginHref,
|
|
496
|
+
locale,
|
|
497
|
+
messages,
|
|
498
|
+
classNames: cx = {},
|
|
499
|
+
children
|
|
500
|
+
}) {
|
|
501
|
+
const m = postPurchaseAccountPromptMessages(locale, messages);
|
|
502
|
+
const ref = react.useRef(null);
|
|
503
|
+
const passwordOn = capabilities.password;
|
|
504
|
+
const otpOn = capabilities.otp_channels.includes("email");
|
|
505
|
+
const errorText = data?.error ? m.errors[data.error.code] : null;
|
|
506
|
+
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields: data?.error?.field === "code" || data?.error?.field === "password" ? [data.error.field] : null, serverMessages: data?.error?.field && errorText ? { [data.error.field]: errorText } : null });
|
|
507
|
+
if (!validEmail(email) || !passwordOn && !otpOn) return null;
|
|
508
|
+
const address = email.trim().toLowerCase();
|
|
509
|
+
const step = data?.step === "verify" || data?.step === "otp" ? data.step : null;
|
|
510
|
+
const view = step ?? (passwordOn ? "register" : "otp-request");
|
|
511
|
+
const intent = step === "verify" ? "verify" : step === "otp" ? "otp-login" : passwordOn ? "register" : "otp-request";
|
|
512
|
+
const label = view === "verify" || view === "otp" ? m.submitCode : view === "otp-request" ? m.submitOtp : m.submit;
|
|
513
|
+
const Heading = `h${headingLevel}`;
|
|
514
|
+
const fieldProps = { classNames: cx.field, ...locale ? { locale } : {} };
|
|
515
|
+
const showAlert = errorText && !(data?.error?.field === "code" || data?.error?.field === "password");
|
|
516
|
+
const benefit = (capabilities.email_verification ? m.benefit : m.benefitBasic).replace("{email}", address);
|
|
517
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "data-sf-ppa": true, "data-sf-ppa-view": view, "aria-labelledby": "sf-ppa-title", children: [
|
|
518
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { id: "sf-ppa-title", className: cx.title, children: m.title }),
|
|
519
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.text, "data-sf-ppa-benefit": true, children: benefit }),
|
|
520
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FormTag, { ref, method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-ppa-form": true, children: [
|
|
521
|
+
/* @__PURE__ */ jsxRuntime.jsx(ErrorSummary, { items: v.summary, focusKey: v.summaryKey, ...locale ? { locale } : {} }),
|
|
522
|
+
showAlert ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: cx.error, "data-sf-ppa-error": data.error.code, children: errorText }) : null,
|
|
523
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "email", value: address }),
|
|
524
|
+
next ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "next", value: next }) : null,
|
|
525
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.email, "data-sf-ppa-email": true, children: m.accountFor.replace("{email}", address) }),
|
|
526
|
+
step ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.notice, role: "status", "data-sf-ppa-notice": true, children: m.codeSentTo.replace("{email}", address) }),
|
|
528
|
+
/* @__PURE__ */ jsxRuntime.jsx(CheckoutField, { ...fieldProps, name: "code", label: m.code, autoComplete: "one-time-code", inputMode: "numeric", pattern: "[0-9]*", error: v.errors.code ?? null })
|
|
529
|
+
] }) : passwordOn ? /* @__PURE__ */ jsxRuntime.jsx(CheckoutField, { ...fieldProps, name: "password", type: "password", label: m.password, autoComplete: "new-password", minLength: 10, maxLength: 128, hint: m.passwordHint, error: v.errors.password ?? null }) : null,
|
|
530
|
+
/* @__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-ppa-submit": true, children: label }) })
|
|
531
|
+
] }),
|
|
532
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.note, "data-sf-ppa-note": true, children: [
|
|
533
|
+
m.skipNote,
|
|
534
|
+
loginHref ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
535
|
+
" ",
|
|
536
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: loginHref, className: cx.link, "data-sf-ppa-login": true, children: m.loginLink })
|
|
537
|
+
] }) : null
|
|
538
|
+
] }),
|
|
539
|
+
children
|
|
540
|
+
] });
|
|
541
|
+
}
|
|
430
542
|
|
|
431
543
|
exports.AccountAuth = AccountAuth;
|
|
544
|
+
exports.PostPurchaseAccountPrompt = PostPurchaseAccountPrompt;
|
|
432
545
|
exports.accountAuthMessages = accountAuthMessages;
|
|
546
|
+
exports.postPurchaseAccountPromptMessages = postPurchaseAccountPromptMessages;
|
|
433
547
|
//# sourceMappingURL=account.cjs.map
|
|
434
548
|
//# sourceMappingURL=account.cjs.map
|
package/dist/account.cjs.map
CHANGED
|
@@ -1 +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;AAAA,EACR,UAAA,EAAY,+BAAA;AAAA,EACZ,WAAA,EAAa,kCAAA;AAAA,EACb,QAAA,EAAU;AACZ,CAAA;AAEA,IAAM,EAAA,GAAoB;AAAA,EACxB,YAAA,EAAc,qBAAA;AAAA,EACd,aAAA,EAAe,mBAAA;AAAA,EACf,KAAA,EAAO,6CAAA;AAAA,EACP,GAAA,EAAK,6BAAA;AAAA,EACL,OAAA,EAAS,mBAAA;AAAA,EACT,QAAA,EAAU,gCAAA;AAAA,EACV,MAAA,EAAQ,mBAAA;AAAA,EACR,UAAA,EAAY,2BAAA;AAAA,EACZ,WAAA,EAAa,8BAAA;AAAA,EACb,QAAA,EAAU;AACZ,CAAA;AAGO,SAAS,aAAA,CAAc,QAAwB,SAAA,EAA0D;AAC9G,EAAA,MAAM,IAAA,GAAA,CAAQ,UAAU,OAAA,EAAS,WAAA,GAAc,UAAA,CAAW,IAAI,IAAI,EAAA,GAAK,EAAA;AACvE,EAAA,OAAO,YAAY,EAAE,GAAG,IAAA,EAAM,GAAG,WAAU,GAAI,IAAA;AACjD;AASA,IAAM,SAAA,GAAY,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CAAA;AAAA,MACvF,SAAA,IAAa,WAAA,mBACZA,cAAAA,CAAC,OAAE,IAAA,EAAK,OAAA,EAAQ,SAAA,EAAW,EAAA,CAAG,OAAO,uBAAA,EAAuB,IAAA,CAAM,KAAA,CAAO,IAAA,EACtE,qBACH,CAAA,GACE,IAAA;AAAA,MACH,IAAA,mBAAOA,cAAAA,CAAC,OAAA,EAAA,EAAM,IAAA,EAAK,UAAS,IAAA,EAAK,MAAA,EAAO,KAAA,EAAO,IAAA,EAAM,CAAA,GAAK,IAAA;AAAA,MAC1D,IAAA;AAAA,sBACDA,cAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,EAAA,CAAG,OAAA,EACjB,QAAA,kBAAAA,cAAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,QAAA,EAAS,OAAO,MAAA,EAAQ,QAAA,EAAU,OAAA,EAAS,SAAA,EAAW,EAAA,CAAG,MAAA,EAAQ,wBAAA,EAAsB,IAAA,EAC/G,QAAA,EAAA,CAAA,CAAE,MAAA,CAAO,IAAI,CAAA,EAChB,CAAA,EACF,CAAA;AAAA,sBACAA,eAAC,KAAA,EAAA,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 ReactNode } 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 store_misconfigured: 'No pudimos crear tu cuenta por un problema de configuración de la tienda. Puedes comprar como invitado; ya avisamos a la 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 store_misconfigured: 'We could not create your account because of a store configuration problem. You can check out as a guest; we have already told the 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\n/** What `<AccountAuth>` passes to its `form` component: the few props a router `Form` and the HTML `<form>` both accept. */\nexport type AccountFormProps = {\n method?: 'post'\n action?: string\n className?: string\n children?: ReactNode\n /** Loose on purpose: a router `Form` types its ref with its own copy of `@types/react`. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref?: any\n 'data-sf-account-form'?: boolean | string\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<AccountFormProps>\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 {capabilities.unavailable_reason === 'missing_scope' ? m.errors.store_misconfigured : 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/checkout/fields.tsx","../src/account/account-auth.tsx","../src/account/post-purchase-prompt.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;AAAA,EACR,UAAA,EAAY,+BAAA;AAAA,EACZ,WAAA,EAAa,kCAAA;AAAA,EACb,QAAA,EAAU;AACZ,CAAA;AAEA,IAAM,EAAA,GAAoB;AAAA,EACxB,YAAA,EAAc,qBAAA;AAAA,EACd,aAAA,EAAe,mBAAA;AAAA,EACf,KAAA,EAAO,6CAAA;AAAA,EACP,GAAA,EAAK,6BAAA;AAAA,EACL,OAAA,EAAS,mBAAA;AAAA,EACT,QAAA,EAAU,gCAAA;AAAA,EACV,MAAA,EAAQ,mBAAA;AAAA,EACR,UAAA,EAAY,2BAAA;AAAA,EACZ,WAAA,EAAa,8BAAA;AAAA,EACb,QAAA,EAAU;AACZ,CAAA;AAGO,SAAS,aAAA,CAAc,QAAwB,SAAA,EAA0D;AAC9G,EAAA,MAAM,IAAA,GAAA,CAAQ,UAAU,OAAA,EAAS,WAAA,GAAc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SAAA,EAAW,GAAG,OAAA,EACjB,QAAA,kBAAAA,cAAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,MAAK,QAAA,EAAS,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAU,OAAA,EAAS,SAAA,EAAW,GAAG,MAAA,EAAQ,oBAAA,EAAkB,IAAA,EAC3G,QAAA,EAAA,KAAA,EACH,CAAA,EACF;AAAA,KAAA,EACF,CAAA;AAAA,oBACAD,eAAAA,CAAC,GAAA,EAAA,EAAE,WAAW,EAAA,CAAG,IAAA,EAAM,oBAAgB,IAAA,EACpC,QAAA,EAAA;AAAA,MAAA,CAAA,CAAE,QAAA;AAAA,MACF,SAAA,mBACCA,eAAAA,CAAAI,mBAAAA,EAAA,EACG,QAAA,EAAA;AAAA,QAAA,GAAA;AAAA,wBACDH,cAAAA,CAAC,GAAA,EAAA,EAAE,IAAA,EAAM,SAAA,EAAW,SAAA,EAAW,EAAA,CAAG,IAAA,EAAM,mBAAA,EAAiB,IAAA,EACtD,QAAA,EAAA,CAAA,CAAE,SAAA,EACL;AAAA,OAAA,EACF,CAAA,GACE;AAAA,KAAA,EACN,CAAA;AAAA,IACC;AAAA,GAAA,EACH,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 ReactNode } 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 store_misconfigured: 'No pudimos crear tu cuenta por un problema de configuración de la tienda. Puedes comprar como invitado; ya avisamos a la 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 store_misconfigured: 'We could not create your account because of a store configuration problem. You can check out as a guest; we have already told the 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\n/** What `<AccountAuth>` passes to its `form` component: the few props a router `Form` and the HTML `<form>` both accept. */\nexport type AccountFormProps = {\n method?: 'post'\n action?: string\n className?: string\n children?: ReactNode\n /** Loose on purpose: a router `Form` types its ref with its own copy of `@types/react`. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref?: any\n 'data-sf-account-form'?: boolean | string\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<AccountFormProps>\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 {capabilities.unavailable_reason === 'missing_scope' ? m.errors.store_misconfigured : 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","/**\n * Post-purchase invitation to create an account, for the thank-you page (`/pagar/gracias`). Headless: no styles of its\n * own, `data-sf-ppa-*` hooks and `classNames` slots. It reuses the account action (`createAuthAction`, `./server`):\n * the form posts `register` (or `otp-request` in a store without passwords) with the buyer's email, so the verification,\n * the session cookie and the errors are exactly the ones of `<AccountAuth>`; nothing about addresses or phones is asked.\n *\n * Privacy: the email is the one of the receipt the SERVER read from the buyer's own session (the `email` prop); it is\n * sent as a hidden field and never editable here, so the form cannot be used to probe other addresses. With email\n * verification the action answers the same whether or not the address already has an account (no enumeration); the\n * guest orders of that address show up in the order history once the mailbox is verified (the store's addon scopes by\n * VERIFIED email). Without verification the account is created unverified and its history does not include guest\n * orders: the text then promises nothing about the order.\n *\n * Texts are Spanish by default, English with `locale=\"en\"`, any with `messages`.\n */\nimport { useRef, type ComponentType, type ReactNode } from 'react'\nimport type { CustomerCapabilities } from '@asteby/storefront'\nimport { CheckoutField, ErrorSummary, useFieldErrors, type CheckoutFieldClassNames } from '../checkout/fields.js'\nimport type { AccountFormProps } from './account-auth.js'\nimport type { AuthActionData, AuthErrorCode } from './types.js'\n\nexport type PostPurchaseAccountPromptMessages = {\n title: string\n /** Why, when the email is verified and the guest order will appear in the history. `{email}` is replaced. */\n benefit: string\n /** Why, when it will not (no email verification in the store). */\n benefitBasic: string\n accountFor: string\n password: string\n passwordHint: string\n code: string\n codeSentTo: string\n submit: string\n submitOtp: string\n submitCode: string\n skipNote: string\n loginLink: string\n errors: Record<AuthErrorCode, string>\n}\n\nconst ES: PostPurchaseAccountPromptMessages = {\n title: 'Crea tu cuenta para seguir tu pedido',\n benefit: 'Con {email} verás aquí tu pedido y su envío, y la próxima compra será más rápida. No te pedimos tu dirección ni tu teléfono otra vez.',\n benefitBasic: 'Guarda tus datos para que la próxima compra sea más rápida.',\n accountFor: 'Cuenta para {email}',\n password: 'Contraseña',\n passwordHint: 'Entre 10 y 128 caracteres.',\n code: 'Código',\n codeSentTo: 'Enviamos un código a {email}. Puede tardar un minuto.',\n submit: 'Crear cuenta',\n submitOtp: 'Enviarme un código',\n submitCode: 'Confirmar',\n skipNote: 'Si no quieres cuenta, no pasa nada: te avisaremos por correo de tu pedido.',\n loginLink: 'Ya tengo cuenta',\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 para ver tu pedido.',\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 tienda no permite crear cuentas por ahora.',\n store_misconfigured: 'No pudimos crear tu cuenta por un problema de configuración de la tienda. Tu pedido sigue en pie.',\n unavailable: 'No pudimos completar la acción. Inténtalo de nuevo en un momento.',\n },\n}\n\nconst EN: PostPurchaseAccountPromptMessages = {\n title: 'Create your account to follow your order',\n benefit: 'With {email} you will see your order and its shipment here, and your next purchase will be faster. We will not ask for your address or phone again.',\n benefitBasic: 'Save your details so your next purchase is faster.',\n accountFor: 'Account for {email}',\n password: 'Password',\n passwordHint: 'Between 10 and 128 characters.',\n code: 'Code',\n codeSentTo: 'We sent a code to {email}. It can take a minute.',\n submit: 'Create account',\n submitOtp: 'Email me a code',\n submitCode: 'Confirm',\n skipNote: 'If you do not want an account, that is fine: we will email you about your order.',\n loginLink: 'I already have an account',\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 to see your order.',\n rate_limited: 'Too many attempts. Wait a few minutes and try again.',\n validation: 'Check the details and try again.',\n unsupported: 'This store does not allow creating accounts right now.',\n store_misconfigured: 'We could not create your account because of a store configuration problem. Your order is safe.',\n unavailable: 'We could not complete that. Try again in a moment.',\n },\n}\n\ntype DeepPartial<T> = { [K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K] }\n\n/** Messages for a locale (`es*` default, `en*`), with optional overrides (`errors` merges). */\nexport function postPurchaseAccountPromptMessages(locale?: string | null, overrides?: DeepPartial<PostPurchaseAccountPromptMessages> | null): PostPurchaseAccountPromptMessages {\n const base = (locale ?? 'es-MX').toLowerCase().startsWith('en') ? EN : ES\n if (!overrides) return base\n return { ...base, ...(overrides as Partial<PostPurchaseAccountPromptMessages>), errors: { ...base.errors, ...overrides.errors } }\n}\n\nexport type PostPurchaseAccountPromptClassNames = Partial<Record<'root' | 'title' | 'text' | 'email' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'note' | 'link', string>> & {\n field?: CheckoutFieldClassNames\n}\n\nexport type PostPurchaseAccountPromptProps = {\n /** The buyer's email from the receipt of THIS session (read on the server). Without it nothing renders. */\n email?: string | null\n /** From `loadAuthCapabilities`. Without password nor email codes nothing renders. */\n capabilities: CustomerCapabilities\n /** What the account action returned (`useActionData()`); drives the code step and the errors. */\n data?: AuthActionData | null\n /** Where to go after the account is ready (sent as `next`; the server validates it). E.g. the order history. */\n next?: string | null\n /** A submit is in flight: disables the button. */\n pending?: boolean\n /** Form component, e.g. React Router's `Form`. Default: the HTML `<form>`. */\n form?: 'form' | ComponentType<AccountFormProps>\n /** `action` of the form: the route that mounts `createAuthAction`. Default: the current URL. */\n action?: string\n /** Heading level of the title (default 2). */\n headingLevel?: 2 | 3 | 4\n /** Where \"I already have an account\" goes (e.g. `/cuenta/entrar?next=...`). Omitted: no link. */\n loginHref?: string | null\n locale?: string\n messages?: DeepPartial<PostPurchaseAccountPromptMessages>\n classNames?: PostPurchaseAccountPromptClassNames\n /** Extra content under the form. */\n children?: ReactNode\n}\n\nconst validEmail = (v: string | null | undefined): v is string => typeof v === 'string' && v.length <= 254 && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v.trim())\n\n/**\n * `<PostPurchaseAccountPrompt email={receipt.email} capabilities={caps} data={actionData} form={Form} next=\"/cuenta/pedidos\" />`\n */\nexport function PostPurchaseAccountPrompt({\n email,\n capabilities,\n data,\n next,\n pending = false,\n form: FormTag = 'form',\n action,\n headingLevel = 2,\n loginHref,\n locale,\n messages,\n classNames: cx = {},\n children,\n}: PostPurchaseAccountPromptProps) {\n const m = postPurchaseAccountPromptMessages(locale, messages)\n const ref = useRef<HTMLFormElement>(null)\n const passwordOn = capabilities.password\n const otpOn = capabilities.otp_channels.includes('email')\n const errorText = data?.error ? m.errors[data.error.code] : null\n const v = useFieldErrors(ref, { ...(locale ? { locale } : {}), serverFields: data?.error?.field === 'code' || data?.error?.field === 'password' ? [data.error.field] : null, serverMessages: data?.error?.field && errorText ? { [data.error.field]: errorText } : null })\n if (!validEmail(email) || (!passwordOn && !otpOn)) return null\n\n const address = email.trim().toLowerCase()\n const step = data?.step === 'verify' || data?.step === 'otp' ? data.step : null\n const view = step ?? (passwordOn ? 'register' : 'otp-request')\n const intent = step === 'verify' ? 'verify' : step === 'otp' ? 'otp-login' : passwordOn ? 'register' : 'otp-request'\n const label = view === 'verify' || view === 'otp' ? m.submitCode : view === 'otp-request' ? m.submitOtp : m.submit\n const Heading = `h${headingLevel}` as 'h2'\n const fieldProps = { classNames: cx.field, ...(locale ? { locale } : {}) }\n // Only the errors with no field of their own go in the alert; the others are inline.\n const showAlert = errorText && !(data?.error?.field === 'code' || data?.error?.field === 'password')\n // Only a verified mailbox earns the guest order in the history (storefront_customers scopes by verified email).\n const benefit = (capabilities.email_verification ? m.benefit : m.benefitBasic).replace('{email}', address)\n\n return (\n <section className={cx.root} data-sf-ppa data-sf-ppa-view={view} aria-labelledby=\"sf-ppa-title\">\n <Heading id=\"sf-ppa-title\" className={cx.title}>\n {m.title}\n </Heading>\n <p className={cx.text} data-sf-ppa-benefit>\n {benefit}\n </p>\n <FormTag ref={ref as never} method=\"post\" {...(action ? { action } : {})} className={cx.form} data-sf-ppa-form>\n <ErrorSummary items={v.summary} focusKey={v.summaryKey} {...(locale ? { locale } : {})} />\n {showAlert ? (\n <p role=\"alert\" className={cx.error} data-sf-ppa-error={data!.error!.code}>\n {errorText}\n </p>\n ) : null}\n <input type=\"hidden\" name=\"email\" value={address} />\n {next ? <input type=\"hidden\" name=\"next\" value={next} /> : null}\n <p className={cx.email} data-sf-ppa-email>\n {m.accountFor.replace('{email}', address)}\n </p>\n {step ? (\n <>\n <p className={cx.notice} role=\"status\" data-sf-ppa-notice>\n {m.codeSentTo.replace('{email}', address)}\n </p>\n <CheckoutField {...fieldProps} name=\"code\" label={m.code} autoComplete=\"one-time-code\" inputMode=\"numeric\" pattern=\"[0-9]*\" error={v.errors.code ?? null} />\n </>\n ) : passwordOn ? (\n <CheckoutField {...fieldProps} name=\"password\" type=\"password\" label={m.password} autoComplete=\"new-password\" minLength={10} maxLength={128} hint={m.passwordHint} error={v.errors.password ?? null} />\n ) : null}\n <div className={cx.actions}>\n <button type=\"submit\" name=\"intent\" value={intent} disabled={pending} className={cx.submit} data-sf-ppa-submit>\n {label}\n </button>\n </div>\n </FormTag>\n <p className={cx.note} data-sf-ppa-note>\n {m.skipNote}\n {loginHref ? (\n <>\n {' '}\n <a href={loginHref} className={cx.link} data-sf-ppa-login>\n {m.loginLink}\n </a>\n </>\n ) : null}\n </p>\n {children}\n </section>\n )\n}\n"]}
|
package/dist/account.d.cts
CHANGED
|
@@ -27,8 +27,8 @@ type AccountAuthMessages = {
|
|
|
27
27
|
errors: Record<AuthErrorCode, string>;
|
|
28
28
|
};
|
|
29
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> = {
|
|
30
|
+
declare function accountAuthMessages(locale?: string | null, overrides?: DeepPartial$1<AccountAuthMessages> | null): AccountAuthMessages;
|
|
31
|
+
type DeepPartial$1<T> = {
|
|
32
32
|
[K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K];
|
|
33
33
|
};
|
|
34
34
|
type AccountAuthClassNames = Partial<Record<'root' | 'title' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'links' | 'link', string>> & {
|
|
@@ -60,7 +60,7 @@ type AccountAuthProps = {
|
|
|
60
60
|
/** `action` of the form (default: the current URL). */
|
|
61
61
|
action?: string;
|
|
62
62
|
locale?: string;
|
|
63
|
-
messages?: DeepPartial<AccountAuthMessages>;
|
|
63
|
+
messages?: DeepPartial$1<AccountAuthMessages>;
|
|
64
64
|
classNames?: AccountAuthClassNames;
|
|
65
65
|
/** Shown above the form (a logo, a welcome text). */
|
|
66
66
|
header?: ReactNode;
|
|
@@ -71,4 +71,60 @@ type AccountAuthProps = {
|
|
|
71
71
|
*/
|
|
72
72
|
declare function AccountAuth({ capabilities, data, next, pending, initialView, form: FormTag, action, locale, messages, classNames: cx, header }: AccountAuthProps): react.JSX.Element;
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
type PostPurchaseAccountPromptMessages = {
|
|
75
|
+
title: string;
|
|
76
|
+
/** Why, when the email is verified and the guest order will appear in the history. `{email}` is replaced. */
|
|
77
|
+
benefit: string;
|
|
78
|
+
/** Why, when it will not (no email verification in the store). */
|
|
79
|
+
benefitBasic: string;
|
|
80
|
+
accountFor: string;
|
|
81
|
+
password: string;
|
|
82
|
+
passwordHint: string;
|
|
83
|
+
code: string;
|
|
84
|
+
codeSentTo: string;
|
|
85
|
+
submit: string;
|
|
86
|
+
submitOtp: string;
|
|
87
|
+
submitCode: string;
|
|
88
|
+
skipNote: string;
|
|
89
|
+
loginLink: string;
|
|
90
|
+
errors: Record<AuthErrorCode, string>;
|
|
91
|
+
};
|
|
92
|
+
type DeepPartial<T> = {
|
|
93
|
+
[K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K];
|
|
94
|
+
};
|
|
95
|
+
/** Messages for a locale (`es*` default, `en*`), with optional overrides (`errors` merges). */
|
|
96
|
+
declare function postPurchaseAccountPromptMessages(locale?: string | null, overrides?: DeepPartial<PostPurchaseAccountPromptMessages> | null): PostPurchaseAccountPromptMessages;
|
|
97
|
+
type PostPurchaseAccountPromptClassNames = Partial<Record<'root' | 'title' | 'text' | 'email' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'note' | 'link', string>> & {
|
|
98
|
+
field?: CheckoutFieldClassNames;
|
|
99
|
+
};
|
|
100
|
+
type PostPurchaseAccountPromptProps = {
|
|
101
|
+
/** The buyer's email from the receipt of THIS session (read on the server). Without it nothing renders. */
|
|
102
|
+
email?: string | null;
|
|
103
|
+
/** From `loadAuthCapabilities`. Without password nor email codes nothing renders. */
|
|
104
|
+
capabilities: CustomerCapabilities;
|
|
105
|
+
/** What the account action returned (`useActionData()`); drives the code step and the errors. */
|
|
106
|
+
data?: AuthActionData | null;
|
|
107
|
+
/** Where to go after the account is ready (sent as `next`; the server validates it). E.g. the order history. */
|
|
108
|
+
next?: string | null;
|
|
109
|
+
/** A submit is in flight: disables the button. */
|
|
110
|
+
pending?: boolean;
|
|
111
|
+
/** Form component, e.g. React Router's `Form`. Default: the HTML `<form>`. */
|
|
112
|
+
form?: 'form' | ComponentType<AccountFormProps>;
|
|
113
|
+
/** `action` of the form: the route that mounts `createAuthAction`. Default: the current URL. */
|
|
114
|
+
action?: string;
|
|
115
|
+
/** Heading level of the title (default 2). */
|
|
116
|
+
headingLevel?: 2 | 3 | 4;
|
|
117
|
+
/** Where "I already have an account" goes (e.g. `/cuenta/entrar?next=...`). Omitted: no link. */
|
|
118
|
+
loginHref?: string | null;
|
|
119
|
+
locale?: string;
|
|
120
|
+
messages?: DeepPartial<PostPurchaseAccountPromptMessages>;
|
|
121
|
+
classNames?: PostPurchaseAccountPromptClassNames;
|
|
122
|
+
/** Extra content under the form. */
|
|
123
|
+
children?: ReactNode;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* `<PostPurchaseAccountPrompt email={receipt.email} capabilities={caps} data={actionData} form={Form} next="/cuenta/pedidos" />`
|
|
127
|
+
*/
|
|
128
|
+
declare function PostPurchaseAccountPrompt({ email, capabilities, data, next, pending, form: FormTag, action, headingLevel, loginHref, locale, messages, classNames: cx, children, }: PostPurchaseAccountPromptProps): react.JSX.Element | null;
|
|
129
|
+
|
|
130
|
+
export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, type AccountFormProps, AuthActionData, AuthErrorCode, AuthStep, PostPurchaseAccountPrompt, type PostPurchaseAccountPromptClassNames, type PostPurchaseAccountPromptMessages, type PostPurchaseAccountPromptProps, accountAuthMessages, postPurchaseAccountPromptMessages };
|
package/dist/account.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ type AccountAuthMessages = {
|
|
|
27
27
|
errors: Record<AuthErrorCode, string>;
|
|
28
28
|
};
|
|
29
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> = {
|
|
30
|
+
declare function accountAuthMessages(locale?: string | null, overrides?: DeepPartial$1<AccountAuthMessages> | null): AccountAuthMessages;
|
|
31
|
+
type DeepPartial$1<T> = {
|
|
32
32
|
[K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K];
|
|
33
33
|
};
|
|
34
34
|
type AccountAuthClassNames = Partial<Record<'root' | 'title' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'links' | 'link', string>> & {
|
|
@@ -60,7 +60,7 @@ type AccountAuthProps = {
|
|
|
60
60
|
/** `action` of the form (default: the current URL). */
|
|
61
61
|
action?: string;
|
|
62
62
|
locale?: string;
|
|
63
|
-
messages?: DeepPartial<AccountAuthMessages>;
|
|
63
|
+
messages?: DeepPartial$1<AccountAuthMessages>;
|
|
64
64
|
classNames?: AccountAuthClassNames;
|
|
65
65
|
/** Shown above the form (a logo, a welcome text). */
|
|
66
66
|
header?: ReactNode;
|
|
@@ -71,4 +71,60 @@ type AccountAuthProps = {
|
|
|
71
71
|
*/
|
|
72
72
|
declare function AccountAuth({ capabilities, data, next, pending, initialView, form: FormTag, action, locale, messages, classNames: cx, header }: AccountAuthProps): react.JSX.Element;
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
type PostPurchaseAccountPromptMessages = {
|
|
75
|
+
title: string;
|
|
76
|
+
/** Why, when the email is verified and the guest order will appear in the history. `{email}` is replaced. */
|
|
77
|
+
benefit: string;
|
|
78
|
+
/** Why, when it will not (no email verification in the store). */
|
|
79
|
+
benefitBasic: string;
|
|
80
|
+
accountFor: string;
|
|
81
|
+
password: string;
|
|
82
|
+
passwordHint: string;
|
|
83
|
+
code: string;
|
|
84
|
+
codeSentTo: string;
|
|
85
|
+
submit: string;
|
|
86
|
+
submitOtp: string;
|
|
87
|
+
submitCode: string;
|
|
88
|
+
skipNote: string;
|
|
89
|
+
loginLink: string;
|
|
90
|
+
errors: Record<AuthErrorCode, string>;
|
|
91
|
+
};
|
|
92
|
+
type DeepPartial<T> = {
|
|
93
|
+
[K in keyof T]?: T[K] extends Record<string, string> ? Partial<T[K]> : T[K];
|
|
94
|
+
};
|
|
95
|
+
/** Messages for a locale (`es*` default, `en*`), with optional overrides (`errors` merges). */
|
|
96
|
+
declare function postPurchaseAccountPromptMessages(locale?: string | null, overrides?: DeepPartial<PostPurchaseAccountPromptMessages> | null): PostPurchaseAccountPromptMessages;
|
|
97
|
+
type PostPurchaseAccountPromptClassNames = Partial<Record<'root' | 'title' | 'text' | 'email' | 'form' | 'notice' | 'error' | 'actions' | 'submit' | 'note' | 'link', string>> & {
|
|
98
|
+
field?: CheckoutFieldClassNames;
|
|
99
|
+
};
|
|
100
|
+
type PostPurchaseAccountPromptProps = {
|
|
101
|
+
/** The buyer's email from the receipt of THIS session (read on the server). Without it nothing renders. */
|
|
102
|
+
email?: string | null;
|
|
103
|
+
/** From `loadAuthCapabilities`. Without password nor email codes nothing renders. */
|
|
104
|
+
capabilities: CustomerCapabilities;
|
|
105
|
+
/** What the account action returned (`useActionData()`); drives the code step and the errors. */
|
|
106
|
+
data?: AuthActionData | null;
|
|
107
|
+
/** Where to go after the account is ready (sent as `next`; the server validates it). E.g. the order history. */
|
|
108
|
+
next?: string | null;
|
|
109
|
+
/** A submit is in flight: disables the button. */
|
|
110
|
+
pending?: boolean;
|
|
111
|
+
/** Form component, e.g. React Router's `Form`. Default: the HTML `<form>`. */
|
|
112
|
+
form?: 'form' | ComponentType<AccountFormProps>;
|
|
113
|
+
/** `action` of the form: the route that mounts `createAuthAction`. Default: the current URL. */
|
|
114
|
+
action?: string;
|
|
115
|
+
/** Heading level of the title (default 2). */
|
|
116
|
+
headingLevel?: 2 | 3 | 4;
|
|
117
|
+
/** Where "I already have an account" goes (e.g. `/cuenta/entrar?next=...`). Omitted: no link. */
|
|
118
|
+
loginHref?: string | null;
|
|
119
|
+
locale?: string;
|
|
120
|
+
messages?: DeepPartial<PostPurchaseAccountPromptMessages>;
|
|
121
|
+
classNames?: PostPurchaseAccountPromptClassNames;
|
|
122
|
+
/** Extra content under the form. */
|
|
123
|
+
children?: ReactNode;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* `<PostPurchaseAccountPrompt email={receipt.email} capabilities={caps} data={actionData} form={Form} next="/cuenta/pedidos" />`
|
|
127
|
+
*/
|
|
128
|
+
declare function PostPurchaseAccountPrompt({ email, capabilities, data, next, pending, form: FormTag, action, headingLevel, loginHref, locale, messages, classNames: cx, children, }: PostPurchaseAccountPromptProps): react.JSX.Element | null;
|
|
129
|
+
|
|
130
|
+
export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, type AccountFormProps, AuthActionData, AuthErrorCode, AuthStep, PostPurchaseAccountPrompt, type PostPurchaseAccountPromptClassNames, type PostPurchaseAccountPromptMessages, type PostPurchaseAccountPromptProps, accountAuthMessages, postPurchaseAccountPromptMessages };
|