@stigg/react-sdk 5.12.0 → 5.13.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/components/utils/numberUtils.d.ts +2 -2
- package/dist/react-sdk.cjs.development.js +26 -28
- package/dist/react-sdk.cjs.development.js.map +1 -1
- package/dist/react-sdk.cjs.production.min.js +1 -1
- package/dist/react-sdk.cjs.production.min.js.map +1 -1
- package/dist/react-sdk.esm.js +26 -28
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/paywall/PlanEntitlements.tsx +32 -33
- package/src/components/utils/getPaidPriceText.ts +7 -3
- package/src/components/utils/numberUtils.ts +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function numberFormatter(number: number, {
|
|
2
|
-
|
|
1
|
+
export declare function numberFormatter(number: number, { locale }?: {
|
|
2
|
+
locale?: string;
|
|
3
3
|
}): string;
|
|
@@ -474,19 +474,19 @@ var PlanEntitlementsContainer = /*#__PURE__*/_styled("div", {
|
|
|
474
474
|
})( {
|
|
475
475
|
name: "budh8k",
|
|
476
476
|
styles: "display:flex;flex-direction:column;gap:16px",
|
|
477
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
477
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlBsYW5FbnRpdGxlbWVudHMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUs2QyIsImZpbGUiOiJQbGFuRW50aXRsZW1lbnRzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCBmcm9tICdyZWFjdCc7XHJcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkL21hY3JvJztcclxuaW1wb3J0IHsgV2lkZ2V0VHlwZSB9IGZyb20gJ0BzdGlnZy9qcy1jbGllbnQtc2RrJztcclxua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iBcInN0aWdnLXBsYW4tZW50aXRsZW1lbnRzLXRpdGxlXCIsIGNvbG9yOiBcInNlY29uZGFyeVwiLCB2YXJpYW50OiBcImg2XCIsIGJvbGQ6IHRydWUgfSwgZ2V0VGl0bGUocGxhbiwgcGF5d2FsbExvY2FsZSwgaGFzRmVhdHVyZXMpKSxcclxuICAgICAgICB1bml0QmFzZWRFbnRpdGxlbWVudHMsXHJcbiAgICAgICAgdmlzaWJsZUVudGl0bGVtZW50cy5tYXAoKGVudGl0bGVtZW50KSA9PiAoUmVhY3QuY3JlYXRlRWxlbWVudChFbnRpdGxlbWVudFJvdywgeyBrZXk6IGVudGl0bGVtZW50LmZlYXR1cmU/LmlkLCBkaXNwbGF5TmFtZU92ZXJyaWRlOiBlbnRpdGxlbWVudC5kaXNwbGF5TmFtZU92ZXJyaWRlLCBmZWF0dXJlOiBlbnRpdGxlbWVudC5mZWF0dXJlLCByZXNldFBlcmlvZDogZW50aXRsZW1lbnQucmVzZXRQZXJpb2QsIGhhc1VubGltaXRlZFVzYWdlOiBlbnRpdGxlbWVudC5oYXNVbmxpbWl0ZWRVc2FnZSwgdXNhZ2VMaW1pdDogZW50aXRsZW1lbnQudXNhZ2VMaW1pdCwgaXNDdXN0b206IGVudGl0bGVtZW50LmlzQ3VzdG9tIH0pKSkpKTtcclxufVxyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1QbGFuRW50aXRsZW1lbnRzLmpzLm1hcCJdfQ== */",
|
|
478
478
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
479
479
|
});
|
|
480
480
|
|
|
481
|
-
function getTitle(plan, paywallLocale) {
|
|
481
|
+
function getTitle(plan, paywallLocale, hasFeatures) {
|
|
482
482
|
if (paywallLocale.entitlementsTitle) {
|
|
483
483
|
return paywallLocale.entitlementsTitle(plan);
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
var title = plan.displayName + " includes";
|
|
486
|
+
var title = hasFeatures ? plan.displayName + " includes" : '';
|
|
487
487
|
|
|
488
488
|
if (plan.basePlan) {
|
|
489
|
-
title = "Everything in " + plan.basePlan.displayName +
|
|
489
|
+
title = "Everything in " + plan.basePlan.displayName + (hasFeatures ? ', plus:' : '');
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
return title;
|
|
@@ -498,18 +498,14 @@ function PlanEntitlements(_ref) {
|
|
|
498
498
|
var plan = _ref.plan,
|
|
499
499
|
billingPeriod = _ref.billingPeriod,
|
|
500
500
|
paywallLocale = _ref.paywallLocale;
|
|
501
|
-
var prices = (_plan$pricePoints = plan.pricePoints) == null ? void 0 : _plan$pricePoints.filter(function (price) {
|
|
501
|
+
var prices = ((_plan$pricePoints = plan.pricePoints) == null ? void 0 : _plan$pricePoints.filter(function (price) {
|
|
502
502
|
return price.billingPeriod === billingPeriod;
|
|
503
|
-
});
|
|
504
|
-
var unitBasedEntitlements = prices
|
|
503
|
+
})) || [];
|
|
504
|
+
var unitBasedEntitlements = prices.filter(function (price) {
|
|
505
|
+
return (price == null ? void 0 : price.minUnitQuantity) && (price == null ? void 0 : price.minUnitQuantity) > 1 || (price == null ? void 0 : price.maxUnitQuantity);
|
|
506
|
+
}).map(function (price) {
|
|
505
507
|
var _price$feature;
|
|
506
508
|
|
|
507
|
-
var shouldRenderUnitBasedEntitlement = (price == null ? void 0 : price.minUnitQuantity) && (price == null ? void 0 : price.minUnitQuantity) > 1 || (price == null ? void 0 : price.maxUnitQuantity);
|
|
508
|
-
|
|
509
|
-
if (!shouldRenderUnitBasedEntitlement) {
|
|
510
|
-
return null;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
509
|
return React__default.createElement(EntitlementRow, {
|
|
514
510
|
key: "priceUnitEntitlement-" + (price == null ? void 0 : (_price$feature = price.feature) == null ? void 0 : _price$feature.displayName),
|
|
515
511
|
feature: price == null ? void 0 : price.feature,
|
|
@@ -517,6 +513,10 @@ function PlanEntitlements(_ref) {
|
|
|
517
513
|
maxUnitQuantity: price == null ? void 0 : price.maxUnitQuantity
|
|
518
514
|
});
|
|
519
515
|
});
|
|
516
|
+
var visibleEntitlements = plan.entitlements.filter(function (entitlement) {
|
|
517
|
+
return !(entitlement.hiddenFromWidgets || []).includes(Stigg.WidgetType.Paywall);
|
|
518
|
+
});
|
|
519
|
+
var hasFeatures = unitBasedEntitlements.length > 0 || visibleEntitlements.length > 0;
|
|
520
520
|
return React__default.createElement(PlanEntitlementsContainer, {
|
|
521
521
|
className: "stigg-plan-entitlements-container"
|
|
522
522
|
}, React__default.createElement(Typography, {
|
|
@@ -524,9 +524,7 @@ function PlanEntitlements(_ref) {
|
|
|
524
524
|
color: "secondary",
|
|
525
525
|
variant: "h6",
|
|
526
526
|
bold: true
|
|
527
|
-
}, getTitle(plan, paywallLocale)), unitBasedEntitlements,
|
|
528
|
-
return !(entitlement.hiddenFromWidgets || []).includes(Stigg.WidgetType.Paywall);
|
|
529
|
-
}).map(function (entitlement) {
|
|
527
|
+
}, getTitle(plan, paywallLocale, hasFeatures)), unitBasedEntitlements, visibleEntitlements.map(function (entitlement) {
|
|
530
528
|
var _entitlement$feature;
|
|
531
529
|
|
|
532
530
|
return React__default.createElement(EntitlementRow, {
|
|
@@ -1176,6 +1174,13 @@ var currencyPriceFormatter = function currencyPriceFormatter(_ref) {
|
|
|
1176
1174
|
return formattedPrice;
|
|
1177
1175
|
};
|
|
1178
1176
|
|
|
1177
|
+
function numberFormatter(number, _temp) {
|
|
1178
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
1179
|
+
locale = _ref.locale;
|
|
1180
|
+
|
|
1181
|
+
return new Intl.NumberFormat(locale).format(number);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1179
1184
|
function getPaidPriceText(_ref) {
|
|
1180
1185
|
var planPrices = _ref.planPrices,
|
|
1181
1186
|
paywallCalculatedPrice = _ref.paywallCalculatedPrice,
|
|
@@ -1209,15 +1214,15 @@ function getPaidPriceText(_ref) {
|
|
|
1209
1214
|
}
|
|
1210
1215
|
|
|
1211
1216
|
if (isSinglePrice) {
|
|
1212
|
-
var _price$feature;
|
|
1217
|
+
var _price$feature, _price$feature2, _price$feature3;
|
|
1213
1218
|
|
|
1214
1219
|
var price = planPrices[0];
|
|
1215
|
-
var
|
|
1220
|
+
var formattedUnits = price.blockSize && price.blockSize > 1 ? "for " + numberFormatter(price.blockSize) + " " + (((_price$feature = price.feature) == null ? void 0 : _price$feature.unitsPlural) || ((_price$feature2 = price.feature) == null ? void 0 : _price$feature2.units) || '') : "per " + (((_price$feature3 = price.feature) == null ? void 0 : _price$feature3.units) || '');
|
|
1216
1221
|
|
|
1217
1222
|
if (price.pricingModel === Stigg.BillingModel.PerUnit && !price.isTieredPrice) {
|
|
1218
|
-
unit =
|
|
1223
|
+
unit = formattedUnits + " " + pricePeriod;
|
|
1219
1224
|
} else if (price.pricingModel === Stigg.BillingModel.UsageBased) {
|
|
1220
|
-
unit = "
|
|
1225
|
+
unit = "" + formattedUnits;
|
|
1221
1226
|
}
|
|
1222
1227
|
}
|
|
1223
1228
|
|
|
@@ -3093,7 +3098,7 @@ var LoggerService = /*#__PURE__*/function () {
|
|
|
3093
3098
|
|
|
3094
3099
|
var logger = /*#__PURE__*/new LoggerService();
|
|
3095
3100
|
|
|
3096
|
-
var version = "5.
|
|
3101
|
+
var version = "5.13.0";
|
|
3097
3102
|
var name = "@stigg/react-sdk";
|
|
3098
3103
|
|
|
3099
3104
|
var StiggContext = /*#__PURE__*/React__default.createContext(null);
|
|
@@ -12201,13 +12206,6 @@ function CheckoutCaptions(props) {
|
|
|
12201
12206
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(RemainingCreditsCaption, Object.assign({}, props)), React__default.createElement(ScheduledUpdatesCaption, Object.assign({}, props)), React__default.createElement(NextBillingCaption, Object.assign({}, props)));
|
|
12202
12207
|
}
|
|
12203
12208
|
|
|
12204
|
-
function numberFormatter(number, _temp) {
|
|
12205
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
12206
|
-
locate = _ref.locate;
|
|
12207
|
-
|
|
12208
|
-
return new Intl.NumberFormat(locate).format(number);
|
|
12209
|
-
}
|
|
12210
|
-
|
|
12211
12209
|
function formatPricePerUnit(_ref) {
|
|
12212
12210
|
var quantity = _ref.quantity,
|
|
12213
12211
|
totalAmount = _ref.totalAmount,
|