@delopay/sdk 0.122.0 → 0.123.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/index.cjs CHANGED
@@ -61,6 +61,7 @@ __export(index_exports, {
61
61
  PANES_MAX: () => PANES_MAX,
62
62
  PANE_CATEGORY_KEYS: () => PANE_CATEGORY_KEYS,
63
63
  PANE_ICON_KEYS: () => PANE_ICON_KEYS,
64
+ RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
64
65
  Regions: () => Regions,
65
66
  Risk: () => Risk,
66
67
  STRIPE_FALLBACK_PANE_CATALOG: () => STRIPE_FALLBACK_PANE_CATALOG,
@@ -88,6 +89,7 @@ __export(index_exports, {
88
89
  buildBrandingExport: () => buildBrandingExport,
89
90
  buttonPadValue: () => buttonPadValue,
90
91
  checkoutCopy: () => checkoutCopy,
92
+ checkoutLocaleDir: () => checkoutLocaleDir,
91
93
  cloneBranding: () => cloneBranding,
92
94
  cloneCustomField: () => cloneCustomField,
93
95
  cloneNativePane: () => cloneNativePane,
@@ -5369,7 +5371,26 @@ var SURCHARGE_FIGURE_MODES = [
5369
5371
  "amountThenPercent",
5370
5372
  "percentThenAmount"
5371
5373
  ];
5372
- var CHECKOUT_LOCALES = ["en", "de"];
5374
+ var CHECKOUT_LOCALES = [
5375
+ "en",
5376
+ "de",
5377
+ "fr",
5378
+ "es",
5379
+ "it",
5380
+ "nl",
5381
+ // Simplified and traditional are separate dictionaries in the checkout,
5382
+ // not region variants: they use different characters, so a merchant who
5383
+ // writes one has not written the other.
5384
+ "zh",
5385
+ "zh-Hant",
5386
+ "hi",
5387
+ "ar"
5388
+ ];
5389
+ var RTL_CHECKOUT_LOCALES = ["ar"];
5390
+ function checkoutLocaleDir(locale) {
5391
+ const base = String(locale ?? "").toLowerCase().split("-")[0];
5392
+ return RTL_CHECKOUT_LOCALES.includes(base) ? "rtl" : "ltr";
5393
+ }
5373
5394
  var LOCALIZABLE_COPY_FIELDS = [
5374
5395
  "headerText",
5375
5396
  "payButtonLabel",
@@ -6093,14 +6114,18 @@ function visibleCustomFields(fields, ctx) {
6093
6114
  }
6094
6115
  function translationFor(map, locale) {
6095
6116
  if (!locale) return null;
6096
- const own = (k) => {
6097
- const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : void 0;
6098
- return typeof v === "string" && v.length > 0 ? v : null;
6099
- };
6100
- const exact = own(locale);
6101
- if (exact) return exact;
6102
- const base = locale.split("-")[0];
6103
- return base && base !== locale ? own(base) : null;
6117
+ const folded = /* @__PURE__ */ new Map();
6118
+ for (const [k, v] of Object.entries(map)) {
6119
+ if (typeof v === "string" && v.length > 0 && !folded.has(k.toLowerCase())) {
6120
+ folded.set(k.toLowerCase(), v);
6121
+ }
6122
+ }
6123
+ const parts = locale.toLowerCase().split("-");
6124
+ for (let i = parts.length; i > 0; i -= 1) {
6125
+ const hit = folded.get(parts.slice(0, i).join("-"));
6126
+ if (hit) return hit;
6127
+ }
6128
+ return null;
6104
6129
  }
6105
6130
  function customFieldText(field, part, locale) {
6106
6131
  const map = part === "label" ? field.labelTranslations : part === "placeholder" ? field.placeholderTranslations : field.helpTextTranslations;
@@ -7401,6 +7426,7 @@ var encodeNativePanes = encodePanes;
7401
7426
  PANES_MAX,
7402
7427
  PANE_CATEGORY_KEYS,
7403
7428
  PANE_ICON_KEYS,
7429
+ RTL_CHECKOUT_LOCALES,
7404
7430
  Regions,
7405
7431
  Risk,
7406
7432
  STRIPE_FALLBACK_PANE_CATALOG,
@@ -7428,6 +7454,7 @@ var encodeNativePanes = encodePanes;
7428
7454
  buildBrandingExport,
7429
7455
  buttonPadValue,
7430
7456
  checkoutCopy,
7457
+ checkoutLocaleDir,
7431
7458
  cloneBranding,
7432
7459
  cloneCustomField,
7433
7460
  cloneNativePane,