@asteby/storefront-react 0.23.0 → 0.25.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/dist/account.cjs CHANGED
@@ -1032,6 +1032,18 @@ var ES4 = {
1032
1032
  "payment.status.partially_refunded": "Reembolsado parcialmente",
1033
1033
  "payment.status.unknown": "En proceso",
1034
1034
  "payment.paidOn": "Pagado el {date}",
1035
+ "payment.method.card": "Tarjeta",
1036
+ "payment.method.credit_card": "Tarjeta de cr\xE9dito",
1037
+ "payment.method.debit_card": "Tarjeta de d\xE9bito",
1038
+ "payment.method.cash_voucher": "Efectivo con ficha (OXXO, tienda de conveniencia)",
1039
+ "payment.method.oxxo": "Efectivo en OXXO",
1040
+ "payment.method.spei": "Transferencia SPEI",
1041
+ "payment.method.transfer": "Transferencia bancaria",
1042
+ "payment.method.bank_deposit": "Dep\xF3sito bancario",
1043
+ "payment.method.wallet": "Billetera digital",
1044
+ "payment.method.cash": "Efectivo",
1045
+ "payment.method.other": "Otro medio de pago",
1046
+ "payment.method.unknown": "Medio de pago",
1035
1047
  // sections
1036
1048
  "section.error": "No pudimos cargar esta secci\xF3n.",
1037
1049
  "section.retry": "Reintentar",
@@ -1192,6 +1204,18 @@ var EN4 = {
1192
1204
  "payment.status.partially_refunded": "Partially refunded",
1193
1205
  "payment.status.unknown": "In progress",
1194
1206
  "payment.paidOn": "Paid on {date}",
1207
+ "payment.method.card": "Card",
1208
+ "payment.method.credit_card": "Credit card",
1209
+ "payment.method.debit_card": "Debit card",
1210
+ "payment.method.cash_voucher": "Cash with a voucher (OXXO, convenience store)",
1211
+ "payment.method.oxxo": "Cash at OXXO",
1212
+ "payment.method.spei": "SPEI transfer",
1213
+ "payment.method.transfer": "Bank transfer",
1214
+ "payment.method.bank_deposit": "Bank deposit",
1215
+ "payment.method.wallet": "Digital wallet",
1216
+ "payment.method.cash": "Cash",
1217
+ "payment.method.other": "Other payment method",
1218
+ "payment.method.unknown": "Payment method",
1195
1219
  "section.error": "We could not load this section.",
1196
1220
  "section.retry": "Try again",
1197
1221
  "section.loading": "Loading"
@@ -1728,6 +1752,10 @@ function ShipmentCard({ shipment, testMode = "hide", eventsPreview = 3, renderCa
1728
1752
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cx.header, "data-sf-shipment-header": true, children: [
1729
1753
  renderCarrierMark && !test ? /* @__PURE__ */ jsxRuntime.jsx("span", { "data-sf-shipment-mark": true, children: renderCarrierMark(shipment) }) : null,
1730
1754
  /* @__PURE__ */ jsxRuntime.jsxs(Heading, { id: titleId, className: cx.carrier, "data-sf-shipment-title": true, children: [
1755
+ carrier && !test ? /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-sf-shipment-eyebrow": true, children: [
1756
+ m["shipment.carrier"],
1757
+ /* @__PURE__ */ jsxRuntime.jsx(Hidden, { children: ": " })
1758
+ ] }) : null,
1731
1759
  isReturn ? m["shipment.return"] : carrier ?? m["shipment.title"],
1732
1760
  isReturn && carrier ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1733
1761
  " \xB7 ",
@@ -1972,6 +2000,69 @@ function PendingPaymentList({ payments, voucherHref, shopName, classNames, listC
1972
2000
  /* @__PURE__ */ jsxRuntime.jsx("ul", { className: lc.list, children: sorted.map((p) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: lc.item, children: /* @__PURE__ */ jsxRuntime.jsx(PendingPaymentCard, { payment: p, ...voucherHref ? { voucherHref } : {}, ...shopName ? { shopName } : {}, ...classNames ? { classNames } : {}, headingLevel: cardHeading, ...text2 }) }, p.id)) })
1973
2001
  ] });
1974
2002
  }
2003
+
2004
+ // src/account/payment-method.ts
2005
+ var FAMILY = {
2006
+ card: "card",
2007
+ credit_card: "credit_card",
2008
+ debit_card: "debit_card",
2009
+ cash_voucher: "cash_voucher",
2010
+ oxxo: "oxxo",
2011
+ spei: "spei",
2012
+ transfer: "transfer",
2013
+ bank_transfer: "transfer",
2014
+ bank_deposit: "bank_deposit",
2015
+ wallet: "wallet",
2016
+ cash: "cash",
2017
+ other: "other"
2018
+ };
2019
+ var KEYWORDS = [
2020
+ [/oxxo/, "oxxo"],
2021
+ [/spei/, "spei"],
2022
+ [/d[eé]bit/, "debit_card"],
2023
+ [/cr[eé]dit/, "credit_card"],
2024
+ [/card|tarjeta/, "card"],
2025
+ [/deposit|dep[oó]sito/, "bank_deposit"],
2026
+ [/transfer/, "transfer"],
2027
+ [/wallet|billetera|paypal|mercado ?pago|apple ?pay|google ?pay/, "wallet"],
2028
+ [/voucher|ficha|convenience|conveniencia|store|tienda/, "cash_voucher"],
2029
+ [/cash|efectivo/, "cash"]
2030
+ ];
2031
+ var BRANDS = { visa: "Visa", mastercard: "Mastercard", master: "Mastercard", amex: "American Express", american_express: "American Express", carnet: "Carnet", discover: "Discover" };
2032
+ var RAW = /^[A-Za-z0-9_.:-]+(?: [A-Za-z0-9_.:-]+)?$/;
2033
+ function paymentMethodKey(p) {
2034
+ return keyOf(p);
2035
+ }
2036
+ function keyOf(p) {
2037
+ const fam = typeof p.family === "string" ? p.family.toLowerCase() : "";
2038
+ const byLabel = () => {
2039
+ const label = typeof p.method_label === "string" ? p.method_label.toLowerCase().replace(/[_-]+/g, " ") : "";
2040
+ for (const [re, key] of KEYWORDS) if (re.test(label)) return key;
2041
+ return null;
2042
+ };
2043
+ if (fam && fam !== "other" && FAMILY[fam]) {
2044
+ const l = byLabel();
2045
+ return fam === "card" && (l === "credit_card" || l === "debit_card") ? l : FAMILY[fam];
2046
+ }
2047
+ return byLabel() ?? (fam === "other" ? "other" : null);
2048
+ }
2049
+ function paymentLabel(p, m, options = {}) {
2050
+ const custom = options.override?.(p);
2051
+ if (typeof custom === "string" && custom.trim()) return custom.trim();
2052
+ const raw = typeof p.method_label === "string" ? p.method_label.trim() : "";
2053
+ const key = keyOf(p);
2054
+ const human = raw && !RAW.test(raw);
2055
+ if (human && /\d{4}/.test(raw)) return raw;
2056
+ if (key) {
2057
+ const base = m[`payment.method.${key}`];
2058
+ if (key !== "card" && key !== "credit_card" && key !== "debit_card") return human && key === "other" ? raw : base;
2059
+ const brandRaw = typeof p.brand === "string" ? p.brand.trim() : "";
2060
+ const brand = brandRaw ? BRANDS[brandRaw.toLowerCase().replace(/[ -]/g, "_")] ?? brandRaw : "";
2061
+ const last4 = typeof p.last4 === "string" && /^\d{2,4}$/.test(p.last4.trim()) ? p.last4.trim() : "";
2062
+ return `${base}${brand ? ` ${brand}` : ""}${last4 ? ` \u2022\u2022\u2022\u2022 ${last4}` : ""}`;
2063
+ }
2064
+ return human ? raw : m["payment.method.unknown"];
2065
+ }
1975
2066
  var tone = (s) => s === "completed" ? "done" : s === "failed" ? "problem" : "current";
1976
2067
  function RefundList({ refunds, showEmpty = false, degraded, onRetry, headingLevel = 3, classNames: cx = {}, ...text2 }) {
1977
2068
  const { m, locale, date } = useAccountText(text2);
@@ -1997,7 +2088,7 @@ function RefundList({ refunds, showEmpty = false, degraded, onRetry, headingLeve
1997
2088
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.meta, children: [
1998
2089
  str(r.method_label) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1999
2090
  " \xB7 ",
2000
- str(r.method_label)
2091
+ paymentLabel({ method_label: r.method_label ?? "", status: "paid", amount: r.amount }, m)
2001
2092
  ] }) : null,
2002
2093
  r.completed_at ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2003
2094
  " \xB7 ",
@@ -2010,7 +2101,7 @@ function RefundList({ refunds, showEmpty = false, degraded, onRetry, headingLeve
2010
2101
  ] }, r.id)) })
2011
2102
  ] });
2012
2103
  }
2013
- function PaymentSummary({ payments, headingLevel = 3, classNames: cx = {}, ...text2 }) {
2104
+ function PaymentSummary({ payments, headingLevel = 3, methodLabel, classNames: cx = {}, ...text2 }) {
2014
2105
  const { m, locale, date } = useAccountText(text2);
2015
2106
  const titleId = `sf-payments-${react.useId().replace(/:/g, "")}`;
2016
2107
  const items = (Array.isArray(payments) ? payments : []).filter((p) => !!p && typeof p === "object" && typeof p.method_label === "string");
@@ -2018,8 +2109,8 @@ function PaymentSummary({ payments, headingLevel = 3, classNames: cx = {}, ...te
2018
2109
  const Heading = `h${headingLevel}`;
2019
2110
  return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-payments": true, children: [
2020
2111
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["payment.title"] }),
2021
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, children: items.map((p, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.item, "data-sf-payment": true, "data-sf-payment-status": typeof p.status === "string" ? p.status : "unknown", children: [
2022
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: p.method_label }),
2112
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, children: items.map((p, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.item, "data-sf-payment": true, "data-sf-payment-method-key": paymentMethodKey(p) ?? "unknown", "data-sf-payment-status": typeof p.status === "string" ? p.status : "unknown", children: [
2113
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-sf-payment-method": true, children: paymentLabel(p, m, methodLabel ? { override: methodLabel } : {}) }),
2023
2114
  moneyText(p.amount, locale) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2024
2115
  " \xB7 ",
2025
2116
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: moneyText(p.amount, locale) })
@@ -2196,6 +2287,8 @@ exports.barcodeValue = barcodeValue;
2196
2287
  exports.code128Modules = code128Modules;
2197
2288
  exports.enumText = enumText;
2198
2289
  exports.lineImage = lineImage;
2290
+ exports.paymentLabel = paymentLabel;
2291
+ exports.paymentMethodKey = paymentMethodKey;
2199
2292
  exports.postPurchaseAccountPromptMessages = postPurchaseAccountPromptMessages;
2200
2293
  exports.productInitials = productInitials;
2201
2294
  exports.stageTone = stageTone;