@alma/widgets 2.3.4 → 2.4.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/raw/widgets.js +123 -51
- package/dist/raw/widgets.js.map +1 -1
- package/dist/raw/widgets.m.js +123 -51
- package/dist/raw/widgets.m.js.map +1 -1
- package/dist/raw/widgets.modern.js +123 -47
- package/dist/raw/widgets.modern.js.map +1 -1
- package/dist/raw/widgets.umd.js +123 -51
- package/dist/raw/widgets.umd.js.map +1 -1
- package/dist/types/Widgets/EligibilityModal/classNames.const.d.ts +18 -0
- package/dist/types/Widgets/PaymentPlans/classNames.const.d.ts +13 -0
- package/dist/types/test/fixtures.d.ts +40 -0
- package/dist/types/types.d.ts +7 -1
- package/dist/widgets.js +1 -1
- package/dist/widgets.js.map +1 -1
- package/dist/widgets.m.js +1 -1
- package/dist/widgets.m.js.map +1 -1
- package/dist/widgets.modern.js +1 -1
- package/dist/widgets.modern.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/raw/widgets.js
CHANGED
|
@@ -2052,16 +2052,34 @@ var fetchFromApi = function fetchFromApi(url, data, headers) {
|
|
|
2052
2052
|
}
|
|
2053
2053
|
};
|
|
2054
2054
|
|
|
2055
|
+
var isPlanEligible = function isPlanEligible(plan, configPlan) {
|
|
2056
|
+
if (!plan.eligible) {
|
|
2057
|
+
return false;
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
return configPlan ? plan.purchase_amount >= (configPlan == null ? void 0 : configPlan.minAmount) && plan.purchase_amount <= (configPlan == null ? void 0 : configPlan.maxAmount) : false;
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2063
|
+
var getPaymentPlanBoundaries = function getPaymentPlanBoundaries(plan, configPlan) {
|
|
2064
|
+
var _plan$constraints;
|
|
2065
|
+
|
|
2066
|
+
// When the plan is not eligible, the purchase amount constraints is given from the merchant config
|
|
2067
|
+
var purchaseAmountConstraints = (_plan$constraints = plan.constraints) == null ? void 0 : _plan$constraints.purchase_amount;
|
|
2068
|
+
|
|
2069
|
+
if (purchaseAmountConstraints && configPlan) {
|
|
2070
|
+
return {
|
|
2071
|
+
minAmount: Math.max(configPlan.minAmount, purchaseAmountConstraints == null ? void 0 : purchaseAmountConstraints.minimum),
|
|
2072
|
+
maxAmount: Math.min(configPlan.maxAmount, purchaseAmountConstraints == null ? void 0 : purchaseAmountConstraints.maximum)
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
return configPlan != null ? configPlan : {};
|
|
2077
|
+
};
|
|
2078
|
+
|
|
2055
2079
|
var filterELigibility = function filterELigibility(eligibilities, configPlans) {
|
|
2056
2080
|
// Remove p1x
|
|
2057
2081
|
var filteredEligibilityPlans = eligibilities.filter(function (plan) {
|
|
2058
2082
|
return !(plan.installments_count === 1 && plan.deferred_days === 0 && plan.deferred_months === 0);
|
|
2059
|
-
}) // Keeps the plans that have a payment_plan property
|
|
2060
|
-
.filter(function (plan) {
|
|
2061
|
-
return plan.payment_plan;
|
|
2062
|
-
}) // Remove plans that have a reasons property
|
|
2063
|
-
.filter(function (plan) {
|
|
2064
|
-
return !plan.reasons;
|
|
2065
2083
|
}); // If no configPlans was provided, return eligibility response
|
|
2066
2084
|
|
|
2067
2085
|
if (!configPlans) {
|
|
@@ -2077,10 +2095,8 @@ var filterELigibility = function filterELigibility(eligibilities, configPlans) {
|
|
|
2077
2095
|
return plan.installments_count === configPlan.installmentsCount && eligibilityDeferredDays === configPlanDeferredDays;
|
|
2078
2096
|
});
|
|
2079
2097
|
return _extends({}, plan, {
|
|
2080
|
-
eligible:
|
|
2081
|
-
|
|
2082
|
-
maxAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount
|
|
2083
|
-
});
|
|
2098
|
+
eligible: isPlanEligible(plan, relatedConfigPlan)
|
|
2099
|
+
}, getPaymentPlanBoundaries(plan, relatedConfigPlan));
|
|
2084
2100
|
});
|
|
2085
2101
|
};
|
|
2086
2102
|
|
|
@@ -2154,6 +2170,29 @@ function CrossIcon(_ref) {
|
|
|
2154
2170
|
}));
|
|
2155
2171
|
}
|
|
2156
2172
|
|
|
2173
|
+
/**
|
|
2174
|
+
* Prefix classes to avoid name collisions.
|
|
2175
|
+
*/
|
|
2176
|
+
var prefix = 'alma-eligibility-modal';
|
|
2177
|
+
/**
|
|
2178
|
+
* Class names for the **eligibility modale** widget.
|
|
2179
|
+
* Those classes are intended to be used by the **merchant developer**.
|
|
2180
|
+
*/
|
|
2181
|
+
|
|
2182
|
+
var STATIC_CUSTOMISATION_CLASSES = {
|
|
2183
|
+
leftSide: prefix + '-left-side',
|
|
2184
|
+
rightSide: prefix + '-right-side',
|
|
2185
|
+
title: prefix + '-title',
|
|
2186
|
+
info: prefix + '-info',
|
|
2187
|
+
infoMessage: prefix + '-info-message',
|
|
2188
|
+
eligibilityOptions: prefix + '-eligibility-options',
|
|
2189
|
+
activeOption: prefix + '-active-option',
|
|
2190
|
+
closeButton: prefix + '-close-button',
|
|
2191
|
+
scheduleDetails: prefix + '-schedule-details',
|
|
2192
|
+
scheduleTotal: prefix + '-schedule-total',
|
|
2193
|
+
scheduleCredit: prefix + '-schedule-credit'
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2157
2196
|
var _excluded = ["children", "isOpen", "onClose", "className", "contentClassName", "scrollable"];
|
|
2158
2197
|
|
|
2159
2198
|
var ControlledModal = function ControlledModal(_ref) {
|
|
@@ -2186,7 +2225,7 @@ var ControlledModal = function ControlledModal(_ref) {
|
|
|
2186
2225
|
className: s$1.header
|
|
2187
2226
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
2188
2227
|
onClick: onClose,
|
|
2189
|
-
className: s$1.closeButton,
|
|
2228
|
+
className: cx(s$1.closeButton, STATIC_CUSTOMISATION_CLASSES.closeButton),
|
|
2190
2229
|
"data-testid": "modal-close-button"
|
|
2191
2230
|
}, /*#__PURE__*/React__default.createElement(CrossIcon, null))), /*#__PURE__*/React__default.createElement("div", {
|
|
2192
2231
|
className: cx(s$1.content, contentClassName, (_cx = {}, _cx[s$1.contentScrollable] = scrollable, _cx))
|
|
@@ -2211,6 +2250,20 @@ var paymentPlanShorthandName = function paymentPlanShorthandName(payment) {
|
|
|
2211
2250
|
return installmentsCount + "x";
|
|
2212
2251
|
}
|
|
2213
2252
|
};
|
|
2253
|
+
|
|
2254
|
+
var withNoFee = function withNoFee(payment) {
|
|
2255
|
+
var _payment$payment_plan;
|
|
2256
|
+
|
|
2257
|
+
if ((_payment$payment_plan = payment.payment_plan) != null && _payment$payment_plan.every(function (plan) {
|
|
2258
|
+
return plan.customer_fee === 0 && plan.customer_interest === 0;
|
|
2259
|
+
})) {
|
|
2260
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, ' ', /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2261
|
+
id: "payment-plan-strings.no-fee",
|
|
2262
|
+
defaultMessage: '(sans frais)'
|
|
2263
|
+
}));
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2214
2267
|
var paymentPlanInfoText = function paymentPlanInfoText(payment) {
|
|
2215
2268
|
var deferred_days = payment.deferred_days,
|
|
2216
2269
|
deferred_months = payment.deferred_months,
|
|
@@ -2220,20 +2273,10 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
|
|
|
2220
2273
|
_payment$minAmount = payment.minAmount,
|
|
2221
2274
|
minAmount = _payment$minAmount === void 0 ? 0 : _payment$minAmount,
|
|
2222
2275
|
_payment$maxAmount = payment.maxAmount,
|
|
2223
|
-
maxAmount = _payment$maxAmount === void 0 ? 0 : _payment$maxAmount
|
|
2276
|
+
maxAmount = _payment$maxAmount === void 0 ? 0 : _payment$maxAmount,
|
|
2277
|
+
payment_plan = payment.payment_plan;
|
|
2224
2278
|
var deferredDaysCount = deferred_days + deferred_months * 30;
|
|
2225
2279
|
|
|
2226
|
-
var withNoFee = function withNoFee() {
|
|
2227
|
-
if (payment.payment_plan.every(function (plan) {
|
|
2228
|
-
return plan.customer_fee === 0 && plan.customer_interest === 0;
|
|
2229
|
-
})) {
|
|
2230
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, ' ', /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2231
|
-
id: "payment-plan-strings.no-fee",
|
|
2232
|
-
defaultMessage: '(sans frais)'
|
|
2233
|
-
}));
|
|
2234
|
-
}
|
|
2235
|
-
};
|
|
2236
|
-
|
|
2237
2280
|
if (!eligible) {
|
|
2238
2281
|
return purchaseAmount > maxAmount ? /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2239
2282
|
id: "payment-plan-strings.ineligible-greater-than-max",
|
|
@@ -2256,27 +2299,32 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
|
|
|
2256
2299
|
})
|
|
2257
2300
|
}
|
|
2258
2301
|
});
|
|
2302
|
+
} else if (!payment_plan) {
|
|
2303
|
+
/* This error should never happen. We added this condition to avoid a typescript warning on
|
|
2304
|
+
payment_plan possibly undefined. As far as we know, it only happens when the plan is not
|
|
2305
|
+
eligible, which is checked above. */
|
|
2306
|
+
throw Error("No payment plan provided for payment in " + installmentsCount + " installments. Please contact us if you see this error.");
|
|
2259
2307
|
} else if (deferredDaysCount !== 0 && installmentsCount === 1) {
|
|
2260
2308
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2261
2309
|
id: "payment-plan-strings.deferred",
|
|
2262
2310
|
defaultMessage: "{totalAmount} \xE0 payer le {dueDate}",
|
|
2263
2311
|
values: {
|
|
2264
2312
|
totalAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
|
|
2265
|
-
value: priceFromCents(
|
|
2313
|
+
value: priceFromCents(payment_plan[0].total_amount),
|
|
2266
2314
|
style: "currency",
|
|
2267
2315
|
currency: "EUR"
|
|
2268
2316
|
}),
|
|
2269
2317
|
dueDate: /*#__PURE__*/React__default.createElement(reactIntl.FormattedDate, {
|
|
2270
|
-
value: dateFns.secondsToMilliseconds(
|
|
2318
|
+
value: dateFns.secondsToMilliseconds(payment_plan[0].due_date),
|
|
2271
2319
|
day: "numeric",
|
|
2272
2320
|
month: "long",
|
|
2273
2321
|
year: "numeric"
|
|
2274
2322
|
})
|
|
2275
2323
|
}
|
|
2276
|
-
}), withNoFee());
|
|
2324
|
+
}), withNoFee(payment));
|
|
2277
2325
|
} else if (installmentsCount > 0) {
|
|
2278
|
-
var areInstallmentsOfSameAmount =
|
|
2279
|
-
return index === 0 || installment.total_amount ===
|
|
2326
|
+
var areInstallmentsOfSameAmount = payment_plan == null ? void 0 : payment_plan.every(function (installment, index) {
|
|
2327
|
+
return index === 0 || installment.total_amount === payment_plan[0].total_amount;
|
|
2280
2328
|
});
|
|
2281
2329
|
|
|
2282
2330
|
if (areInstallmentsOfSameAmount) {
|
|
@@ -2285,13 +2333,13 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
|
|
|
2285
2333
|
defaultMessage: "{installmentsCount} x {totalAmount}",
|
|
2286
2334
|
values: {
|
|
2287
2335
|
totalAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
|
|
2288
|
-
value: priceFromCents(
|
|
2336
|
+
value: priceFromCents(payment_plan[0].total_amount),
|
|
2289
2337
|
style: "currency",
|
|
2290
2338
|
currency: "EUR"
|
|
2291
2339
|
}),
|
|
2292
2340
|
installmentsCount: installmentsCount
|
|
2293
2341
|
}
|
|
2294
|
-
}), withNoFee());
|
|
2342
|
+
}), withNoFee(payment));
|
|
2295
2343
|
}
|
|
2296
2344
|
|
|
2297
2345
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
@@ -2299,18 +2347,18 @@ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
|
|
|
2299
2347
|
defaultMessage: "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
|
|
2300
2348
|
values: {
|
|
2301
2349
|
firstInstallmentAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
|
|
2302
|
-
value: priceFromCents(
|
|
2350
|
+
value: priceFromCents(payment_plan[0].total_amount),
|
|
2303
2351
|
style: "currency",
|
|
2304
2352
|
currency: "EUR"
|
|
2305
2353
|
}),
|
|
2306
2354
|
numberOfRemainingInstallments: installmentsCount - 1,
|
|
2307
2355
|
othersInstallmentAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
|
|
2308
|
-
value: priceFromCents(
|
|
2356
|
+
value: priceFromCents(payment_plan[1].total_amount),
|
|
2309
2357
|
style: "currency",
|
|
2310
2358
|
currency: "EUR"
|
|
2311
2359
|
})
|
|
2312
2360
|
}
|
|
2313
|
-
}), withNoFee());
|
|
2361
|
+
}), withNoFee(payment));
|
|
2314
2362
|
}
|
|
2315
2363
|
|
|
2316
2364
|
return /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
@@ -2326,13 +2374,13 @@ var EligibilityPlansButtons = function EligibilityPlansButtons(_ref) {
|
|
|
2326
2374
|
currentPlanIndex = _ref.currentPlanIndex,
|
|
2327
2375
|
setCurrentPlanIndex = _ref.setCurrentPlanIndex;
|
|
2328
2376
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2329
|
-
className: s$2.buttons
|
|
2377
|
+
className: cx(s$2.buttons, STATIC_CUSTOMISATION_CLASSES.eligibilityOptions)
|
|
2330
2378
|
}, eligibilityPlans.map(function (eligibilityPlan, index) {
|
|
2331
2379
|
var _cx;
|
|
2332
2380
|
|
|
2333
2381
|
return /*#__PURE__*/React__default.createElement("button", {
|
|
2334
2382
|
key: index,
|
|
2335
|
-
className: cx((_cx = {}, _cx[s$2.active] = index === currentPlanIndex, _cx)),
|
|
2383
|
+
className: cx((_cx = {}, _cx[cx(s$2.active, STATIC_CUSTOMISATION_CLASSES.activeOption)] = index === currentPlanIndex, _cx)),
|
|
2336
2384
|
onClick: function onClick() {
|
|
2337
2385
|
return setCurrentPlanIndex(index);
|
|
2338
2386
|
}
|
|
@@ -2351,10 +2399,10 @@ var Schedule = function Schedule(_ref) {
|
|
|
2351
2399
|
var isCredit = currentPlan && currentPlan.installments_count > 4;
|
|
2352
2400
|
var intl = reactIntl.useIntl();
|
|
2353
2401
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2354
|
-
className: s$3.schedule,
|
|
2402
|
+
className: cx(s$3.schedule, STATIC_CUSTOMISATION_CLASSES.scheduleDetails),
|
|
2355
2403
|
"data-testid": "modal-installments-element"
|
|
2356
2404
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2357
|
-
className: cx(s$3.scheduleLine, s$3.total)
|
|
2405
|
+
className: cx(s$3.scheduleLine, s$3.total, STATIC_CUSTOMISATION_CLASSES.scheduleTotal)
|
|
2358
2406
|
}, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2359
2407
|
id: "eligibility-modal.total",
|
|
2360
2408
|
defaultMessage: "Total"
|
|
@@ -2363,7 +2411,7 @@ var Schedule = function Schedule(_ref) {
|
|
|
2363
2411
|
style: "currency",
|
|
2364
2412
|
currency: "EUR"
|
|
2365
2413
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
2366
|
-
className: cx(s$3.scheduleLine, s$3.creditCost)
|
|
2414
|
+
className: cx(s$3.scheduleLine, s$3.creditCost, STATIC_CUSTOMISATION_CLASSES.scheduleCredit)
|
|
2367
2415
|
}, isCredit ? /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2368
2416
|
id: "eligibility-modal.credit-cost",
|
|
2369
2417
|
defaultMessage: "Dont co\xFBt du cr\xE9dit"
|
|
@@ -2416,13 +2464,15 @@ var s$4 = {"list":"_180ro","listItem":"_1HqCO","bullet":"_3B8wx"};
|
|
|
2416
2464
|
|
|
2417
2465
|
var Info = function Info() {
|
|
2418
2466
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2419
|
-
className: s$4.list,
|
|
2467
|
+
className: cx(s$4.list, STATIC_CUSTOMISATION_CLASSES.info),
|
|
2420
2468
|
"data-testid": "modal-info-element"
|
|
2421
2469
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2422
2470
|
className: s$4.listItem
|
|
2423
2471
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2424
2472
|
className: s$4.bullet
|
|
2425
|
-
}, "1"), /*#__PURE__*/React__default.createElement("div",
|
|
2473
|
+
}, "1"), /*#__PURE__*/React__default.createElement("div", {
|
|
2474
|
+
className: STATIC_CUSTOMISATION_CLASSES.infoMessage
|
|
2475
|
+
}, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2426
2476
|
id: "eligibility-modal.bullet-1",
|
|
2427
2477
|
defaultMessage: "Choisissez <strong>Alma</strong> au moment du paiement.",
|
|
2428
2478
|
values: {
|
|
@@ -2434,7 +2484,9 @@ var Info = function Info() {
|
|
|
2434
2484
|
className: s$4.listItem
|
|
2435
2485
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2436
2486
|
className: s$4.bullet
|
|
2437
|
-
}, "2"), /*#__PURE__*/React__default.createElement("div",
|
|
2487
|
+
}, "2"), /*#__PURE__*/React__default.createElement("div", {
|
|
2488
|
+
className: STATIC_CUSTOMISATION_CLASSES.infoMessage
|
|
2489
|
+
}, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2438
2490
|
id: "eligibility-modal.bullet-2",
|
|
2439
2491
|
defaultMessage: "Renseignez les <strong>informations</strong> demand\xE9es.",
|
|
2440
2492
|
values: {
|
|
@@ -2446,7 +2498,9 @@ var Info = function Info() {
|
|
|
2446
2498
|
className: s$4.listItem
|
|
2447
2499
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2448
2500
|
className: s$4.bullet
|
|
2449
|
-
}, "3"), /*#__PURE__*/React__default.createElement("div",
|
|
2501
|
+
}, "3"), /*#__PURE__*/React__default.createElement("div", {
|
|
2502
|
+
className: STATIC_CUSTOMISATION_CLASSES.infoMessage
|
|
2503
|
+
}, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2450
2504
|
id: "eligibility-modal.bullet-3",
|
|
2451
2505
|
defaultMessage: "La validation de votre paiement <strong>instantan\xE9e</strong> !",
|
|
2452
2506
|
values: {
|
|
@@ -2504,7 +2558,7 @@ var s$6 = {"title":"_3ERx-"};
|
|
|
2504
2558
|
|
|
2505
2559
|
var Title = function Title() {
|
|
2506
2560
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2507
|
-
className: s$6.title,
|
|
2561
|
+
className: cx(s$6.title, STATIC_CUSTOMISATION_CLASSES.title),
|
|
2508
2562
|
"data-testid": "modal-title-element"
|
|
2509
2563
|
}, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
|
|
2510
2564
|
id: "eligibility-modal.title",
|
|
@@ -2525,9 +2579,9 @@ var DesktopModal = function DesktopModal(_ref) {
|
|
|
2525
2579
|
className: s$7.container,
|
|
2526
2580
|
"data-testid": "modal-container"
|
|
2527
2581
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2528
|
-
className: cx([s$7.block, s$7.left])
|
|
2582
|
+
className: cx([s$7.block, s$7.left, STATIC_CUSTOMISATION_CLASSES.leftSide])
|
|
2529
2583
|
}, /*#__PURE__*/React__default.createElement(Title, null), /*#__PURE__*/React__default.createElement(Info, null), /*#__PURE__*/React__default.createElement(Logo, null)), /*#__PURE__*/React__default.createElement("div", {
|
|
2530
|
-
className: s$7.block
|
|
2584
|
+
className: cx(s$7.block, STATIC_CUSTOMISATION_CLASSES.rightSide)
|
|
2531
2585
|
}, children));
|
|
2532
2586
|
};
|
|
2533
2587
|
|
|
@@ -2696,6 +2750,24 @@ var getIndexOfActivePlan = function getIndexOfActivePlan(_ref) {
|
|
|
2696
2750
|
return 0;
|
|
2697
2751
|
};
|
|
2698
2752
|
|
|
2753
|
+
/**
|
|
2754
|
+
* Prefix classes to avoid name collisions.
|
|
2755
|
+
*/
|
|
2756
|
+
var prefix$1 = 'alma-payment-plans';
|
|
2757
|
+
/**
|
|
2758
|
+
* Class names for the **payment plans** widget.
|
|
2759
|
+
* Those classes are intended to be used by the **merchant developer**.
|
|
2760
|
+
*/
|
|
2761
|
+
|
|
2762
|
+
var STATIC_CUSTOMISATION_CLASSES$1 = {
|
|
2763
|
+
container: prefix$1 + '-container',
|
|
2764
|
+
eligibilityLine: prefix$1 + '-eligibility-line',
|
|
2765
|
+
eligibilityOptions: prefix$1 + '-eligibility-options',
|
|
2766
|
+
notEligibleOption: prefix$1 + '-not-eligible-option',
|
|
2767
|
+
paymentInfo: prefix$1 + '-payment-info',
|
|
2768
|
+
activeOption: prefix$1 + '-active-option'
|
|
2769
|
+
};
|
|
2770
|
+
|
|
2699
2771
|
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"};
|
|
2700
2772
|
|
|
2701
2773
|
var VERY_LONG_TIME_IN_MS = 1000 * 3600 * 24 * 365;
|
|
@@ -2722,7 +2794,7 @@ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
|
|
|
2722
2794
|
eligibilityPlans: eligibilityPlans,
|
|
2723
2795
|
suggestedPaymentPlan: suggestedPaymentPlan != null ? suggestedPaymentPlan : 0
|
|
2724
2796
|
});
|
|
2725
|
-
var isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab
|
|
2797
|
+
var isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab
|
|
2726
2798
|
|
|
2727
2799
|
var isTransitionSpecified = transitionDelay !== undefined; // 👈 The merchant has specified a transition time
|
|
2728
2800
|
|
|
@@ -2807,14 +2879,14 @@ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
|
|
|
2807
2879
|
|
|
2808
2880
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
2809
2881
|
onClick: handleOpenModal,
|
|
2810
|
-
className: cx(s$b.widgetButton, (_cx = {}, _cx[s$b.clickable] = eligiblePlans.length > 0, _cx[s$b.unClickable] = eligiblePlans.length === 0, _cx)),
|
|
2882
|
+
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),
|
|
2811
2883
|
"data-testid": "widget-button"
|
|
2812
2884
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2813
|
-
className: s$b.primaryContainer
|
|
2885
|
+
className: cx(s$b.primaryContainer, STATIC_CUSTOMISATION_CLASSES$1.eligibilityLine)
|
|
2814
2886
|
}, /*#__PURE__*/React__default.createElement(LogoIcon, {
|
|
2815
2887
|
className: s$b.logo
|
|
2816
2888
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
2817
|
-
className: s$b.paymentPlans
|
|
2889
|
+
className: cx(s$b.paymentPlans, STATIC_CUSTOMISATION_CLASSES$1.eligibilityOptions)
|
|
2818
2890
|
}, eligibilityPlans.map(function (eligibilityPlan, key) {
|
|
2819
2891
|
var _cx2;
|
|
2820
2892
|
|
|
@@ -2824,10 +2896,10 @@ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
|
|
|
2824
2896
|
return onHover(key);
|
|
2825
2897
|
},
|
|
2826
2898
|
onMouseOut: onLeave,
|
|
2827
|
-
className: cx(s$b.plan, (_cx2 = {}, _cx2[s$b.active] = current === key, _cx2[s$b.notEligible] = !eligibilityPlan.eligible, _cx2))
|
|
2899
|
+
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))
|
|
2828
2900
|
}, paymentPlanShorthandName(eligibilityPlan));
|
|
2829
2901
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
2830
|
-
className: cx(s$b.info, (_cx3 = {}, _cx3[s$b.notEligible] = eligibilityPlans[current] && !eligibilityPlans[current].eligible, _cx3))
|
|
2902
|
+
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)
|
|
2831
2903
|
}, eligibilityPlans.length !== 0 && paymentPlanInfoText(eligibilityPlans[current]))), isOpen && /*#__PURE__*/React__default.createElement(EligibilityModal, {
|
|
2832
2904
|
initialPlanIndex: getIndexWithinEligiblePlans(current),
|
|
2833
2905
|
onClose: closeModal,
|