@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
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.13.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"@emotion/react": "^11.10.5",
|
|
113
113
|
"@emotion/styled": "^11.10.5",
|
|
114
114
|
"@mui/material": "^5.12.0",
|
|
115
|
-
"@stigg/js-client-sdk": "3.
|
|
115
|
+
"@stigg/js-client-sdk": "^3.13.0",
|
|
116
116
|
"@stripe/react-stripe-js": "^2.1.1",
|
|
117
117
|
"@stripe/stripe-js": "^1.54.1",
|
|
118
118
|
"@types/styled-components": "^5.1.26",
|
|
@@ -12,13 +12,13 @@ const PlanEntitlementsContainer = styled.div`
|
|
|
12
12
|
gap: 16px;
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
|
-
function getTitle(plan: PaywallPlan, paywallLocale: PaywallLocalization) {
|
|
15
|
+
function getTitle(plan: PaywallPlan, paywallLocale: PaywallLocalization, hasFeatures: boolean) {
|
|
16
16
|
if (paywallLocale.entitlementsTitle) {
|
|
17
17
|
return paywallLocale.entitlementsTitle(plan);
|
|
18
18
|
}
|
|
19
|
-
let title = `${plan.displayName} includes
|
|
19
|
+
let title = hasFeatures ? `${plan.displayName} includes` : '';
|
|
20
20
|
if (plan.basePlan) {
|
|
21
|
-
title = `Everything in ${plan.basePlan.displayName}, plus
|
|
21
|
+
title = `Everything in ${plan.basePlan.displayName}${hasFeatures ? ', plus:' : ''}`;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return title;
|
|
@@ -33,44 +33,43 @@ export function PlanEntitlements({
|
|
|
33
33
|
billingPeriod: BillingPeriod;
|
|
34
34
|
paywallLocale: PaywallLocalization;
|
|
35
35
|
}) {
|
|
36
|
-
const prices = plan.pricePoints?.filter((price) => price.billingPeriod === billingPeriod);
|
|
37
|
-
const unitBasedEntitlements = prices
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const prices = plan.pricePoints?.filter((price) => price.billingPeriod === billingPeriod) || [];
|
|
37
|
+
const unitBasedEntitlements = prices
|
|
38
|
+
.filter((price) => (price?.minUnitQuantity && price?.minUnitQuantity > 1) || price?.maxUnitQuantity)
|
|
39
|
+
.map((price) => {
|
|
40
|
+
return (
|
|
41
|
+
<EntitlementRow
|
|
42
|
+
key={`priceUnitEntitlement-${price?.feature?.displayName}`}
|
|
43
|
+
feature={price?.feature}
|
|
44
|
+
minUnitQuantity={price?.minUnitQuantity}
|
|
45
|
+
maxUnitQuantity={price?.maxUnitQuantity}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
const visibleEntitlements = plan.entitlements.filter(
|
|
51
|
+
(entitlement) => !(entitlement.hiddenFromWidgets || []).includes(WidgetType.Paywall),
|
|
52
|
+
);
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
<EntitlementRow
|
|
47
|
-
key={`priceUnitEntitlement-${price?.feature?.displayName}`}
|
|
48
|
-
feature={price?.feature}
|
|
49
|
-
minUnitQuantity={price?.minUnitQuantity}
|
|
50
|
-
maxUnitQuantity={price?.maxUnitQuantity}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
+
const hasFeatures = unitBasedEntitlements.length > 0 || visibleEntitlements.length > 0;
|
|
54
55
|
|
|
55
56
|
return (
|
|
56
57
|
<PlanEntitlementsContainer className="stigg-plan-entitlements-container">
|
|
57
58
|
<Typography className="stigg-plan-entitlements-title" color="secondary" variant="h6" bold>
|
|
58
|
-
{getTitle(plan, paywallLocale)}
|
|
59
|
+
{getTitle(plan, paywallLocale, hasFeatures)}
|
|
59
60
|
</Typography>
|
|
60
61
|
{unitBasedEntitlements}
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/>
|
|
73
|
-
))}
|
|
62
|
+
{visibleEntitlements.map((entitlement) => (
|
|
63
|
+
<EntitlementRow
|
|
64
|
+
key={entitlement.feature?.id}
|
|
65
|
+
displayNameOverride={entitlement.displayNameOverride}
|
|
66
|
+
feature={entitlement.feature}
|
|
67
|
+
resetPeriod={entitlement.resetPeriod}
|
|
68
|
+
hasUnlimitedUsage={entitlement.hasUnlimitedUsage}
|
|
69
|
+
usageLimit={entitlement.usageLimit}
|
|
70
|
+
isCustom={entitlement.isCustom}
|
|
71
|
+
/>
|
|
72
|
+
))}
|
|
74
73
|
</PlanEntitlementsContainer>
|
|
75
74
|
);
|
|
76
75
|
}
|
|
@@ -3,6 +3,7 @@ import { currencyPriceFormatter } from './currencyUtils';
|
|
|
3
3
|
import { PlanPriceText } from './getPlanPrice';
|
|
4
4
|
import { calculateTierPrice, getPriceFeatureUnit } from './priceTierUtils';
|
|
5
5
|
import { PaywallLocalization } from '../paywall';
|
|
6
|
+
import { numberFormatter } from './numberUtils';
|
|
6
7
|
|
|
7
8
|
type GetPaidPriceTextParams = {
|
|
8
9
|
planPrices: Price[];
|
|
@@ -49,12 +50,15 @@ export function getPaidPriceText({
|
|
|
49
50
|
|
|
50
51
|
if (isSinglePrice) {
|
|
51
52
|
const price = planPrices[0];
|
|
52
|
-
const
|
|
53
|
+
const formattedUnits =
|
|
54
|
+
price.blockSize && price.blockSize > 1
|
|
55
|
+
? `for ${numberFormatter(price.blockSize)} ${price.feature?.unitsPlural || price.feature?.units || ''}`
|
|
56
|
+
: `per ${price.feature?.units || ''}`;
|
|
53
57
|
|
|
54
58
|
if (price.pricingModel === BillingModel.PerUnit && !price.isTieredPrice) {
|
|
55
|
-
unit =
|
|
59
|
+
unit = `${formattedUnits} ${pricePeriod}`;
|
|
56
60
|
} else if (price.pricingModel === BillingModel.UsageBased) {
|
|
57
|
-
unit =
|
|
61
|
+
unit = `${formattedUnits}`;
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function numberFormatter(number: number, {
|
|
2
|
-
return new Intl.NumberFormat(
|
|
1
|
+
export function numberFormatter(number: number, { locale }: { locale?: string } = {}) {
|
|
2
|
+
return new Intl.NumberFormat(locale).format(number);
|
|
3
3
|
}
|