@asteby/storefront-react 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/dist/account-server.cjs +128 -19
- package/dist/account-server.cjs.map +1 -1
- package/dist/account-server.d.cts +67 -4
- package/dist/account-server.d.ts +67 -4
- package/dist/account-server.js +125 -20
- package/dist/account-server.js.map +1 -1
- package/dist/account.cjs +252 -7
- package/dist/account.cjs.map +1 -1
- package/dist/account.css +91 -0
- package/dist/account.d.cts +130 -6
- package/dist/account.d.ts +130 -6
- package/dist/account.js +247 -8
- package/dist/account.js.map +1 -1
- package/dist/checkout.cjs +162 -8
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +104 -4
- package/dist/checkout.d.ts +104 -4
- package/dist/checkout.js +158 -10
- package/dist/checkout.js.map +1 -1
- package/dist/chunk-Z4C4LKXF.js +25 -0
- package/dist/chunk-Z4C4LKXF.js.map +1 -0
- package/dist/fiscal-server.cjs +27 -2
- package/dist/fiscal-server.cjs.map +1 -1
- package/dist/fiscal-server.d.cts +10 -1
- package/dist/fiscal-server.d.ts +10 -1
- package/dist/fiscal-server.js +26 -3
- package/dist/fiscal-server.js.map +1 -1
- package/dist/fit-key-B9sYQVwG.d.cts +49 -0
- package/dist/fit-key-B9sYQVwG.d.ts +49 -0
- package/dist/fitment.cjs +54 -9
- package/dist/fitment.cjs.map +1 -1
- package/dist/fitment.d.cts +20 -2
- package/dist/fitment.d.ts +20 -2
- package/dist/fitment.js +54 -10
- package/dist/fitment.js.map +1 -1
- package/dist/settings-types-jxFQFFqP.d.cts +77 -0
- package/dist/settings-types-jxFQFFqP.d.ts +77 -0
- package/dist/subjects-server.cjs +248 -0
- package/dist/subjects-server.cjs.map +1 -0
- package/dist/subjects-server.d.cts +130 -0
- package/dist/subjects-server.d.ts +130 -0
- package/dist/subjects-server.js +217 -0
- package/dist/subjects-server.js.map +1 -0
- package/dist/subjects.cjs +501 -0
- package/dist/subjects.cjs.map +1 -0
- package/dist/subjects.css +166 -0
- package/dist/subjects.d.cts +178 -0
- package/dist/subjects.d.ts +178 -0
- package/dist/subjects.js +465 -0
- package/dist/subjects.js.map +1 -0
- package/package.json +23 -2
- package/dist/types-D7pVK0GK.d.cts +0 -39
- package/dist/types-D7pVK0GK.d.ts +0 -39
package/dist/account.js
CHANGED
|
@@ -121,8 +121,8 @@ function AccountAuth({ capabilities, data, next, pending = false, initialView, f
|
|
|
121
121
|
const [email, setEmail] = useState(data?.email ?? "");
|
|
122
122
|
const ref = useRef(null);
|
|
123
123
|
const serverFields = data?.error?.field ? [data.error.field] : null;
|
|
124
|
-
const
|
|
125
|
-
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields, serverMessages: data?.error?.field &&
|
|
124
|
+
const errorText2 = data?.error ? m.errors[data.error.code] : null;
|
|
125
|
+
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields, serverMessages: data?.error?.field && errorText2 ? { [data.error.field]: errorText2 } : null });
|
|
126
126
|
useEffect(() => {
|
|
127
127
|
if (data?.step) setView(data.step);
|
|
128
128
|
if (data?.email) setEmail(data.email);
|
|
@@ -208,7 +208,7 @@ function AccountAuth({ capabilities, data, next, pending = false, initialView, f
|
|
|
208
208
|
/* @__PURE__ */ jsx("h1", { id: "sf-account-title", className: cx.title, children: title }),
|
|
209
209
|
/* @__PURE__ */ jsxs(FormTag, { ref, method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": true, children: [
|
|
210
210
|
/* @__PURE__ */ jsx(ErrorSummary, { items: v.summary, focusKey: v.summaryKey, ...locale ? { locale } : {} }),
|
|
211
|
-
|
|
211
|
+
errorText2 && showSummary ? /* @__PURE__ */ jsx("p", { role: "alert", className: cx.error, "data-sf-account-error": data.error.code, children: errorText2 }) : null,
|
|
212
212
|
next ? /* @__PURE__ */ jsx("input", { type: "hidden", name: "next", value: next }) : null,
|
|
213
213
|
body,
|
|
214
214
|
/* @__PURE__ */ jsx("div", { className: cx.actions, children: /* @__PURE__ */ jsx("button", { type: "submit", name: "intent", value: intent, disabled: pending, className: cx.submit, "data-sf-account-submit": true, children: m.submit[view] }) }),
|
|
@@ -291,8 +291,8 @@ function PostPurchaseAccountPrompt({
|
|
|
291
291
|
const ref = useRef(null);
|
|
292
292
|
const passwordOn = capabilities.password;
|
|
293
293
|
const otpOn = capabilities.otp_channels.includes("email");
|
|
294
|
-
const
|
|
295
|
-
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields: data?.error?.field === "code" || data?.error?.field === "password" ? [data.error.field] : null, serverMessages: data?.error?.field &&
|
|
294
|
+
const errorText2 = data?.error ? m.errors[data.error.code] : null;
|
|
295
|
+
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields: data?.error?.field === "code" || data?.error?.field === "password" ? [data.error.field] : null, serverMessages: data?.error?.field && errorText2 ? { [data.error.field]: errorText2 } : null });
|
|
296
296
|
if (!validEmail(email) || !passwordOn && !otpOn) return null;
|
|
297
297
|
const address = email.trim().toLowerCase();
|
|
298
298
|
const step = data?.step === "verify" || data?.step === "otp" ? data.step : null;
|
|
@@ -301,14 +301,14 @@ function PostPurchaseAccountPrompt({
|
|
|
301
301
|
const label = view === "verify" || view === "otp" ? m.submitCode : view === "otp-request" ? m.submitOtp : m.submit;
|
|
302
302
|
const Heading = `h${headingLevel}`;
|
|
303
303
|
const fieldProps = { classNames: cx.field, ...locale ? { locale } : {} };
|
|
304
|
-
const showAlert =
|
|
304
|
+
const showAlert = errorText2 && !(data?.error?.field === "code" || data?.error?.field === "password");
|
|
305
305
|
const benefit = (capabilities.email_verification ? m.benefit : m.benefitBasic).replace("{email}", address);
|
|
306
306
|
return /* @__PURE__ */ jsxs("section", { className: cx.root, "data-sf-ppa": true, "data-sf-ppa-view": view, "aria-labelledby": "sf-ppa-title", children: [
|
|
307
307
|
/* @__PURE__ */ jsx(Heading, { id: "sf-ppa-title", className: cx.title, children: m.title }),
|
|
308
308
|
/* @__PURE__ */ jsx("p", { className: cx.text, "data-sf-ppa-benefit": true, children: benefit }),
|
|
309
309
|
/* @__PURE__ */ jsxs(FormTag, { ref, method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-ppa-form": true, children: [
|
|
310
310
|
/* @__PURE__ */ jsx(ErrorSummary, { items: v.summary, focusKey: v.summaryKey, ...locale ? { locale } : {} }),
|
|
311
|
-
showAlert ? /* @__PURE__ */ jsx("p", { role: "alert", className: cx.error, "data-sf-ppa-error": data.error.code, children:
|
|
311
|
+
showAlert ? /* @__PURE__ */ jsx("p", { role: "alert", className: cx.error, "data-sf-ppa-error": data.error.code, children: errorText2 }) : null,
|
|
312
312
|
/* @__PURE__ */ jsx("input", { type: "hidden", name: "email", value: address }),
|
|
313
313
|
next ? /* @__PURE__ */ jsx("input", { type: "hidden", name: "next", value: next }) : null,
|
|
314
314
|
/* @__PURE__ */ jsx("p", { className: cx.email, "data-sf-ppa-email": true, children: m.accountFor.replace("{email}", address) }),
|
|
@@ -1511,6 +1511,245 @@ function useCustomerOrder(id, { client, initial, poll } = {}) {
|
|
|
1511
1511
|
return { status: mine ? state.status : "loading", order, error: mine ? state.error : null, refreshing: mine && refreshing, reload };
|
|
1512
1512
|
}
|
|
1513
1513
|
|
|
1514
|
-
|
|
1514
|
+
// src/account/settings-messages.ts
|
|
1515
|
+
var ES4 = {
|
|
1516
|
+
// shared
|
|
1517
|
+
"settings.saved": "Listo, guardamos tus cambios.",
|
|
1518
|
+
"settings.error.session_expired": "Tu sesi\xF3n venci\xF3. Inicia sesi\xF3n de nuevo para continuar.",
|
|
1519
|
+
"settings.error.invalid_credential": "No pudimos verificarte. Revisa tu contrase\xF1a o el c\xF3digo e int\xE9ntalo de nuevo.",
|
|
1520
|
+
"settings.error.reauth_required": "Por seguridad, confirma tu contrase\xF1a o un c\xF3digo antes de continuar.",
|
|
1521
|
+
"settings.error.rate_limited": "Demasiados intentos. Espera unos minutos e int\xE9ntalo de nuevo.",
|
|
1522
|
+
"settings.error.rate_limited_in": "Demasiados intentos. Int\xE9ntalo de nuevo en {minutes} min.",
|
|
1523
|
+
"settings.error.validation": "Revisa los datos e int\xE9ntalo de nuevo.",
|
|
1524
|
+
"settings.error.blocked_orders": "Tienes un pedido en camino. Podr\xE1s hacerlo cuando llegue.",
|
|
1525
|
+
"settings.error.blocked_pending_payments": "Tienes un pago pendiente. P\xE1galo o espera a que venza para continuar.",
|
|
1526
|
+
"settings.error.unsupported": "Esta tienda no ofrece esta opci\xF3n por ahora.",
|
|
1527
|
+
"settings.error.unavailable": "No pudimos completar la acci\xF3n. Int\xE9ntalo de nuevo en un momento.",
|
|
1528
|
+
// language
|
|
1529
|
+
"lang.title": "Idioma",
|
|
1530
|
+
"lang.label": "Idioma de tus mensajes",
|
|
1531
|
+
"lang.default": "El de la tienda",
|
|
1532
|
+
"lang.save": "Guardar idioma",
|
|
1533
|
+
// notifications
|
|
1534
|
+
"notif.title": "Avisos",
|
|
1535
|
+
"notif.intro": "Elige c\xF3mo quieres que te avisemos.",
|
|
1536
|
+
"notif.event.order_updates": "Actualizaciones de tu pedido",
|
|
1537
|
+
"notif.event.shipping": "Env\xEDo y seguimiento",
|
|
1538
|
+
"notif.event.restock": "Producto otra vez disponible",
|
|
1539
|
+
"notif.event.unknown": "Otros avisos",
|
|
1540
|
+
"notif.channel.email": "Correo",
|
|
1541
|
+
"notif.channel.whatsapp": "WhatsApp",
|
|
1542
|
+
"notif.channel.unknown": "Otro canal",
|
|
1543
|
+
"notif.required": "La confirmaci\xF3n de tu pedido, tus pagos y tus facturas siempre se env\xEDan: son necesarios.",
|
|
1544
|
+
"notif.save": "Guardar avisos",
|
|
1545
|
+
"notif.matrixLabel": "Avisos por tipo y canal",
|
|
1546
|
+
// sessions
|
|
1547
|
+
"sessions.title": "Dispositivos con sesi\xF3n abierta",
|
|
1548
|
+
"sessions.intro": "Estos son los dispositivos donde tu cuenta tiene la sesi\xF3n abierta. Si no reconoces alguno, ci\xE9rralo.",
|
|
1549
|
+
"sessions.current": "Este dispositivo",
|
|
1550
|
+
"sessions.lastUsed": "\xDAltimo uso: {date}",
|
|
1551
|
+
"sessions.signedIn": "Inicio de sesi\xF3n: {date}",
|
|
1552
|
+
"sessions.method.email": "Con c\xF3digo por correo",
|
|
1553
|
+
"sessions.method.phone": "Con c\xF3digo por mensaje",
|
|
1554
|
+
"sessions.method.password": "Con contrase\xF1a",
|
|
1555
|
+
"sessions.method.unknown": "Inicio de sesi\xF3n",
|
|
1556
|
+
"sessions.revoke": "Cerrar sesi\xF3n",
|
|
1557
|
+
"sessions.revokeLabel": "Cerrar la sesi\xF3n de {device}",
|
|
1558
|
+
"sessions.revokeOthers": "Cerrar las dem\xE1s sesiones",
|
|
1559
|
+
"sessions.revoked": "Cerramos la sesi\xF3n.",
|
|
1560
|
+
"sessions.revokedOthers": "Cerramos las dem\xE1s sesiones.",
|
|
1561
|
+
"sessions.none": "No hay otras sesiones abiertas.",
|
|
1562
|
+
"sessions.error": "No pudimos cargar tus dispositivos. Int\xE9ntalo de nuevo m\xE1s tarde.",
|
|
1563
|
+
"sessions.loading": "Cargando tus dispositivos",
|
|
1564
|
+
"sessions.listLabel": "Dispositivos con sesi\xF3n abierta"
|
|
1565
|
+
};
|
|
1566
|
+
var EN4 = {
|
|
1567
|
+
"settings.saved": "Done, your changes are saved.",
|
|
1568
|
+
"settings.error.session_expired": "Your session expired. Sign in again to continue.",
|
|
1569
|
+
"settings.error.invalid_credential": "We could not verify you. Check your password or the code and try again.",
|
|
1570
|
+
"settings.error.reauth_required": "For your security, confirm your password or a code before continuing.",
|
|
1571
|
+
"settings.error.rate_limited": "Too many attempts. Wait a few minutes and try again.",
|
|
1572
|
+
"settings.error.rate_limited_in": "Too many attempts. Try again in {minutes} min.",
|
|
1573
|
+
"settings.error.validation": "Check the details and try again.",
|
|
1574
|
+
"settings.error.blocked_orders": "You have an order on its way. You will be able to do this once it arrives.",
|
|
1575
|
+
"settings.error.blocked_pending_payments": "You have a pending payment. Pay it or wait for it to expire to continue.",
|
|
1576
|
+
"settings.error.unsupported": "This store does not offer this option right now.",
|
|
1577
|
+
"settings.error.unavailable": "We could not complete that. Try again in a moment.",
|
|
1578
|
+
"lang.title": "Language",
|
|
1579
|
+
"lang.label": "Language of your messages",
|
|
1580
|
+
"lang.default": "The store\u2019s",
|
|
1581
|
+
"lang.save": "Save language",
|
|
1582
|
+
"notif.title": "Notices",
|
|
1583
|
+
"notif.intro": "Choose how you want us to notify you.",
|
|
1584
|
+
"notif.event.order_updates": "Updates about your order",
|
|
1585
|
+
"notif.event.shipping": "Shipping and tracking",
|
|
1586
|
+
"notif.event.restock": "A product is available again",
|
|
1587
|
+
"notif.event.unknown": "Other notices",
|
|
1588
|
+
"notif.channel.email": "Email",
|
|
1589
|
+
"notif.channel.whatsapp": "WhatsApp",
|
|
1590
|
+
"notif.channel.unknown": "Other channel",
|
|
1591
|
+
"notif.required": "Your order confirmation, payments and invoices are always sent: they are required.",
|
|
1592
|
+
"notif.save": "Save notices",
|
|
1593
|
+
"notif.matrixLabel": "Notices by type and channel",
|
|
1594
|
+
"sessions.title": "Devices signed in",
|
|
1595
|
+
"sessions.intro": "These are the devices where your account is signed in. If you do not recognize one, sign it out.",
|
|
1596
|
+
"sessions.current": "This device",
|
|
1597
|
+
"sessions.lastUsed": "Last used: {date}",
|
|
1598
|
+
"sessions.signedIn": "Signed in: {date}",
|
|
1599
|
+
"sessions.method.email": "With an email code",
|
|
1600
|
+
"sessions.method.phone": "With a text code",
|
|
1601
|
+
"sessions.method.password": "With a password",
|
|
1602
|
+
"sessions.method.unknown": "Sign-in",
|
|
1603
|
+
"sessions.revoke": "Sign out",
|
|
1604
|
+
"sessions.revokeLabel": "Sign out {device}",
|
|
1605
|
+
"sessions.revokeOthers": "Sign out of all other devices",
|
|
1606
|
+
"sessions.revoked": "We signed that device out.",
|
|
1607
|
+
"sessions.revokedOthers": "We signed out the other devices.",
|
|
1608
|
+
"sessions.none": "There are no other signed-in devices.",
|
|
1609
|
+
"sessions.error": "We could not load your devices. Try again later.",
|
|
1610
|
+
"sessions.loading": "Loading your devices",
|
|
1611
|
+
"sessions.listLabel": "Devices signed in"
|
|
1612
|
+
};
|
|
1613
|
+
function settingsMessages(locale, overrides) {
|
|
1614
|
+
const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN4 : ES4;
|
|
1615
|
+
return overrides ? { ...base, ...overrides } : base;
|
|
1616
|
+
}
|
|
1617
|
+
function settingsEnumText(m, group, value) {
|
|
1618
|
+
const key = `${group}.${typeof value === "string" ? value : ""}`;
|
|
1619
|
+
return Object.prototype.hasOwnProperty.call(m, key) ? m[key] : m[`${group}.unknown`];
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
// src/account/settings-ui.tsx
|
|
1623
|
+
function useSettingsText({ locale, messages, timeZone }) {
|
|
1624
|
+
const resolved = useResolvedLocale(locale);
|
|
1625
|
+
const m = settingsMessages(resolved, messages);
|
|
1626
|
+
const t = (key, vars) => vars ? fill(m[key], vars) : m[key];
|
|
1627
|
+
const date = (iso) => formatDate(iso, resolved, "datetime", timeZone);
|
|
1628
|
+
return { locale: resolved, m, t, date };
|
|
1629
|
+
}
|
|
1630
|
+
function errorText(m, error) {
|
|
1631
|
+
if (error.code === "rate_limited" && typeof error.retryAfter === "number" && error.retryAfter > 0) {
|
|
1632
|
+
return fill(m["settings.error.rate_limited_in"], { minutes: Math.max(1, Math.ceil(error.retryAfter / 60)) });
|
|
1633
|
+
}
|
|
1634
|
+
const key = `settings.error.${error.code}`;
|
|
1635
|
+
return Object.prototype.hasOwnProperty.call(m, key) ? m[key] : m["settings.error.unavailable"];
|
|
1636
|
+
}
|
|
1637
|
+
function resultFor(data, ...intents) {
|
|
1638
|
+
return data && data.intent && intents.includes(data.intent) ? data : null;
|
|
1639
|
+
}
|
|
1640
|
+
function methodText(m, method) {
|
|
1641
|
+
return settingsEnumText(m, "sessions.method", method);
|
|
1642
|
+
}
|
|
1643
|
+
function SessionsList({ sessions, data, pending = false, form: FormTag = "form", action, headingLevel = 3, classNames: cx = {}, children, ...text }) {
|
|
1644
|
+
const { m, t, date } = useSettingsText(text);
|
|
1645
|
+
const titleId = useId();
|
|
1646
|
+
const Heading = `h${headingLevel}`;
|
|
1647
|
+
const result = resultFor(data, "session-revoke", "session-revoke-others");
|
|
1648
|
+
const list = (sessions ?? []).filter((s) => s && typeof s.id === "string" && s.id);
|
|
1649
|
+
const others = list.filter((s) => !s.current);
|
|
1650
|
+
const formProps = { method: "post", ...action ? { action } : {} };
|
|
1651
|
+
return /* @__PURE__ */ jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-sessions": true, "data-state": sessions === null ? "degraded" : "ready", children: [
|
|
1652
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.title, children: m["sessions.title"] }),
|
|
1653
|
+
sessions === null ? /* @__PURE__ */ jsx("p", { className: cx.error, role: "status", "data-sf-sessions-degraded": true, children: m["sessions.error"] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1654
|
+
/* @__PURE__ */ jsx("p", { className: cx.intro, children: m["sessions.intro"] }),
|
|
1655
|
+
result?.ok ? /* @__PURE__ */ jsx("p", { className: cx.notice, role: "status", "data-sf-sessions-notice": true, children: result.intent === "session-revoke-others" ? m["sessions.revokedOthers"] : m["sessions.revoked"] }) : result?.error ? /* @__PURE__ */ jsx("p", { className: cx.error, role: "alert", "data-sf-sessions-error": result.error.code, children: errorText(m, result.error) }) : null,
|
|
1656
|
+
/* @__PURE__ */ jsx("ul", { className: cx.list, "aria-label": m["sessions.listLabel"], "data-sf-sessions-list": true, children: list.map((s) => {
|
|
1657
|
+
const device = str(s.device_label) ?? m["sessions.method.unknown"];
|
|
1658
|
+
const last = date(s.last_used_at ?? null);
|
|
1659
|
+
const since = date(s.created_at);
|
|
1660
|
+
return /* @__PURE__ */ jsxs("li", { className: cx.item, "data-sf-session": true, "data-current": s.current ? "true" : "false", children: [
|
|
1661
|
+
/* @__PURE__ */ jsxs("p", { className: cx.device, "data-sf-session-device": true, children: [
|
|
1662
|
+
device,
|
|
1663
|
+
s.current ? /* @__PURE__ */ jsxs("span", { className: cx.badge, "data-sf-session-current": true, children: [
|
|
1664
|
+
" ",
|
|
1665
|
+
m["sessions.current"]
|
|
1666
|
+
] }) : null
|
|
1667
|
+
] }),
|
|
1668
|
+
/* @__PURE__ */ jsxs("p", { className: cx.meta, "data-sf-session-meta": true, children: [
|
|
1669
|
+
methodText(m, s.login_method),
|
|
1670
|
+
last ? ` \xB7 ${t("sessions.lastUsed", { date: last })}` : since ? ` \xB7 ${t("sessions.signedIn", { date: since })}` : ""
|
|
1671
|
+
] }),
|
|
1672
|
+
s.current ? null : /* @__PURE__ */ jsxs(FormTag, { ...formProps, "data-sf-account-form": "", children: [
|
|
1673
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: "session_id", value: s.id }),
|
|
1674
|
+
/* @__PURE__ */ jsx("button", { type: "submit", name: "intent", value: "session-revoke", disabled: pending, className: cx.revoke, "aria-label": t("sessions.revokeLabel", { device }), "data-sf-session-revoke": true, children: m["sessions.revoke"] })
|
|
1675
|
+
] })
|
|
1676
|
+
] }, s.id);
|
|
1677
|
+
}) }),
|
|
1678
|
+
others.length === 0 ? /* @__PURE__ */ jsx("p", { className: cx.empty, "data-sf-sessions-empty": true, children: m["sessions.none"] }) : /* @__PURE__ */ jsx(FormTag, { ...formProps, "data-sf-account-form": "", children: /* @__PURE__ */ jsx("button", { type: "submit", name: "intent", value: "session-revoke-others", disabled: pending, className: cx.revokeOthers, "data-sf-session-revoke-others": true, children: m["sessions.revokeOthers"] }) })
|
|
1679
|
+
] }),
|
|
1680
|
+
children
|
|
1681
|
+
] });
|
|
1682
|
+
}
|
|
1683
|
+
var NOTIFICATION_EVENTS = ["order_updates", "shipping", "restock"];
|
|
1684
|
+
function languageName(tag, inLocale) {
|
|
1685
|
+
try {
|
|
1686
|
+
const name = new Intl.DisplayNames([inLocale], { type: "language", languageDisplay: "dialect" }).of(tag);
|
|
1687
|
+
return name ? name.charAt(0).toLocaleUpperCase(inLocale) + name.slice(1) : tag;
|
|
1688
|
+
} catch {
|
|
1689
|
+
return tag;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
function LanguagePreference({ locales, value, data, pending = false, form: FormTag = "form", action, headingLevel = 3, classNames: cx = {}, children, ...text }) {
|
|
1693
|
+
const { m, locale } = useSettingsText(text);
|
|
1694
|
+
const titleId = useId();
|
|
1695
|
+
const selectId = useId();
|
|
1696
|
+
const options = (locales ?? []).map((l) => typeof l === "string" ? { value: l, label: void 0 } : { value: l?.value, label: l?.label }).filter((o) => typeof o.value === "string" && /^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8}){0,2}$/.test(o.value));
|
|
1697
|
+
if (options.length < 2) return null;
|
|
1698
|
+
const Heading = `h${headingLevel}`;
|
|
1699
|
+
const result = resultFor(data, "locale");
|
|
1700
|
+
const current = options.find((o) => o.value.toLowerCase() === (value ?? "").toLowerCase())?.value ?? "";
|
|
1701
|
+
return /* @__PURE__ */ jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-lang": true, children: [
|
|
1702
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.title, children: m["lang.title"] }),
|
|
1703
|
+
/* @__PURE__ */ jsxs(FormTag, { method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": "", children: [
|
|
1704
|
+
result?.saved ? /* @__PURE__ */ jsx("p", { className: cx.notice, role: "status", "data-sf-lang-notice": true, children: m["settings.saved"] }) : result?.error ? /* @__PURE__ */ jsx("p", { className: cx.error, role: "alert", "data-sf-lang-error": result.error.code, children: errorText(m, result.error) }) : null,
|
|
1705
|
+
/* @__PURE__ */ jsx("label", { htmlFor: selectId, className: cx.label, children: m["lang.label"] }),
|
|
1706
|
+
/* @__PURE__ */ jsxs("select", { id: selectId, name: "locale", defaultValue: current, className: cx.select, "data-sf-lang-select": true, children: [
|
|
1707
|
+
/* @__PURE__ */ jsx("option", { value: "", children: m["lang.default"] }),
|
|
1708
|
+
options.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: str(o.label) ?? languageName(o.value, locale) }, o.value))
|
|
1709
|
+
] }),
|
|
1710
|
+
/* @__PURE__ */ jsx("button", { type: "submit", name: "intent", value: "locale", disabled: pending, className: cx.submit, "data-sf-lang-submit": true, children: m["lang.save"] })
|
|
1711
|
+
] }),
|
|
1712
|
+
children
|
|
1713
|
+
] });
|
|
1714
|
+
}
|
|
1715
|
+
var TOKEN = /^[a-z][a-z0-9_]{0,31}$/;
|
|
1716
|
+
function NotificationPreferences({ channels, preferences, events = NOTIFICATION_EVENTS, data, pending = false, form: FormTag = "form", action, headingLevel = 3, classNames: cx = {}, children, ...text }) {
|
|
1717
|
+
const { m } = useSettingsText(text);
|
|
1718
|
+
const titleId = useId();
|
|
1719
|
+
const cols = Array.from(new Set((channels ?? []).filter((c) => typeof c === "string" && TOKEN.test(c))));
|
|
1720
|
+
const rows = Array.from(new Set(events.filter((e) => TOKEN.test(e))));
|
|
1721
|
+
if (cols.length === 0 || rows.length === 0) return null;
|
|
1722
|
+
const Heading = `h${headingLevel}`;
|
|
1723
|
+
const result = resultFor(data, "notifications");
|
|
1724
|
+
const on = (event, channel) => preferences?.notifications?.[event]?.[channel] !== false;
|
|
1725
|
+
return /* @__PURE__ */ jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-notif": true, children: [
|
|
1726
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.title, children: m["notif.title"] }),
|
|
1727
|
+
/* @__PURE__ */ jsx("p", { className: cx.intro, children: m["notif.intro"] }),
|
|
1728
|
+
/* @__PURE__ */ jsxs(FormTag, { method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": "", children: [
|
|
1729
|
+
result?.saved ? /* @__PURE__ */ jsx("p", { className: cx.notice, role: "status", "data-sf-notif-notice": true, children: m["settings.saved"] }) : result?.error ? /* @__PURE__ */ jsx("p", { className: cx.error, role: "alert", "data-sf-notif-error": result.error.code, children: errorText(m, result.error) }) : null,
|
|
1730
|
+
/* @__PURE__ */ jsxs("table", { className: cx.table, "aria-label": m["notif.matrixLabel"], "data-sf-notif-table": true, children: [
|
|
1731
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1732
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: /* @__PURE__ */ jsx("span", { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" }, children: m["notif.title"] }) }),
|
|
1733
|
+
cols.map((c) => /* @__PURE__ */ jsx("th", { scope: "col", className: cx.channel, "data-sf-notif-channel": c, children: settingsEnumText(m, "notif.channel", c) }, c))
|
|
1734
|
+
] }) }),
|
|
1735
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map((e) => /* @__PURE__ */ jsxs("tr", { className: cx.row, "data-sf-notif-row": e, children: [
|
|
1736
|
+
/* @__PURE__ */ jsx("th", { scope: "row", className: cx.event, children: settingsEnumText(m, "notif.event", e) }),
|
|
1737
|
+
cols.map((c) => {
|
|
1738
|
+
const id = `${e}:${c}`;
|
|
1739
|
+
return /* @__PURE__ */ jsxs("td", { children: [
|
|
1740
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: "pref_shown", value: id }),
|
|
1741
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", name: "pref", value: id, defaultChecked: on(e, c), className: cx.check, "aria-label": `${settingsEnumText(m, "notif.event", e)} \xB7 ${settingsEnumText(m, "notif.channel", c)}` })
|
|
1742
|
+
] }, c);
|
|
1743
|
+
})
|
|
1744
|
+
] }, e)) })
|
|
1745
|
+
] }),
|
|
1746
|
+
/* @__PURE__ */ jsx("p", { className: cx.required, "data-sf-notif-required": true, children: m["notif.required"] }),
|
|
1747
|
+
/* @__PURE__ */ jsx("button", { type: "submit", name: "intent", value: "notifications", disabled: pending, className: cx.submit, "data-sf-notif-submit": true, children: m["notif.save"] })
|
|
1748
|
+
] }),
|
|
1749
|
+
children
|
|
1750
|
+
] });
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
export { AccountAuth, Barcode, InvoiceList, LanguagePreference, NOTIFICATION_EVENTS, NextActionBar, NotificationPreferences, OrderCard, OrderLines, OrderList, OrderProductsStack, OrderProgress, OrderStatusBadge, PaymentSummary, PendingPaymentCard, PendingPaymentList, PostPurchaseAccountPrompt, RefundList, SessionsList, ShipmentCard, accountAuthMessages, accountMessages, enumText, lineImage, paymentLabel, paymentMethodKey, postPurchaseAccountPromptMessages, settingsEnumText, settingsMessages, stageTone, useCustomerOrder, useCustomerOrders, usePendingPayments };
|
|
1515
1754
|
//# sourceMappingURL=account.js.map
|
|
1516
1755
|
//# sourceMappingURL=account.js.map
|