@alma/widgets 2.3.4 → 2.5.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.
Files changed (36) hide show
  1. package/dist/raw/widgets.js +166 -75
  2. package/dist/raw/widgets.js.map +1 -1
  3. package/dist/raw/widgets.m.js +166 -75
  4. package/dist/raw/widgets.m.js.map +1 -1
  5. package/dist/raw/widgets.modern.js +163 -71
  6. package/dist/raw/widgets.modern.js.map +1 -1
  7. package/dist/raw/widgets.umd.js +166 -75
  8. package/dist/raw/widgets.umd.js.map +1 -1
  9. package/dist/types/Widgets/EligibilityModal/DesktopModal/index.d.ts +3 -1
  10. package/dist/types/Widgets/EligibilityModal/MobileModal/index.d.ts +3 -1
  11. package/dist/types/Widgets/EligibilityModal/ModalContainer.test.d.ts +1 -0
  12. package/dist/types/Widgets/EligibilityModal/classNames.const.d.ts +18 -0
  13. package/dist/types/Widgets/EligibilityModal/components/Title/index.d.ts +3 -1
  14. package/dist/types/Widgets/EligibilityModal/modal.test.d.ts +1 -0
  15. package/dist/types/Widgets/PaymentPlans/__tests__/Basics.test.d.ts +1 -0
  16. package/dist/types/Widgets/PaymentPlans/__tests__/Credit.test.d.ts +1 -0
  17. package/dist/types/Widgets/PaymentPlans/__tests__/CustomTransitionDelay.test.d.ts +1 -0
  18. package/dist/types/Widgets/PaymentPlans/__tests__/HideWidget.test.d.ts +1 -0
  19. package/dist/types/Widgets/PaymentPlans/__tests__/IneligibleOptions.test.d.ts +1 -0
  20. package/dist/types/Widgets/PaymentPlans/__tests__/LanguageCheck.test.d.ts +1 -0
  21. package/dist/types/Widgets/PaymentPlans/__tests__/LaunchModal.test.d.ts +1 -0
  22. package/dist/types/Widgets/PaymentPlans/__tests__/SuggestedPaymentPlan.test.d.ts +1 -0
  23. package/dist/types/Widgets/PaymentPlans/__tests__/WithoutPlans.test.d.ts +1 -0
  24. package/dist/types/Widgets/PaymentPlans/classNames.const.d.ts +13 -0
  25. package/dist/types/test/fixtures.d.ts +41 -0
  26. package/dist/types/types.d.ts +7 -1
  27. package/dist/types/utils/index.test.d.ts +1 -0
  28. package/dist/widgets.js +1 -1
  29. package/dist/widgets.js.map +1 -1
  30. package/dist/widgets.m.js +1 -1
  31. package/dist/widgets.m.js.map +1 -1
  32. package/dist/widgets.modern.js +1 -1
  33. package/dist/widgets.modern.js.map +1 -1
  34. package/dist/widgets.umd.js +1 -1
  35. package/dist/widgets.umd.js.map +1 -1
  36. package/package.json +1 -1
@@ -1835,8 +1835,9 @@ var messagesDE = {
1835
1835
  "eligibility-modal.credit-commitment": "Ein Kredit verpflichtet Sie und muss zurückgezahlt werden. Prüfen Sie Ihre Rückzahlungsfähigkeit, bevor Sie sich verpflichten.",
1836
1836
  "eligibility-modal.credit-cost": "Davon Kreditkosten",
1837
1837
  "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1838
- "eligibility-modal.no-eligibility": "Ups, die Simulation scheint nicht funktioniert zu haben.",
1839
- "eligibility-modal.title": "<highlighted>Bezahlen Sie in Raten</highlighted> oder später per Kreditkarte mit Alma.",
1838
+ "eligibility-modal.no-eligibility": "Ups, die Simulation hat anscheinend nicht funktioniert.",
1839
+ "eligibility-modal.title": "<highlighted>Bezahlen Sie in Raten</highlighted> per Kreditkarte mit Alma.",
1840
+ "eligibility-modal.title-deferred": "<highlighted>Bezahlen Sie in Raten</highlighted> oder später per Kreditkarte mit Alma.",
1840
1841
  "eligibility-modal.total": "Insgesamt",
1841
1842
  "installments.today": "Heutzutage",
1842
1843
  "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
@@ -1858,7 +1859,8 @@ var messagesEN = {
1858
1859
  "eligibility-modal.credit-cost": "Of which cost of credit",
1859
1860
  "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1860
1861
  "eligibility-modal.no-eligibility": "Oops, looks like the simulation didn't work.",
1861
- "eligibility-modal.title": "<highlighted>Pay in installments</highlighted> or later by credit card with Alma.",
1862
+ "eligibility-modal.title": "<highlighted>Pay in installments</highlighted> by credit card with Alma.",
1863
+ "eligibility-modal.title-deferred": "<highlighted>Pay in installments</highlighted> or later by credit card with Alma.",
1862
1864
  "eligibility-modal.total": "Total",
1863
1865
  "installments.today": "Today",
1864
1866
  "payment-plan-strings.day-abbreviation": "T{numberOfDeferredDays}",
@@ -1880,7 +1882,8 @@ var messagesES = {
1880
1882
  "eligibility-modal.credit-cost": "Coste de crédito (incl. en el total)",
1881
1883
  "eligibility-modal.credit-cost-amount": "{creditCost} (TAE {TAEG})",
1882
1884
  "eligibility-modal.no-eligibility": "Uy, parece que la simulación no ha funcionado.",
1883
- "eligibility-modal.title": "<highlighted>Paga a plazos</highlighted> o más adelante con tu tarjeta, a través de Alma.",
1885
+ "eligibility-modal.title": "<highlighted>Paga a plazos</highlighted> con tarjeta de crédito con Alma.",
1886
+ "eligibility-modal.title-deferred": "<highlighted>Paga a plazos</highlighted> o más adelante con tu tarjeta, a través de Alma.",
1884
1887
  "eligibility-modal.total": "Total",
1885
1888
  "installments.today": "Hoy",
1886
1889
  "payment-plan-strings.day-abbreviation": "D{numberOfDeferredDays}",
@@ -1901,8 +1904,9 @@ var messagesFR = {
1901
1904
  "eligibility-modal.credit-commitment": "Un crédit vous engage et doit être remboursé. Vérifiez vos capacités de remboursement avant de vous engager.",
1902
1905
  "eligibility-modal.credit-cost": "Dont coût du crédit",
1903
1906
  "eligibility-modal.credit-cost-amount": "{creditCost} (TAEG {TAEG})",
1904
- "eligibility-modal.no-eligibility": "Oups, il semblerait que la simulation n'aie pas fonctionné.",
1905
- "eligibility-modal.title": "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
1907
+ "eligibility-modal.no-eligibility": "Oups, il semblerait que la simulation n'ait pas fonctionné.",
1908
+ "eligibility-modal.title": "<highlighted>Payez en plusieurs fois</highlighted> par carte bancaire avec Alma.",
1909
+ "eligibility-modal.title-deferred": "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
1906
1910
  "eligibility-modal.total": "Total",
1907
1911
  "installments.today": "Aujourd'hui",
1908
1912
  "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
@@ -1924,7 +1928,8 @@ var messagesIT = {
1924
1928
  "eligibility-modal.credit-cost": "Di cui commissioni",
1925
1929
  "eligibility-modal.credit-cost-amount": "{creditCost} (TAEG {TAEG})",
1926
1930
  "eligibility-modal.no-eligibility": "Ops, sembra che la simulazione non abbia funzionato.",
1927
- "eligibility-modal.title": "<highlighted>Paga a rate</highlighted> e posticipa il pagamento con Alma, senza interessi.",
1931
+ "eligibility-modal.title": "<highlighted>Paga a rate</highlighted> con carta di credito con Alma.",
1932
+ "eligibility-modal.title-deferred": "<highlighted>Paga a rate</highlighted> e posticipa il pagamento con Alma, senza interessi.",
1928
1933
  "eligibility-modal.total": "Totale",
1929
1934
  "installments.today": "Oggi",
1930
1935
  "payment-plan-strings.day-abbreviation": "G{numberOfDeferredDays}",
@@ -1946,7 +1951,8 @@ var messagesNL = {
1946
1951
  "eligibility-modal.credit-cost": "Waarvan kosten van krediet",
1947
1952
  "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1948
1953
  "eligibility-modal.no-eligibility": "Oeps, het lijkt erop dat de simulatie niet werkte.",
1949
- "eligibility-modal.title": "<highlighted>Betaal in termijnen</highlighted> of later per credit card met Alma.",
1954
+ "eligibility-modal.title": "<highlighted>Betaal in termijnen</highlighted> met kredietkaart bij Alma.",
1955
+ "eligibility-modal.title-deferred": "<highlighted>Betaal in termijnen</highlighted> of later per credit card met Alma.",
1950
1956
  "eligibility-modal.total": "Totaal",
1951
1957
  "installments.today": "Tegenwoordig",
1952
1958
  "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
@@ -2049,16 +2055,34 @@ var fetchFromApi = function fetchFromApi(url, data, headers) {
2049
2055
  }
2050
2056
  };
2051
2057
 
2058
+ var isPlanEligible = function isPlanEligible(plan, configPlan) {
2059
+ if (!plan.eligible) {
2060
+ return false;
2061
+ }
2062
+
2063
+ return configPlan ? plan.purchase_amount >= (configPlan == null ? void 0 : configPlan.minAmount) && plan.purchase_amount <= (configPlan == null ? void 0 : configPlan.maxAmount) : false;
2064
+ };
2065
+
2066
+ var getPaymentPlanBoundaries = function getPaymentPlanBoundaries(plan, configPlan) {
2067
+ var _plan$constraints;
2068
+
2069
+ // When the plan is not eligible, the purchase amount constraints is given from the merchant config
2070
+ var purchaseAmountConstraints = (_plan$constraints = plan.constraints) == null ? void 0 : _plan$constraints.purchase_amount;
2071
+
2072
+ if (purchaseAmountConstraints && configPlan) {
2073
+ return {
2074
+ minAmount: Math.max(configPlan.minAmount, purchaseAmountConstraints == null ? void 0 : purchaseAmountConstraints.minimum),
2075
+ maxAmount: Math.min(configPlan.maxAmount, purchaseAmountConstraints == null ? void 0 : purchaseAmountConstraints.maximum)
2076
+ };
2077
+ }
2078
+
2079
+ return configPlan != null ? configPlan : {};
2080
+ };
2081
+
2052
2082
  var filterELigibility = function filterELigibility(eligibilities, configPlans) {
2053
2083
  // Remove p1x
2054
2084
  var filteredEligibilityPlans = eligibilities.filter(function (plan) {
2055
2085
  return !(plan.installments_count === 1 && plan.deferred_days === 0 && plan.deferred_months === 0);
2056
- }) // Keeps the plans that have a payment_plan property
2057
- .filter(function (plan) {
2058
- return plan.payment_plan;
2059
- }) // Remove plans that have a reasons property
2060
- .filter(function (plan) {
2061
- return !plan.reasons;
2062
2086
  }); // If no configPlans was provided, return eligibility response
2063
2087
 
2064
2088
  if (!configPlans) {
@@ -2074,10 +2098,8 @@ var filterELigibility = function filterELigibility(eligibilities, configPlans) {
2074
2098
  return plan.installments_count === configPlan.installmentsCount && eligibilityDeferredDays === configPlanDeferredDays;
2075
2099
  });
2076
2100
  return _extends({}, plan, {
2077
- eligible: relatedConfigPlan ? plan.purchase_amount >= (relatedConfigPlan == null ? void 0 : relatedConfigPlan.minAmount) && plan.purchase_amount <= (relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount) : false,
2078
- minAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.minAmount,
2079
- maxAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount
2080
- });
2101
+ eligible: isPlanEligible(plan, relatedConfigPlan)
2102
+ }, getPaymentPlanBoundaries(plan, relatedConfigPlan));
2081
2103
  });
2082
2104
  };
2083
2105
 
@@ -2151,6 +2173,29 @@ function CrossIcon(_ref) {
2151
2173
  }));
2152
2174
  }
2153
2175
 
2176
+ /**
2177
+ * Prefix classes to avoid name collisions.
2178
+ */
2179
+ var prefix = 'alma-eligibility-modal';
2180
+ /**
2181
+ * Class names for the **eligibility modale** widget.
2182
+ * Those classes are intended to be used by the **merchant developer**.
2183
+ */
2184
+
2185
+ var STATIC_CUSTOMISATION_CLASSES = {
2186
+ leftSide: prefix + '-left-side',
2187
+ rightSide: prefix + '-right-side',
2188
+ title: prefix + '-title',
2189
+ info: prefix + '-info',
2190
+ infoMessage: prefix + '-info-message',
2191
+ eligibilityOptions: prefix + '-eligibility-options',
2192
+ activeOption: prefix + '-active-option',
2193
+ closeButton: prefix + '-close-button',
2194
+ scheduleDetails: prefix + '-schedule-details',
2195
+ scheduleTotal: prefix + '-schedule-total',
2196
+ scheduleCredit: prefix + '-schedule-credit'
2197
+ };
2198
+
2154
2199
  var _excluded = ["children", "isOpen", "onClose", "className", "contentClassName", "scrollable"];
2155
2200
 
2156
2201
  var ControlledModal = function ControlledModal(_ref) {
@@ -2183,7 +2228,7 @@ var ControlledModal = function ControlledModal(_ref) {
2183
2228
  className: s$1.header
2184
2229
  }, /*#__PURE__*/React.createElement("button", {
2185
2230
  onClick: onClose,
2186
- className: s$1.closeButton,
2231
+ className: cx(s$1.closeButton, STATIC_CUSTOMISATION_CLASSES.closeButton),
2187
2232
  "data-testid": "modal-close-button"
2188
2233
  }, /*#__PURE__*/React.createElement(CrossIcon, null))), /*#__PURE__*/React.createElement("div", {
2189
2234
  className: cx(s$1.content, contentClassName, (_cx = {}, _cx[s$1.contentScrollable] = scrollable, _cx))
@@ -2208,6 +2253,20 @@ var paymentPlanShorthandName = function paymentPlanShorthandName(payment) {
2208
2253
  return installmentsCount + "x";
2209
2254
  }
2210
2255
  };
2256
+
2257
+ var withNoFee = function withNoFee(payment) {
2258
+ var _payment$payment_plan;
2259
+
2260
+ if ((_payment$payment_plan = payment.payment_plan) != null && _payment$payment_plan.every(function (plan) {
2261
+ return plan.customer_fee === 0 && plan.customer_interest === 0;
2262
+ })) {
2263
+ return /*#__PURE__*/React.createElement(React.Fragment, null, ' ', /*#__PURE__*/React.createElement(FormattedMessage, {
2264
+ id: "payment-plan-strings.no-fee",
2265
+ defaultMessage: '(sans frais)'
2266
+ }));
2267
+ }
2268
+ };
2269
+
2211
2270
  var paymentPlanInfoText = function paymentPlanInfoText(payment) {
2212
2271
  var deferred_days = payment.deferred_days,
2213
2272
  deferred_months = payment.deferred_months,
@@ -2217,20 +2276,10 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
2217
2276
  _payment$minAmount = payment.minAmount,
2218
2277
  minAmount = _payment$minAmount === void 0 ? 0 : _payment$minAmount,
2219
2278
  _payment$maxAmount = payment.maxAmount,
2220
- maxAmount = _payment$maxAmount === void 0 ? 0 : _payment$maxAmount;
2279
+ maxAmount = _payment$maxAmount === void 0 ? 0 : _payment$maxAmount,
2280
+ payment_plan = payment.payment_plan;
2221
2281
  var deferredDaysCount = deferred_days + deferred_months * 30;
2222
2282
 
2223
- var withNoFee = function withNoFee() {
2224
- if (payment.payment_plan.every(function (plan) {
2225
- return plan.customer_fee === 0 && plan.customer_interest === 0;
2226
- })) {
2227
- return /*#__PURE__*/React.createElement(React.Fragment, null, ' ', /*#__PURE__*/React.createElement(FormattedMessage, {
2228
- id: "payment-plan-strings.no-fee",
2229
- defaultMessage: '(sans frais)'
2230
- }));
2231
- }
2232
- };
2233
-
2234
2283
  if (!eligible) {
2235
2284
  return purchaseAmount > maxAmount ? /*#__PURE__*/React.createElement(FormattedMessage, {
2236
2285
  id: "payment-plan-strings.ineligible-greater-than-max",
@@ -2253,27 +2302,32 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
2253
2302
  })
2254
2303
  }
2255
2304
  });
2305
+ } else if (!payment_plan) {
2306
+ /* This error should never happen. We added this condition to avoid a typescript warning on
2307
+ payment_plan possibly undefined. As far as we know, it only happens when the plan is not
2308
+ eligible, which is checked above. */
2309
+ throw Error("No payment plan provided for payment in " + installmentsCount + " installments. Please contact us if you see this error.");
2256
2310
  } else if (deferredDaysCount !== 0 && installmentsCount === 1) {
2257
2311
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
2258
2312
  id: "payment-plan-strings.deferred",
2259
2313
  defaultMessage: "{totalAmount} \xE0 payer le {dueDate}",
2260
2314
  values: {
2261
2315
  totalAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2262
- value: priceFromCents(payment.payment_plan[0].total_amount),
2316
+ value: priceFromCents(payment_plan[0].total_amount),
2263
2317
  style: "currency",
2264
2318
  currency: "EUR"
2265
2319
  }),
2266
2320
  dueDate: /*#__PURE__*/React.createElement(FormattedDate, {
2267
- value: secondsToMilliseconds(payment.payment_plan[0].due_date),
2321
+ value: secondsToMilliseconds(payment_plan[0].due_date),
2268
2322
  day: "numeric",
2269
2323
  month: "long",
2270
2324
  year: "numeric"
2271
2325
  })
2272
2326
  }
2273
- }), withNoFee());
2327
+ }), withNoFee(payment));
2274
2328
  } else if (installmentsCount > 0) {
2275
- var areInstallmentsOfSameAmount = payment.payment_plan.every(function (installment, index) {
2276
- return index === 0 || installment.total_amount === payment.payment_plan[0].total_amount;
2329
+ var areInstallmentsOfSameAmount = payment_plan == null ? void 0 : payment_plan.every(function (installment, index) {
2330
+ return index === 0 || installment.total_amount === payment_plan[0].total_amount;
2277
2331
  });
2278
2332
 
2279
2333
  if (areInstallmentsOfSameAmount) {
@@ -2282,13 +2336,13 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
2282
2336
  defaultMessage: "{installmentsCount} x {totalAmount}",
2283
2337
  values: {
2284
2338
  totalAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2285
- value: priceFromCents(payment.payment_plan[0].total_amount),
2339
+ value: priceFromCents(payment_plan[0].total_amount),
2286
2340
  style: "currency",
2287
2341
  currency: "EUR"
2288
2342
  }),
2289
2343
  installmentsCount: installmentsCount
2290
2344
  }
2291
- }), withNoFee());
2345
+ }), withNoFee(payment));
2292
2346
  }
2293
2347
 
2294
2348
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -2296,18 +2350,18 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
2296
2350
  defaultMessage: "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
2297
2351
  values: {
2298
2352
  firstInstallmentAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2299
- value: priceFromCents(payment.payment_plan[0].total_amount),
2353
+ value: priceFromCents(payment_plan[0].total_amount),
2300
2354
  style: "currency",
2301
2355
  currency: "EUR"
2302
2356
  }),
2303
2357
  numberOfRemainingInstallments: installmentsCount - 1,
2304
2358
  othersInstallmentAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2305
- value: priceFromCents(payment.payment_plan[1].total_amount),
2359
+ value: priceFromCents(payment_plan[1].total_amount),
2306
2360
  style: "currency",
2307
2361
  currency: "EUR"
2308
2362
  })
2309
2363
  }
2310
- }), withNoFee());
2364
+ }), withNoFee(payment));
2311
2365
  }
2312
2366
 
2313
2367
  return /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -2323,13 +2377,13 @@ var EligibilityPlansButtons = function EligibilityPlansButtons(_ref) {
2323
2377
  currentPlanIndex = _ref.currentPlanIndex,
2324
2378
  setCurrentPlanIndex = _ref.setCurrentPlanIndex;
2325
2379
  return /*#__PURE__*/React.createElement("div", {
2326
- className: s$2.buttons
2380
+ className: cx(s$2.buttons, STATIC_CUSTOMISATION_CLASSES.eligibilityOptions)
2327
2381
  }, eligibilityPlans.map(function (eligibilityPlan, index) {
2328
2382
  var _cx;
2329
2383
 
2330
2384
  return /*#__PURE__*/React.createElement("button", {
2331
2385
  key: index,
2332
- className: cx((_cx = {}, _cx[s$2.active] = index === currentPlanIndex, _cx)),
2386
+ className: cx((_cx = {}, _cx[cx(s$2.active, STATIC_CUSTOMISATION_CLASSES.activeOption)] = index === currentPlanIndex, _cx)),
2333
2387
  onClick: function onClick() {
2334
2388
  return setCurrentPlanIndex(index);
2335
2389
  }
@@ -2348,10 +2402,10 @@ var Schedule = function Schedule(_ref) {
2348
2402
  var isCredit = currentPlan && currentPlan.installments_count > 4;
2349
2403
  var intl = useIntl();
2350
2404
  return /*#__PURE__*/React.createElement("div", {
2351
- className: s$3.schedule,
2405
+ className: cx(s$3.schedule, STATIC_CUSTOMISATION_CLASSES.scheduleDetails),
2352
2406
  "data-testid": "modal-installments-element"
2353
2407
  }, /*#__PURE__*/React.createElement("div", {
2354
- className: cx(s$3.scheduleLine, s$3.total)
2408
+ className: cx(s$3.scheduleLine, s$3.total, STATIC_CUSTOMISATION_CLASSES.scheduleTotal)
2355
2409
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2356
2410
  id: "eligibility-modal.total",
2357
2411
  defaultMessage: "Total"
@@ -2360,7 +2414,7 @@ var Schedule = function Schedule(_ref) {
2360
2414
  style: "currency",
2361
2415
  currency: "EUR"
2362
2416
  }))), /*#__PURE__*/React.createElement("div", {
2363
- className: cx(s$3.scheduleLine, s$3.creditCost)
2417
+ className: cx(s$3.scheduleLine, s$3.creditCost, STATIC_CUSTOMISATION_CLASSES.scheduleCredit)
2364
2418
  }, isCredit ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2365
2419
  id: "eligibility-modal.credit-cost",
2366
2420
  defaultMessage: "Dont co\xFBt du cr\xE9dit"
@@ -2413,13 +2467,15 @@ var s$4 = {"list":"_180ro","listItem":"_1HqCO","bullet":"_3B8wx"};
2413
2467
 
2414
2468
  var Info = function Info() {
2415
2469
  return /*#__PURE__*/React.createElement("div", {
2416
- className: s$4.list,
2470
+ className: cx(s$4.list, STATIC_CUSTOMISATION_CLASSES.info),
2417
2471
  "data-testid": "modal-info-element"
2418
2472
  }, /*#__PURE__*/React.createElement("div", {
2419
2473
  className: s$4.listItem
2420
2474
  }, /*#__PURE__*/React.createElement("div", {
2421
2475
  className: s$4.bullet
2422
- }, "1"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2476
+ }, "1"), /*#__PURE__*/React.createElement("div", {
2477
+ className: STATIC_CUSTOMISATION_CLASSES.infoMessage
2478
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
2423
2479
  id: "eligibility-modal.bullet-1",
2424
2480
  defaultMessage: "Choisissez <strong>Alma</strong> au moment du paiement.",
2425
2481
  values: {
@@ -2431,7 +2487,9 @@ var Info = function Info() {
2431
2487
  className: s$4.listItem
2432
2488
  }, /*#__PURE__*/React.createElement("div", {
2433
2489
  className: s$4.bullet
2434
- }, "2"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2490
+ }, "2"), /*#__PURE__*/React.createElement("div", {
2491
+ className: STATIC_CUSTOMISATION_CLASSES.infoMessage
2492
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
2435
2493
  id: "eligibility-modal.bullet-2",
2436
2494
  defaultMessage: "Renseignez les <strong>informations</strong> demand\xE9es.",
2437
2495
  values: {
@@ -2443,7 +2501,9 @@ var Info = function Info() {
2443
2501
  className: s$4.listItem
2444
2502
  }, /*#__PURE__*/React.createElement("div", {
2445
2503
  className: s$4.bullet
2446
- }, "3"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2504
+ }, "3"), /*#__PURE__*/React.createElement("div", {
2505
+ className: STATIC_CUSTOMISATION_CLASSES.infoMessage
2506
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
2447
2507
  id: "eligibility-modal.bullet-3",
2448
2508
  defaultMessage: "La validation de votre paiement <strong>instantan\xE9e</strong> !",
2449
2509
  values: {
@@ -2499,32 +2559,44 @@ var Logo = function Logo() {
2499
2559
 
2500
2560
  var s$6 = {"title":"_3ERx-"};
2501
2561
 
2502
- var Title = function Title() {
2562
+ var Title = function Title(_ref) {
2563
+ var isSomePlanDeferred = _ref.isSomePlanDeferred;
2503
2564
  return /*#__PURE__*/React.createElement("div", {
2504
- className: s$6.title,
2565
+ className: cx(s$6.title, STATIC_CUSTOMISATION_CLASSES.title),
2505
2566
  "data-testid": "modal-title-element"
2506
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
2507
- id: "eligibility-modal.title",
2567
+ }, isSomePlanDeferred ? /*#__PURE__*/React.createElement(FormattedMessage, {
2568
+ id: 'eligibility-modal.title-deferred',
2508
2569
  defaultMessage: "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
2509
2570
  values: {
2510
2571
  highlighted: function highlighted() {
2511
2572
  return /*#__PURE__*/React.createElement("span", null, [].slice.call(arguments));
2512
2573
  }
2513
2574
  }
2575
+ }) : /*#__PURE__*/React.createElement(FormattedMessage, {
2576
+ id: 'eligibility-modal.title',
2577
+ defaultMessage: "<highlighted>Payez en plusieurs fois</highlighted> par carte bancaire avec Alma.",
2578
+ values: {
2579
+ highlighted: function highlighted() {
2580
+ return /*#__PURE__*/React.createElement("span", null, [].slice.call(arguments));
2581
+ }
2582
+ }
2514
2583
  }));
2515
2584
  };
2516
2585
 
2517
2586
  var s$7 = {"container":"_21g6u","block":"_3zaP5","left":"_2SBRC"};
2518
2587
 
2519
2588
  var DesktopModal = function DesktopModal(_ref) {
2520
- var children = _ref.children;
2589
+ var children = _ref.children,
2590
+ isSomePlanDeferred = _ref.isSomePlanDeferred;
2521
2591
  return /*#__PURE__*/React.createElement("div", {
2522
2592
  className: s$7.container,
2523
2593
  "data-testid": "modal-container"
2524
2594
  }, /*#__PURE__*/React.createElement("div", {
2525
- className: cx([s$7.block, s$7.left])
2526
- }, /*#__PURE__*/React.createElement(Title, null), /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null)), /*#__PURE__*/React.createElement("div", {
2527
- className: s$7.block
2595
+ className: cx([s$7.block, s$7.left, STATIC_CUSTOMISATION_CLASSES.leftSide])
2596
+ }, /*#__PURE__*/React.createElement(Title, {
2597
+ isSomePlanDeferred: isSomePlanDeferred
2598
+ }), /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null)), /*#__PURE__*/React.createElement("div", {
2599
+ className: cx(s$7.block, STATIC_CUSTOMISATION_CLASSES.rightSide)
2528
2600
  }, children));
2529
2601
  };
2530
2602
 
@@ -2533,11 +2605,14 @@ var s$8 = {"noEligibility":"_17qNJ","loader":"_2oTJq"};
2533
2605
  var s$9 = {"container":"_2G7Ch"};
2534
2606
 
2535
2607
  var MobileModal = function MobileModal(_ref) {
2536
- var children = _ref.children;
2608
+ var children = _ref.children,
2609
+ isSomePlanDeferred = _ref.isSomePlanDeferred;
2537
2610
  return /*#__PURE__*/React.createElement("div", {
2538
2611
  className: s$9.container,
2539
2612
  "data-testid": "modal-container"
2540
- }, /*#__PURE__*/React.createElement(Title, null), children, /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null));
2613
+ }, /*#__PURE__*/React.createElement(Title, {
2614
+ isSomePlanDeferred: isSomePlanDeferred
2615
+ }), children, /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null));
2541
2616
  };
2542
2617
 
2543
2618
  var EligibilityModal = function EligibilityModal(_ref) {
@@ -2558,25 +2633,23 @@ var EligibilityModal = function EligibilityModal(_ref) {
2558
2633
  return plan.eligible;
2559
2634
  });
2560
2635
  var currentPlan = eligiblePlans[currentPlanIndex];
2561
- var modalProps = {
2562
- eligibilityPlans: eligiblePlans,
2563
- currentPlanIndex: currentPlanIndex,
2564
- setCurrentPlanIndex: setCurrentPlanIndex,
2565
- currentPlan: currentPlan,
2566
- status: status
2567
- };
2636
+ var isSomePlanDeferred = eligibilityPlans.some(function (plan) {
2637
+ return plan.deferred_days > 0 || plan.deferred_months > 0;
2638
+ });
2568
2639
  return /*#__PURE__*/React.createElement(ControlledModal, {
2569
2640
  onClose: onClose,
2570
2641
  ariaHideApp: false,
2571
2642
  scrollable: true,
2572
2643
  isOpen: true
2573
- }, /*#__PURE__*/React.createElement(ModalComponent, Object.assign({}, modalProps), status === apiStatus.PENDING && /*#__PURE__*/React.createElement("div", {
2644
+ }, /*#__PURE__*/React.createElement(ModalComponent, {
2645
+ isSomePlanDeferred: isSomePlanDeferred
2646
+ }, status === apiStatus.PENDING && /*#__PURE__*/React.createElement("div", {
2574
2647
  className: s$8.loader
2575
2648
  }, /*#__PURE__*/React.createElement(LoadingIndicator, null)), status === apiStatus.SUCCESS && eligiblePlans.length === 0 && /*#__PURE__*/React.createElement("div", {
2576
2649
  className: s$8.noEligibility
2577
2650
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
2578
2651
  id: "eligibility-modal.no-eligibility",
2579
- defaultMessage: "Oups, il semblerait que la simulation n'aie pas fonctionn\xE9."
2652
+ defaultMessage: "Oups, il semblerait que la simulation n'ait pas fonctionn\xE9."
2580
2653
  })), status === apiStatus.SUCCESS && eligiblePlans.length >= 1 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EligibilityPlansButtons, {
2581
2654
  eligibilityPlans: eligiblePlans,
2582
2655
  currentPlanIndex: currentPlanIndex,
@@ -2693,6 +2766,24 @@ var getIndexOfActivePlan = function getIndexOfActivePlan(_ref) {
2693
2766
  return 0;
2694
2767
  };
2695
2768
 
2769
+ /**
2770
+ * Prefix classes to avoid name collisions.
2771
+ */
2772
+ var prefix$1 = 'alma-payment-plans';
2773
+ /**
2774
+ * Class names for the **payment plans** widget.
2775
+ * Those classes are intended to be used by the **merchant developer**.
2776
+ */
2777
+
2778
+ var STATIC_CUSTOMISATION_CLASSES$1 = {
2779
+ container: prefix$1 + '-container',
2780
+ eligibilityLine: prefix$1 + '-eligibility-line',
2781
+ eligibilityOptions: prefix$1 + '-eligibility-options',
2782
+ notEligibleOption: prefix$1 + '-not-eligible-option',
2783
+ paymentInfo: prefix$1 + '-payment-info',
2784
+ activeOption: prefix$1 + '-active-option'
2785
+ };
2786
+
2696
2787
  var s$b = {"widgetButton":"_TSkFv","logo":"_LJ4nZ","primaryContainer":"_bMClc","paymentPlans":"_17c_S","plan":"_2Kqjn","active":"_3dG_J","notEligible":"_3O1bg","info":"_25GrF","loader":"_30j1O","error":"_R0YlN","errorText":"_2kGhu","errorButton":"_73d_Y","pending":"_1ZDMS","clickable":"_UksZa","unClickable":"_1lr-q"};
2697
2788
 
2698
2789
  var VERY_LONG_TIME_IN_MS = 1000 * 3600 * 24 * 365;
@@ -2719,7 +2810,7 @@ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
2719
2810
  eligibilityPlans: eligibilityPlans,
2720
2811
  suggestedPaymentPlan: suggestedPaymentPlan != null ? suggestedPaymentPlan : 0
2721
2812
  });
2722
- var isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab and remove animated transition.
2813
+ var isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab
2723
2814
 
2724
2815
  var isTransitionSpecified = transitionDelay !== undefined; // 👈 The merchant has specified a transition time
2725
2816
 
@@ -2804,14 +2895,14 @@ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
2804
2895
 
2805
2896
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
2806
2897
  onClick: handleOpenModal,
2807
- className: cx(s$b.widgetButton, (_cx = {}, _cx[s$b.clickable] = eligiblePlans.length > 0, _cx[s$b.unClickable] = eligiblePlans.length === 0, _cx)),
2898
+ className: cx(s$b.widgetButton, (_cx = {}, _cx[s$b.clickable] = eligiblePlans.length > 0, _cx[s$b.unClickable] = eligiblePlans.length === 0, _cx), STATIC_CUSTOMISATION_CLASSES$1.container),
2808
2899
  "data-testid": "widget-button"
2809
2900
  }, /*#__PURE__*/React.createElement("div", {
2810
- className: s$b.primaryContainer
2901
+ className: cx(s$b.primaryContainer, STATIC_CUSTOMISATION_CLASSES$1.eligibilityLine)
2811
2902
  }, /*#__PURE__*/React.createElement(LogoIcon, {
2812
2903
  className: s$b.logo
2813
2904
  }), /*#__PURE__*/React.createElement("div", {
2814
- className: s$b.paymentPlans
2905
+ className: cx(s$b.paymentPlans, STATIC_CUSTOMISATION_CLASSES$1.eligibilityOptions)
2815
2906
  }, eligibilityPlans.map(function (eligibilityPlan, key) {
2816
2907
  var _cx2;
2817
2908
 
@@ -2821,10 +2912,10 @@ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
2821
2912
  return onHover(key);
2822
2913
  },
2823
2914
  onMouseOut: onLeave,
2824
- className: cx(s$b.plan, (_cx2 = {}, _cx2[s$b.active] = current === key, _cx2[s$b.notEligible] = !eligibilityPlan.eligible, _cx2))
2915
+ className: cx(s$b.plan, (_cx2 = {}, _cx2[cx(s$b.active, STATIC_CUSTOMISATION_CLASSES$1.activeOption)] = current === key, _cx2[cx(s$b.notEligible, STATIC_CUSTOMISATION_CLASSES$1.notEligibleOption)] = !eligibilityPlan.eligible, _cx2))
2825
2916
  }, paymentPlanShorthandName(eligibilityPlan));
2826
2917
  }))), /*#__PURE__*/React.createElement("div", {
2827
- className: cx(s$b.info, (_cx3 = {}, _cx3[s$b.notEligible] = eligibilityPlans[current] && !eligibilityPlans[current].eligible, _cx3))
2918
+ className: cx(s$b.info, (_cx3 = {}, _cx3[cx(s$b.notEligible, STATIC_CUSTOMISATION_CLASSES$1.notEligibleOption)] = eligibilityPlans[current] && !eligibilityPlans[current].eligible, _cx3), STATIC_CUSTOMISATION_CLASSES$1.paymentInfo)
2828
2919
  }, eligibilityPlans.length !== 0 && paymentPlanInfoText(eligibilityPlans[current]))), isOpen && /*#__PURE__*/React.createElement(EligibilityModal, {
2829
2920
  initialPlanIndex: getIndexWithinEligiblePlans(current),
2830
2921
  onClose: closeModal,