@rebuy/rebuy 2.27.0-rc.9 → 2.28.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.js CHANGED
@@ -85,6 +85,7 @@ __export(src_exports, {
85
85
  LineItemEditorV1: () => LineItemEditorV1,
86
86
  Metadata: () => Metadata,
87
87
  NO_HTML: () => NO_HTML,
88
+ OFFER_LABELS: () => OFFER_LABELS,
88
89
  ObjectFit: () => ObjectFit,
89
90
  PayButtonBlock: () => PayButtonBlock,
90
91
  PopoverPosition: () => PopoverPosition,
@@ -2229,6 +2230,178 @@ var WidgetData = import_v433.z.discriminatedUnion("type", [
2229
2230
  RebuyMonetize
2230
2231
  ]);
2231
2232
 
2233
+ // src/schema/widgets/checkout-and-beyond/offerLabels.ts
2234
+ var OFFER_LABELS = {
2235
+ addToCart: {
2236
+ ar: "\u0623\u0636\u0641 \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629",
2237
+ cs: "P\u0159idat do ko\u0161\xEDku",
2238
+ da: "L\xE6g i kurv",
2239
+ de: "In den Warenkorb",
2240
+ en: "Add to cart",
2241
+ es: "A\xF1adir al carrito",
2242
+ fi: "Lis\xE4\xE4 ostoskoriin",
2243
+ fr: "Ajouter au panier",
2244
+ ga: "Cuir sa chairt",
2245
+ he: "\u05D4\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4",
2246
+ hi: "\u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u0947\u0902",
2247
+ id: "Tambahkan ke keranjang",
2248
+ it: "Aggiungi al carrello",
2249
+ ja: "\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0",
2250
+ ko: "\uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00",
2251
+ nl: "In winkelwagen",
2252
+ no: "Legg i handlekurven",
2253
+ pl: "Dodaj do koszyka",
2254
+ pt: "Adicionar ao carrinho",
2255
+ ru: "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443",
2256
+ sv: "L\xE4gg i varukorgen",
2257
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E25\u0E07\u0E15\u0E30\u0E01\u0E23\u0E49\u0E32",
2258
+ tr: "Sepete ekle",
2259
+ uk: "\u0414\u043E\u0434\u0430\u0442\u0438 \u0432 \u043A\u043E\u0448\u0438\u043A",
2260
+ vi: "Th\xEAm v\xE0o gi\u1ECF h\xE0ng",
2261
+ zh: "\u52A0\u5165\u8D2D\u7269\u8F66"
2262
+ },
2263
+ addedToCart: {
2264
+ ar: "\u062A\u0645\u062A \u0627\u0644\u0625\u0636\u0627\u0641\u0629!",
2265
+ cs: "P\u0159id\xE1no!",
2266
+ da: "Tilf\xF8jet!",
2267
+ de: "Hinzugef\xFCgt!",
2268
+ en: "Added!",
2269
+ es: "\xA1A\xF1adido!",
2270
+ fi: "Lis\xE4tty!",
2271
+ fr: "Ajout\xE9 !",
2272
+ ga: "Curtha leis!",
2273
+ he: "\u05E0\u05D5\u05E1\u05E3!",
2274
+ hi: "\u091C\u094B\u0921\u093C\u093E \u0917\u092F\u093E!",
2275
+ id: "Ditambahkan!",
2276
+ it: "Aggiunto!",
2277
+ ja: "\u8FFD\u52A0\u3057\u307E\u3057\u305F\uFF01",
2278
+ ko: "\uCD94\uAC00\uB428!",
2279
+ nl: "Toegevoegd!",
2280
+ no: "Lagt til!",
2281
+ pl: "Dodano!",
2282
+ pt: "Adicionado!",
2283
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E!",
2284
+ sv: "Tillagd!",
2285
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E41\u0E25\u0E49\u0E27!",
2286
+ tr: "Eklendi!",
2287
+ uk: "\u0414\u043E\u0434\u0430\u043D\u043E!",
2288
+ vi: "\u0110\xE3 th\xEAm!",
2289
+ zh: "\u5DF2\u6DFB\u52A0\uFF01"
2290
+ },
2291
+ addedToCartMessage: {
2292
+ ar: "\u062A\u0645\u062A \u0625\u0636\u0627\u0641\u0629 {{quantity}} {{productTitle}} \u0625\u0644\u0649 \u0627\u0644\u0633\u0644\u0629.",
2293
+ cs: "{{quantity}} {{productTitle}} p\u0159id\xE1no do ko\u0161\xEDku.",
2294
+ da: "{{quantity}} {{productTitle}} lagt i kurven.",
2295
+ de: "{{quantity}} {{productTitle}} zum Warenkorb hinzugef\xFCgt.",
2296
+ en: "{{quantity}} {{productTitle}} added to cart.",
2297
+ es: "{{quantity}} {{productTitle}} a\xF1adido al carrito.",
2298
+ fi: "{{quantity}} {{productTitle}} lis\xE4tty ostoskoriin.",
2299
+ fr: "{{quantity}} {{productTitle}} ajout\xE9 au panier.",
2300
+ ga: "Cuireadh {{quantity}} {{productTitle}} sa chairt.",
2301
+ he: "{{quantity}} {{productTitle}} \u05E0\u05D5\u05E1\u05E3 \u05DC\u05E2\u05D2\u05DC\u05D4.",
2302
+ hi: "{{quantity}} {{productTitle}} \u0915\u093E\u0930\u094D\u091F \u092E\u0947\u0902 \u091C\u094B\u0921\u093C\u093E \u0917\u092F\u093E\u0964",
2303
+ id: "{{quantity}} {{productTitle}} ditambahkan ke keranjang.",
2304
+ it: "{{quantity}} {{productTitle}} aggiunto al carrello.",
2305
+ ja: "{{quantity}} {{productTitle}}\u3092\u30AB\u30FC\u30C8\u306B\u8FFD\u52A0\u3057\u307E\u3057\u305F\u3002",
2306
+ ko: "{{quantity}} {{productTitle}}\uC774(\uAC00) \uC7A5\uBC14\uAD6C\uB2C8\uC5D0 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",
2307
+ nl: "{{quantity}} {{productTitle}} toegevoegd aan winkelwagen.",
2308
+ no: "{{quantity}} {{productTitle}} lagt i handlekurven.",
2309
+ pl: "{{quantity}} {{productTitle}} dodano do koszyka.",
2310
+ pt: "{{quantity}} {{productTitle}} adicionado ao carrinho.",
2311
+ ru: "{{quantity}} {{productTitle}} \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u043E \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443.",
2312
+ sv: "{{quantity}} {{productTitle}} har lagts i varukorgen.",
2313
+ th: "\u0E40\u0E1E\u0E34\u0E48\u0E21 {{quantity}} {{productTitle}} \u0E25\u0E07\u0E15\u0E30\u0E01\u0E23\u0E49\u0E32\u0E41\u0E25\u0E49\u0E27",
2314
+ tr: "{{quantity}} {{productTitle}} sepete eklendi.",
2315
+ uk: "{{quantity}} {{productTitle}} \u0434\u043E\u0434\u0430\u043D\u043E \u0434\u043E \u043A\u043E\u0448\u0438\u043A\u0430.",
2316
+ vi: "\u0110\xE3 th\xEAm {{quantity}} {{productTitle}} v\xE0o gi\u1ECF h\xE0ng.",
2317
+ zh: "{{quantity}} {{productTitle}} \u5DF2\u52A0\u5165\u8D2D\u7269\u8F66\u3002"
2318
+ },
2319
+ addingToCart: {
2320
+ ar: "\u062C\u0627\u0631\u064D \u0627\u0644\u0625\u0636\u0627\u0641\u0629...",
2321
+ cs: "P\u0159id\xE1v\xE1n\xED...",
2322
+ da: "Tilf\xF8jer...",
2323
+ de: "Wird hinzugef\xFCgt...",
2324
+ en: "Adding...",
2325
+ es: "A\xF1adiendo...",
2326
+ fi: "Lis\xE4t\xE4\xE4n...",
2327
+ fr: "Ajout en cours...",
2328
+ ga: "\xC1 chur leis...",
2329
+ he: "\u05DE\u05D5\u05E1\u05D9\u05E3...",
2330
+ hi: "\u091C\u094B\u0921\u093C\u093E \u091C\u093E \u0930\u0939\u093E \u0939\u0948...",
2331
+ id: "Menambahkan...",
2332
+ it: "Aggiunta in corso...",
2333
+ ja: "\u8FFD\u52A0\u4E2D...",
2334
+ ko: "\uCD94\uAC00 \uC911...",
2335
+ nl: "Toevoegen...",
2336
+ no: "Legger til...",
2337
+ pl: "Dodawanie...",
2338
+ pt: "Adicionando...",
2339
+ ru: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435...",
2340
+ sv: "L\xE4gger till...",
2341
+ th: "\u0E01\u0E33\u0E25\u0E31\u0E07\u0E40\u0E1E\u0E34\u0E48\u0E21...",
2342
+ tr: "Ekleniyor...",
2343
+ uk: "\u0414\u043E\u0434\u0430\u0432\u0430\u043D\u043D\u044F...",
2344
+ vi: "\u0110ang th\xEAm...",
2345
+ zh: "\u6B63\u5728\u6DFB\u52A0..."
2346
+ },
2347
+ soldOut: {
2348
+ ar: "\u0646\u0641\u062F\u062A \u0627\u0644\u0643\u0645\u064A\u0629",
2349
+ cs: "Vyprod\xE1no",
2350
+ da: "Udsolgt",
2351
+ de: "Ausverkauft",
2352
+ en: "Sold out",
2353
+ es: "Agotado",
2354
+ fi: "Loppuunmyyty",
2355
+ fr: "\xC9puis\xE9",
2356
+ ga: "D\xEDolta amach",
2357
+ he: "\u05D0\u05D6\u05DC \u05DE\u05D4\u05DE\u05DC\u05D0\u05D9",
2358
+ hi: "\u0938\u094D\u091F\u0949\u0915 \u0916\u093C\u0924\u094D\u092E",
2359
+ id: "Habis terjual",
2360
+ it: "Esaurito",
2361
+ ja: "\u58F2\u308A\u5207\u308C",
2362
+ ko: "\uD488\uC808",
2363
+ nl: "Uitverkocht",
2364
+ no: "Utsolgt",
2365
+ pl: "Wyprzedane",
2366
+ pt: "Esgotado",
2367
+ ru: "\u0420\u0430\u0441\u043F\u0440\u043E\u0434\u0430\u043D\u043E",
2368
+ sv: "Sluts\xE5ld",
2369
+ th: "\u0E2A\u0E34\u0E19\u0E04\u0E49\u0E32\u0E2B\u0E21\u0E14",
2370
+ tr: "T\xFCkendi",
2371
+ uk: "\u0420\u043E\u0437\u043F\u0440\u043E\u0434\u0430\u043D\u043E",
2372
+ vi: "H\u1EBFt h\xE0ng",
2373
+ zh: "\u5DF2\u552E\u7F44"
2374
+ },
2375
+ undo: {
2376
+ ar: "\u062A\u0631\u0627\u062C\u0639",
2377
+ cs: "Zp\u011Bt",
2378
+ da: "Fortryd",
2379
+ de: "R\xFCckg\xE4ngig",
2380
+ en: "Undo",
2381
+ es: "Deshacer",
2382
+ fi: "Kumoa",
2383
+ fr: "Annuler",
2384
+ ga: "Cealaigh",
2385
+ he: "\u05D1\u05D8\u05DC",
2386
+ hi: "\u092A\u0942\u0930\u094D\u0935\u0935\u0924 \u0915\u0930\u0947\u0902",
2387
+ id: "Urungkan",
2388
+ it: "Annulla",
2389
+ ja: "\u5143\u306B\u623B\u3059",
2390
+ ko: "\uC2E4\uD589 \uCDE8\uC18C",
2391
+ nl: "Ongedaan maken",
2392
+ no: "Angre",
2393
+ pl: "Cofnij",
2394
+ pt: "Desfazer",
2395
+ ru: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",
2396
+ sv: "\xC5ngra",
2397
+ th: "\u0E40\u0E25\u0E34\u0E01\u0E17\u0E33",
2398
+ tr: "Geri al",
2399
+ uk: "\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438",
2400
+ vi: "Ho\xE0n t\xE1c",
2401
+ zh: "\u64A4\u9500"
2402
+ }
2403
+ };
2404
+
2232
2405
  // src/schema/widgets/checkout-and-beyond/switchLabels.ts
2233
2406
  var SWITCH_LABELS = {
2234
2407
  subscriptionOption: {
@@ -3224,6 +3397,10 @@ var buildOfferTemplate = ({ location: location2, name } = {}) => CABRootSection.
3224
3397
 
3225
3398
  // src/transforms/offerV1/offerCard.ts
3226
3399
  var VARIANT_SELECTOR = { button: "button", radio: "radio", select: "menu" };
3400
+ var localizedContent = (defaults, override) => {
3401
+ const trimmed = override?.trim();
3402
+ return trimmed ? { ...defaults, en: trimmed } : defaults;
3403
+ };
3227
3404
  var buildStyledText = (token, style, color = "base") => {
3228
3405
  const marks = [
3229
3406
  { attrs: { color, fontSize: style?.textSize ?? "base" }, type: "textStyle" }
@@ -3328,60 +3505,45 @@ var buildQuantity = (settings) => {
3328
3505
  var buildSubscriptionButton = (settings) => {
3329
3506
  if (settings.productType !== "both" && settings.productType !== "subscription") return [];
3330
3507
  const language = settings.language;
3508
+ const slot = (buttonField, override) => ({
3509
+ buttonField,
3510
+ content: localizedContent(SWITCH_LABELS[buttonField], override),
3511
+ sectionType: "text"
3512
+ });
3331
3513
  return [
3332
3514
  {
3333
3515
  action: "switchToSubscription",
3334
3516
  buttonStyle: "plain",
3335
3517
  sections: [
3336
- {
3337
- buttonField: "switchToSubscriptionWithDiscount",
3338
- content: {
3339
- en: language?.upgradeToSubscription || "Upgrade to Subscription and Save {{subscription_discount}}%"
3340
- },
3341
- sectionType: "text"
3342
- },
3343
- {
3344
- buttonField: "switchToSubscriptionNoDiscount",
3345
- content: { en: language?.cartSwitchToSubscription || "Upgrade to Subscription" },
3346
- sectionType: "text"
3347
- },
3348
- {
3349
- buttonField: "switchToOneTimePurchase",
3350
- content: { en: language?.cartSwitchToOnetime || "One-time purchase" },
3351
- sectionType: "text"
3352
- }
3518
+ slot("subscriptionOption", void 0),
3519
+ slot("switchToOneTimePurchase", language?.cartSwitchToOnetime),
3520
+ slot("switchToSubscriptionNoDiscount", language?.cartSwitchToSubscription),
3521
+ slot("switchToSubscriptionWithDiscount", language?.upgradeToSubscription)
3353
3522
  ],
3354
3523
  sectionType: "button"
3355
3524
  }
3356
3525
  ];
3357
3526
  };
3358
- var buildAddButton = (settings) => ({
3359
- action: "addToOrder",
3360
- buttonStyle: settings.button?.kind ?? "primary",
3361
- sections: [
3362
- {
3363
- buttonField: "addToCart",
3364
- content: { en: settings.language?.addToCart ?? "Add to cart" },
3365
- sectionType: "text"
3366
- },
3367
- {
3368
- buttonField: "addingToCart",
3369
- content: { en: settings.language?.addingToCart ?? "Adding..." },
3370
- sectionType: "text"
3371
- },
3372
- {
3373
- buttonField: "addedToCart",
3374
- content: { en: settings.language?.addedToCart ?? "Added!" },
3375
- sectionType: "text"
3376
- },
3377
- {
3378
- buttonField: "soldOut",
3379
- content: { en: settings.language?.soldOutLabel ?? "Sold out" },
3380
- sectionType: "text"
3381
- }
3382
- ],
3383
- sectionType: "button"
3384
- });
3527
+ var BUTTON_KINDS = ["plain", "primary", "secondary"];
3528
+ var buildAddButton = (settings) => {
3529
+ const kind = settings.button?.kind;
3530
+ const slot = (buttonField, override) => ({
3531
+ buttonField,
3532
+ content: localizedContent(OFFER_LABELS[buttonField], override),
3533
+ sectionType: "text"
3534
+ });
3535
+ return {
3536
+ action: "addToOrder",
3537
+ buttonStyle: BUTTON_KINDS.includes(kind) ? kind : "primary",
3538
+ sections: [
3539
+ slot("addToCart", settings.language?.addToCart),
3540
+ slot("addingToCart", settings.language?.addingToCart),
3541
+ slot("addedToCart", settings.language?.addedToCart),
3542
+ slot("soldOut", settings.language?.soldOutLabel)
3543
+ ],
3544
+ sectionType: "button"
3545
+ };
3546
+ };
3385
3547
  var rowsLayout = (sections) => ({
3386
3548
  direction: "rows",
3387
3549
  sections,
@@ -3465,15 +3627,17 @@ var buildBanner = (language) => language?.successBannerEnabled ? [
3465
3627
  dismissible: true,
3466
3628
  sections: [
3467
3629
  {
3468
- content: {
3469
- en: language.successBannerMessageRte ?? "{{quantity}} {{productTitle}} added to cart."
3470
- },
3630
+ /**
3631
+ * A defined v1 message (RTE doc or string) passes through verbatim as `en`;
3632
+ * absent falls back to the localized defaults (P4 language policy).
3633
+ */
3634
+ content: language.successBannerMessageRte ? { ...OFFER_LABELS.addedToCartMessage, en: language.successBannerMessageRte } : OFFER_LABELS.addedToCartMessage,
3471
3635
  sectionType: "text"
3472
3636
  },
3473
3637
  {
3474
3638
  action: "undoAddToOrder",
3475
3639
  buttonStyle: "plain",
3476
- sections: [{ buttonField: "buttonLabel", content: { en: "Undo" }, sectionType: "text" }],
3640
+ sections: [{ buttonField: "buttonLabel", content: OFFER_LABELS.undo, sectionType: "text" }],
3477
3641
  sectionType: "button"
3478
3642
  }
3479
3643
  ],