@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.cjs
CHANGED
|
@@ -655,8 +655,8 @@ function AccountAuth({ capabilities, data, next, pending = false, initialView, f
|
|
|
655
655
|
const [email, setEmail] = react.useState(data?.email ?? "");
|
|
656
656
|
const ref = react.useRef(null);
|
|
657
657
|
const serverFields = data?.error?.field ? [data.error.field] : null;
|
|
658
|
-
const
|
|
659
|
-
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields, serverMessages: data?.error?.field &&
|
|
658
|
+
const errorText2 = data?.error ? m.errors[data.error.code] : null;
|
|
659
|
+
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields, serverMessages: data?.error?.field && errorText2 ? { [data.error.field]: errorText2 } : null });
|
|
660
660
|
react.useEffect(() => {
|
|
661
661
|
if (data?.step) setView(data.step);
|
|
662
662
|
if (data?.email) setEmail(data.email);
|
|
@@ -742,7 +742,7 @@ function AccountAuth({ capabilities, data, next, pending = false, initialView, f
|
|
|
742
742
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { id: "sf-account-title", className: cx.title, children: title }),
|
|
743
743
|
/* @__PURE__ */ jsxRuntime.jsxs(FormTag, { ref, method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": true, children: [
|
|
744
744
|
/* @__PURE__ */ jsxRuntime.jsx(ErrorSummary, { items: v.summary, focusKey: v.summaryKey, ...locale ? { locale } : {} }),
|
|
745
|
-
|
|
745
|
+
errorText2 && showSummary ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: cx.error, "data-sf-account-error": data.error.code, children: errorText2 }) : null,
|
|
746
746
|
next ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "next", value: next }) : null,
|
|
747
747
|
body,
|
|
748
748
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.actions, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", name: "intent", value: intent, disabled: pending, className: cx.submit, "data-sf-account-submit": true, children: m.submit[view] }) }),
|
|
@@ -825,8 +825,8 @@ function PostPurchaseAccountPrompt({
|
|
|
825
825
|
const ref = react.useRef(null);
|
|
826
826
|
const passwordOn = capabilities.password;
|
|
827
827
|
const otpOn = capabilities.otp_channels.includes("email");
|
|
828
|
-
const
|
|
829
|
-
const v = useFieldErrors(ref, { ...locale ? { locale } : {}, serverFields: data?.error?.field === "code" || data?.error?.field === "password" ? [data.error.field] : null, serverMessages: data?.error?.field &&
|
|
828
|
+
const errorText2 = data?.error ? m.errors[data.error.code] : null;
|
|
829
|
+
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 });
|
|
830
830
|
if (!validEmail(email) || !passwordOn && !otpOn) return null;
|
|
831
831
|
const address = email.trim().toLowerCase();
|
|
832
832
|
const step = data?.step === "verify" || data?.step === "otp" ? data.step : null;
|
|
@@ -835,14 +835,14 @@ function PostPurchaseAccountPrompt({
|
|
|
835
835
|
const label = view === "verify" || view === "otp" ? m.submitCode : view === "otp-request" ? m.submitOtp : m.submit;
|
|
836
836
|
const Heading = `h${headingLevel}`;
|
|
837
837
|
const fieldProps = { classNames: cx.field, ...locale ? { locale } : {} };
|
|
838
|
-
const showAlert =
|
|
838
|
+
const showAlert = errorText2 && !(data?.error?.field === "code" || data?.error?.field === "password");
|
|
839
839
|
const benefit = (capabilities.email_verification ? m.benefit : m.benefitBasic).replace("{email}", address);
|
|
840
840
|
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "data-sf-ppa": true, "data-sf-ppa-view": view, "aria-labelledby": "sf-ppa-title", children: [
|
|
841
841
|
/* @__PURE__ */ jsxRuntime.jsx(Heading, { id: "sf-ppa-title", className: cx.title, children: m.title }),
|
|
842
842
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.text, "data-sf-ppa-benefit": true, children: benefit }),
|
|
843
843
|
/* @__PURE__ */ jsxRuntime.jsxs(FormTag, { ref, method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-ppa-form": true, children: [
|
|
844
844
|
/* @__PURE__ */ jsxRuntime.jsx(ErrorSummary, { items: v.summary, focusKey: v.summaryKey, ...locale ? { locale } : {} }),
|
|
845
|
-
showAlert ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: cx.error, "data-sf-ppa-error": data.error.code, children:
|
|
845
|
+
showAlert ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: cx.error, "data-sf-ppa-error": data.error.code, children: errorText2 }) : null,
|
|
846
846
|
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "email", value: address }),
|
|
847
847
|
next ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "next", value: next }) : null,
|
|
848
848
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.email, "data-sf-ppa-email": true, children: m.accountFor.replace("{email}", address) }),
|
|
@@ -2261,10 +2261,252 @@ function useCustomerOrder(id, { client, initial, poll } = {}) {
|
|
|
2261
2261
|
// src/account/index.ts
|
|
2262
2262
|
init_voucher();
|
|
2263
2263
|
|
|
2264
|
+
// src/account/settings-messages.ts
|
|
2265
|
+
var ES6 = {
|
|
2266
|
+
// shared
|
|
2267
|
+
"settings.saved": "Listo, guardamos tus cambios.",
|
|
2268
|
+
"settings.error.session_expired": "Tu sesi\xF3n venci\xF3. Inicia sesi\xF3n de nuevo para continuar.",
|
|
2269
|
+
"settings.error.invalid_credential": "No pudimos verificarte. Revisa tu contrase\xF1a o el c\xF3digo e int\xE9ntalo de nuevo.",
|
|
2270
|
+
"settings.error.reauth_required": "Por seguridad, confirma tu contrase\xF1a o un c\xF3digo antes de continuar.",
|
|
2271
|
+
"settings.error.rate_limited": "Demasiados intentos. Espera unos minutos e int\xE9ntalo de nuevo.",
|
|
2272
|
+
"settings.error.rate_limited_in": "Demasiados intentos. Int\xE9ntalo de nuevo en {minutes} min.",
|
|
2273
|
+
"settings.error.validation": "Revisa los datos e int\xE9ntalo de nuevo.",
|
|
2274
|
+
"settings.error.blocked_orders": "Tienes un pedido en camino. Podr\xE1s hacerlo cuando llegue.",
|
|
2275
|
+
"settings.error.blocked_pending_payments": "Tienes un pago pendiente. P\xE1galo o espera a que venza para continuar.",
|
|
2276
|
+
"settings.error.unsupported": "Esta tienda no ofrece esta opci\xF3n por ahora.",
|
|
2277
|
+
"settings.error.unavailable": "No pudimos completar la acci\xF3n. Int\xE9ntalo de nuevo en un momento.",
|
|
2278
|
+
// language
|
|
2279
|
+
"lang.title": "Idioma",
|
|
2280
|
+
"lang.label": "Idioma de tus mensajes",
|
|
2281
|
+
"lang.default": "El de la tienda",
|
|
2282
|
+
"lang.save": "Guardar idioma",
|
|
2283
|
+
// notifications
|
|
2284
|
+
"notif.title": "Avisos",
|
|
2285
|
+
"notif.intro": "Elige c\xF3mo quieres que te avisemos.",
|
|
2286
|
+
"notif.event.order_updates": "Actualizaciones de tu pedido",
|
|
2287
|
+
"notif.event.shipping": "Env\xEDo y seguimiento",
|
|
2288
|
+
"notif.event.restock": "Producto otra vez disponible",
|
|
2289
|
+
"notif.event.unknown": "Otros avisos",
|
|
2290
|
+
"notif.channel.email": "Correo",
|
|
2291
|
+
"notif.channel.whatsapp": "WhatsApp",
|
|
2292
|
+
"notif.channel.unknown": "Otro canal",
|
|
2293
|
+
"notif.required": "La confirmaci\xF3n de tu pedido, tus pagos y tus facturas siempre se env\xEDan: son necesarios.",
|
|
2294
|
+
"notif.save": "Guardar avisos",
|
|
2295
|
+
"notif.matrixLabel": "Avisos por tipo y canal",
|
|
2296
|
+
// sessions
|
|
2297
|
+
"sessions.title": "Dispositivos con sesi\xF3n abierta",
|
|
2298
|
+
"sessions.intro": "Estos son los dispositivos donde tu cuenta tiene la sesi\xF3n abierta. Si no reconoces alguno, ci\xE9rralo.",
|
|
2299
|
+
"sessions.current": "Este dispositivo",
|
|
2300
|
+
"sessions.lastUsed": "\xDAltimo uso: {date}",
|
|
2301
|
+
"sessions.signedIn": "Inicio de sesi\xF3n: {date}",
|
|
2302
|
+
"sessions.method.email": "Con c\xF3digo por correo",
|
|
2303
|
+
"sessions.method.phone": "Con c\xF3digo por mensaje",
|
|
2304
|
+
"sessions.method.password": "Con contrase\xF1a",
|
|
2305
|
+
"sessions.method.unknown": "Inicio de sesi\xF3n",
|
|
2306
|
+
"sessions.revoke": "Cerrar sesi\xF3n",
|
|
2307
|
+
"sessions.revokeLabel": "Cerrar la sesi\xF3n de {device}",
|
|
2308
|
+
"sessions.revokeOthers": "Cerrar las dem\xE1s sesiones",
|
|
2309
|
+
"sessions.revoked": "Cerramos la sesi\xF3n.",
|
|
2310
|
+
"sessions.revokedOthers": "Cerramos las dem\xE1s sesiones.",
|
|
2311
|
+
"sessions.none": "No hay otras sesiones abiertas.",
|
|
2312
|
+
"sessions.error": "No pudimos cargar tus dispositivos. Int\xE9ntalo de nuevo m\xE1s tarde.",
|
|
2313
|
+
"sessions.loading": "Cargando tus dispositivos",
|
|
2314
|
+
"sessions.listLabel": "Dispositivos con sesi\xF3n abierta"
|
|
2315
|
+
};
|
|
2316
|
+
var EN6 = {
|
|
2317
|
+
"settings.saved": "Done, your changes are saved.",
|
|
2318
|
+
"settings.error.session_expired": "Your session expired. Sign in again to continue.",
|
|
2319
|
+
"settings.error.invalid_credential": "We could not verify you. Check your password or the code and try again.",
|
|
2320
|
+
"settings.error.reauth_required": "For your security, confirm your password or a code before continuing.",
|
|
2321
|
+
"settings.error.rate_limited": "Too many attempts. Wait a few minutes and try again.",
|
|
2322
|
+
"settings.error.rate_limited_in": "Too many attempts. Try again in {minutes} min.",
|
|
2323
|
+
"settings.error.validation": "Check the details and try again.",
|
|
2324
|
+
"settings.error.blocked_orders": "You have an order on its way. You will be able to do this once it arrives.",
|
|
2325
|
+
"settings.error.blocked_pending_payments": "You have a pending payment. Pay it or wait for it to expire to continue.",
|
|
2326
|
+
"settings.error.unsupported": "This store does not offer this option right now.",
|
|
2327
|
+
"settings.error.unavailable": "We could not complete that. Try again in a moment.",
|
|
2328
|
+
"lang.title": "Language",
|
|
2329
|
+
"lang.label": "Language of your messages",
|
|
2330
|
+
"lang.default": "The store\u2019s",
|
|
2331
|
+
"lang.save": "Save language",
|
|
2332
|
+
"notif.title": "Notices",
|
|
2333
|
+
"notif.intro": "Choose how you want us to notify you.",
|
|
2334
|
+
"notif.event.order_updates": "Updates about your order",
|
|
2335
|
+
"notif.event.shipping": "Shipping and tracking",
|
|
2336
|
+
"notif.event.restock": "A product is available again",
|
|
2337
|
+
"notif.event.unknown": "Other notices",
|
|
2338
|
+
"notif.channel.email": "Email",
|
|
2339
|
+
"notif.channel.whatsapp": "WhatsApp",
|
|
2340
|
+
"notif.channel.unknown": "Other channel",
|
|
2341
|
+
"notif.required": "Your order confirmation, payments and invoices are always sent: they are required.",
|
|
2342
|
+
"notif.save": "Save notices",
|
|
2343
|
+
"notif.matrixLabel": "Notices by type and channel",
|
|
2344
|
+
"sessions.title": "Devices signed in",
|
|
2345
|
+
"sessions.intro": "These are the devices where your account is signed in. If you do not recognize one, sign it out.",
|
|
2346
|
+
"sessions.current": "This device",
|
|
2347
|
+
"sessions.lastUsed": "Last used: {date}",
|
|
2348
|
+
"sessions.signedIn": "Signed in: {date}",
|
|
2349
|
+
"sessions.method.email": "With an email code",
|
|
2350
|
+
"sessions.method.phone": "With a text code",
|
|
2351
|
+
"sessions.method.password": "With a password",
|
|
2352
|
+
"sessions.method.unknown": "Sign-in",
|
|
2353
|
+
"sessions.revoke": "Sign out",
|
|
2354
|
+
"sessions.revokeLabel": "Sign out {device}",
|
|
2355
|
+
"sessions.revokeOthers": "Sign out of all other devices",
|
|
2356
|
+
"sessions.revoked": "We signed that device out.",
|
|
2357
|
+
"sessions.revokedOthers": "We signed out the other devices.",
|
|
2358
|
+
"sessions.none": "There are no other signed-in devices.",
|
|
2359
|
+
"sessions.error": "We could not load your devices. Try again later.",
|
|
2360
|
+
"sessions.loading": "Loading your devices",
|
|
2361
|
+
"sessions.listLabel": "Devices signed in"
|
|
2362
|
+
};
|
|
2363
|
+
function settingsMessages(locale, overrides) {
|
|
2364
|
+
const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN6 : ES6;
|
|
2365
|
+
return overrides ? { ...base, ...overrides } : base;
|
|
2366
|
+
}
|
|
2367
|
+
function settingsEnumText(m, group, value) {
|
|
2368
|
+
const key = `${group}.${typeof value === "string" ? value : ""}`;
|
|
2369
|
+
return Object.prototype.hasOwnProperty.call(m, key) ? m[key] : m[`${group}.unknown`];
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
// src/account/settings-ui.tsx
|
|
2373
|
+
function useSettingsText({ locale, messages, timeZone }) {
|
|
2374
|
+
const resolved = useResolvedLocale(locale);
|
|
2375
|
+
const m = settingsMessages(resolved, messages);
|
|
2376
|
+
const t = (key, vars) => vars ? fill(m[key], vars) : m[key];
|
|
2377
|
+
const date = (iso) => formatDate(iso, resolved, "datetime", timeZone);
|
|
2378
|
+
return { locale: resolved, m, t, date };
|
|
2379
|
+
}
|
|
2380
|
+
function errorText(m, error) {
|
|
2381
|
+
if (error.code === "rate_limited" && typeof error.retryAfter === "number" && error.retryAfter > 0) {
|
|
2382
|
+
return fill(m["settings.error.rate_limited_in"], { minutes: Math.max(1, Math.ceil(error.retryAfter / 60)) });
|
|
2383
|
+
}
|
|
2384
|
+
const key = `settings.error.${error.code}`;
|
|
2385
|
+
return Object.prototype.hasOwnProperty.call(m, key) ? m[key] : m["settings.error.unavailable"];
|
|
2386
|
+
}
|
|
2387
|
+
function resultFor(data, ...intents) {
|
|
2388
|
+
return data && data.intent && intents.includes(data.intent) ? data : null;
|
|
2389
|
+
}
|
|
2390
|
+
function methodText(m, method) {
|
|
2391
|
+
return settingsEnumText(m, "sessions.method", method);
|
|
2392
|
+
}
|
|
2393
|
+
function SessionsList({ sessions, data, pending = false, form: FormTag = "form", action, headingLevel = 3, classNames: cx = {}, children, ...text2 }) {
|
|
2394
|
+
const { m, t, date } = useSettingsText(text2);
|
|
2395
|
+
const titleId = react.useId();
|
|
2396
|
+
const Heading = `h${headingLevel}`;
|
|
2397
|
+
const result = resultFor(data, "session-revoke", "session-revoke-others");
|
|
2398
|
+
const list = (sessions ?? []).filter((s) => s && typeof s.id === "string" && s.id);
|
|
2399
|
+
const others = list.filter((s) => !s.current);
|
|
2400
|
+
const formProps = { method: "post", ...action ? { action } : {} };
|
|
2401
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-sessions": true, "data-state": sessions === null ? "degraded" : "ready", children: [
|
|
2402
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["sessions.title"] }),
|
|
2403
|
+
sessions === null ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.error, role: "status", "data-sf-sessions-degraded": true, children: m["sessions.error"] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2404
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.intro, children: m["sessions.intro"] }),
|
|
2405
|
+
result?.ok ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("p", { className: cx.error, role: "alert", "data-sf-sessions-error": result.error.code, children: errorText(m, result.error) }) : null,
|
|
2406
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, "aria-label": m["sessions.listLabel"], "data-sf-sessions-list": true, children: list.map((s) => {
|
|
2407
|
+
const device = str(s.device_label) ?? m["sessions.method.unknown"];
|
|
2408
|
+
const last = date(s.last_used_at ?? null);
|
|
2409
|
+
const since = date(s.created_at);
|
|
2410
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.item, "data-sf-session": true, "data-current": s.current ? "true" : "false", children: [
|
|
2411
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.device, "data-sf-session-device": true, children: [
|
|
2412
|
+
device,
|
|
2413
|
+
s.current ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.badge, "data-sf-session-current": true, children: [
|
|
2414
|
+
" ",
|
|
2415
|
+
m["sessions.current"]
|
|
2416
|
+
] }) : null
|
|
2417
|
+
] }),
|
|
2418
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.meta, "data-sf-session-meta": true, children: [
|
|
2419
|
+
methodText(m, s.login_method),
|
|
2420
|
+
last ? ` \xB7 ${t("sessions.lastUsed", { date: last })}` : since ? ` \xB7 ${t("sessions.signedIn", { date: since })}` : ""
|
|
2421
|
+
] }),
|
|
2422
|
+
s.current ? null : /* @__PURE__ */ jsxRuntime.jsxs(FormTag, { ...formProps, "data-sf-account-form": "", children: [
|
|
2423
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "session_id", value: s.id }),
|
|
2424
|
+
/* @__PURE__ */ jsxRuntime.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"] })
|
|
2425
|
+
] })
|
|
2426
|
+
] }, s.id);
|
|
2427
|
+
}) }),
|
|
2428
|
+
others.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.empty, "data-sf-sessions-empty": true, children: m["sessions.none"] }) : /* @__PURE__ */ jsxRuntime.jsx(FormTag, { ...formProps, "data-sf-account-form": "", children: /* @__PURE__ */ jsxRuntime.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"] }) })
|
|
2429
|
+
] }),
|
|
2430
|
+
children
|
|
2431
|
+
] });
|
|
2432
|
+
}
|
|
2433
|
+
var NOTIFICATION_EVENTS = ["order_updates", "shipping", "restock"];
|
|
2434
|
+
function languageName(tag, inLocale) {
|
|
2435
|
+
try {
|
|
2436
|
+
const name = new Intl.DisplayNames([inLocale], { type: "language", languageDisplay: "dialect" }).of(tag);
|
|
2437
|
+
return name ? name.charAt(0).toLocaleUpperCase(inLocale) + name.slice(1) : tag;
|
|
2438
|
+
} catch {
|
|
2439
|
+
return tag;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
function LanguagePreference({ locales, value, data, pending = false, form: FormTag = "form", action, headingLevel = 3, classNames: cx = {}, children, ...text2 }) {
|
|
2443
|
+
const { m, locale } = useSettingsText(text2);
|
|
2444
|
+
const titleId = react.useId();
|
|
2445
|
+
const selectId = react.useId();
|
|
2446
|
+
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));
|
|
2447
|
+
if (options.length < 2) return null;
|
|
2448
|
+
const Heading = `h${headingLevel}`;
|
|
2449
|
+
const result = resultFor(data, "locale");
|
|
2450
|
+
const current = options.find((o) => o.value.toLowerCase() === (value ?? "").toLowerCase())?.value ?? "";
|
|
2451
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-lang": true, children: [
|
|
2452
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["lang.title"] }),
|
|
2453
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FormTag, { method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": "", children: [
|
|
2454
|
+
result?.saved ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.notice, role: "status", "data-sf-lang-notice": true, children: m["settings.saved"] }) : result?.error ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.error, role: "alert", "data-sf-lang-error": result.error.code, children: errorText(m, result.error) }) : null,
|
|
2455
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: selectId, className: cx.label, children: m["lang.label"] }),
|
|
2456
|
+
/* @__PURE__ */ jsxRuntime.jsxs("select", { id: selectId, name: "locale", defaultValue: current, className: cx.select, "data-sf-lang-select": true, children: [
|
|
2457
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: m["lang.default"] }),
|
|
2458
|
+
options.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: str(o.label) ?? languageName(o.value, locale) }, o.value))
|
|
2459
|
+
] }),
|
|
2460
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", name: "intent", value: "locale", disabled: pending, className: cx.submit, "data-sf-lang-submit": true, children: m["lang.save"] })
|
|
2461
|
+
] }),
|
|
2462
|
+
children
|
|
2463
|
+
] });
|
|
2464
|
+
}
|
|
2465
|
+
var TOKEN = /^[a-z][a-z0-9_]{0,31}$/;
|
|
2466
|
+
function NotificationPreferences({ channels, preferences, events = NOTIFICATION_EVENTS, data, pending = false, form: FormTag = "form", action, headingLevel = 3, classNames: cx = {}, children, ...text2 }) {
|
|
2467
|
+
const { m } = useSettingsText(text2);
|
|
2468
|
+
const titleId = react.useId();
|
|
2469
|
+
const cols = Array.from(new Set((channels ?? []).filter((c) => typeof c === "string" && TOKEN.test(c))));
|
|
2470
|
+
const rows = Array.from(new Set(events.filter((e) => TOKEN.test(e))));
|
|
2471
|
+
if (cols.length === 0 || rows.length === 0) return null;
|
|
2472
|
+
const Heading = `h${headingLevel}`;
|
|
2473
|
+
const result = resultFor(data, "notifications");
|
|
2474
|
+
const on = (event, channel) => preferences?.notifications?.[event]?.[channel] !== false;
|
|
2475
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-notif": true, children: [
|
|
2476
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["notif.title"] }),
|
|
2477
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.intro, children: m["notif.intro"] }),
|
|
2478
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FormTag, { method: "post", ...action ? { action } : {}, className: cx.form, "data-sf-account-form": "", children: [
|
|
2479
|
+
result?.saved ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.notice, role: "status", "data-sf-notif-notice": true, children: m["settings.saved"] }) : result?.error ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.error, role: "alert", "data-sf-notif-error": result.error.code, children: errorText(m, result.error) }) : null,
|
|
2480
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { className: cx.table, "aria-label": m["notif.matrixLabel"], "data-sf-notif-table": true, children: [
|
|
2481
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2482
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" }, children: m["notif.title"] }) }),
|
|
2483
|
+
cols.map((c) => /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: cx.channel, "data-sf-notif-channel": c, children: settingsEnumText(m, "notif.channel", c) }, c))
|
|
2484
|
+
] }) }),
|
|
2485
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((e) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: cx.row, "data-sf-notif-row": e, children: [
|
|
2486
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "row", className: cx.event, children: settingsEnumText(m, "notif.event", e) }),
|
|
2487
|
+
cols.map((c) => {
|
|
2488
|
+
const id = `${e}:${c}`;
|
|
2489
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("td", { children: [
|
|
2490
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: "pref_shown", value: id }),
|
|
2491
|
+
/* @__PURE__ */ jsxRuntime.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)}` })
|
|
2492
|
+
] }, c);
|
|
2493
|
+
})
|
|
2494
|
+
] }, e)) })
|
|
2495
|
+
] }),
|
|
2496
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.required, "data-sf-notif-required": true, children: m["notif.required"] }),
|
|
2497
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", name: "intent", value: "notifications", disabled: pending, className: cx.submit, "data-sf-notif-submit": true, children: m["notif.save"] })
|
|
2498
|
+
] }),
|
|
2499
|
+
children
|
|
2500
|
+
] });
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2264
2503
|
exports.AccountAuth = AccountAuth;
|
|
2265
2504
|
exports.Barcode = Barcode;
|
|
2266
2505
|
exports.InvoiceList = InvoiceList;
|
|
2506
|
+
exports.LanguagePreference = LanguagePreference;
|
|
2507
|
+
exports.NOTIFICATION_EVENTS = NOTIFICATION_EVENTS;
|
|
2267
2508
|
exports.NextActionBar = NextActionBar;
|
|
2509
|
+
exports.NotificationPreferences = NotificationPreferences;
|
|
2268
2510
|
exports.OrderCard = OrderCard;
|
|
2269
2511
|
exports.OrderLines = OrderLines;
|
|
2270
2512
|
exports.OrderList = OrderList;
|
|
@@ -2279,6 +2521,7 @@ exports.ProductPreview = ProductPreview;
|
|
|
2279
2521
|
exports.ProductThumb = ProductThumb;
|
|
2280
2522
|
exports.ProductThumbStack = ProductThumbStack;
|
|
2281
2523
|
exports.RefundList = RefundList;
|
|
2524
|
+
exports.SessionsList = SessionsList;
|
|
2282
2525
|
exports.ShipmentCard = ShipmentCard;
|
|
2283
2526
|
exports.accountAuthMessages = accountAuthMessages;
|
|
2284
2527
|
exports.accountMessages = accountMessages;
|
|
@@ -2291,6 +2534,8 @@ exports.paymentLabel = paymentLabel;
|
|
|
2291
2534
|
exports.paymentMethodKey = paymentMethodKey;
|
|
2292
2535
|
exports.postPurchaseAccountPromptMessages = postPurchaseAccountPromptMessages;
|
|
2293
2536
|
exports.productInitials = productInitials;
|
|
2537
|
+
exports.settingsEnumText = settingsEnumText;
|
|
2538
|
+
exports.settingsMessages = settingsMessages;
|
|
2294
2539
|
exports.stageTone = stageTone;
|
|
2295
2540
|
exports.useCustomerOrder = useCustomerOrder;
|
|
2296
2541
|
exports.useCustomerOrders = useCustomerOrders;
|