@stigg/react-sdk 4.3.0 → 4.3.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.
- package/dist/components/paywall/paywallTextOverrides.d.ts +2 -0
- package/dist/components/utils/getPaidPriceText.d.ts +3 -1
- package/dist/react-sdk.cjs.development.js +10 -4
- 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 +10 -4
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/paywall/paywallTextOverrides.ts +2 -0
- package/src/components/utils/getPaidPriceText.ts +8 -2
- package/src/components/utils/getPlanPrice.ts +1 -1
package/package.json
CHANGED
|
@@ -27,6 +27,7 @@ export type PaywallLocalization = {
|
|
|
27
27
|
price: {
|
|
28
28
|
startingAtCaption: string;
|
|
29
29
|
billingPeriod?: (billingPeriod: BillingPeriod) => string;
|
|
30
|
+
pricePeriod: (billingPeriod: BillingPeriod) => string;
|
|
30
31
|
custom: string;
|
|
31
32
|
priceNotSet: string;
|
|
32
33
|
free: PlanPriceText | ((currency?: PaywallCurrency) => PlanPriceText);
|
|
@@ -57,6 +58,7 @@ export function getResolvedPaywallLocalize(localizeOverride?: DeepPartial<Paywal
|
|
|
57
58
|
},
|
|
58
59
|
price: {
|
|
59
60
|
startingAtCaption: 'Starts at',
|
|
61
|
+
pricePeriod: (billingPeriod: BillingPeriod) => (billingPeriod === BillingPeriod.Monthly ? '/ month' : '/ year'),
|
|
60
62
|
free: currency => ({
|
|
61
63
|
price: `${currency?.symbol}0`,
|
|
62
64
|
}),
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { currencyPriceFormatter } from './currencyUtils';
|
|
9
9
|
import { PlanPriceText } from './getPlanPrice';
|
|
10
10
|
import { calculateTierPrice } from '../paywall/planPriceTier';
|
|
11
|
+
import { PaywallLocalization } from '../paywall';
|
|
11
12
|
|
|
12
13
|
type GetPaidPriceTextParams = {
|
|
13
14
|
planPrices: Price[];
|
|
@@ -16,6 +17,7 @@ type GetPaidPriceTextParams = {
|
|
|
16
17
|
locale: string;
|
|
17
18
|
shouldShowMonthlyPriceAmount: boolean;
|
|
18
19
|
selectedTierByFeature: Record<string, PriceTierFragment>;
|
|
20
|
+
paywallLocale: PaywallLocalization;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export function getPaidPriceText({
|
|
@@ -25,6 +27,7 @@ export function getPaidPriceText({
|
|
|
25
27
|
locale,
|
|
26
28
|
shouldShowMonthlyPriceAmount,
|
|
27
29
|
selectedTierByFeature,
|
|
30
|
+
paywallLocale,
|
|
28
31
|
}: GetPaidPriceTextParams): PlanPriceText {
|
|
29
32
|
const { amount, currency } = paywallCalculatedPrice || planPrices[0];
|
|
30
33
|
const priceAmount = amount || 0;
|
|
@@ -35,7 +38,10 @@ export function getPaidPriceText({
|
|
|
35
38
|
|
|
36
39
|
let tiers;
|
|
37
40
|
let tierUnits;
|
|
38
|
-
|
|
41
|
+
const pricePeriod = paywallLocale.price.pricePeriod(
|
|
42
|
+
shouldShowMonthlyPriceAmount ? BillingPeriod.Monthly : BillingPeriod.Annually,
|
|
43
|
+
);
|
|
44
|
+
let unit = pricePeriod;
|
|
39
45
|
|
|
40
46
|
for (const price of planPrices) {
|
|
41
47
|
if (price.isTieredPrice) {
|
|
@@ -56,7 +62,7 @@ export function getPaidPriceText({
|
|
|
56
62
|
const featureUnit = price.feature?.units || '';
|
|
57
63
|
|
|
58
64
|
if (price.pricingModel === BillingModel.PerUnit && !price.isTieredPrice) {
|
|
59
|
-
unit = shouldShowMonthlyPriceAmount ? `per ${featureUnit}
|
|
65
|
+
unit = shouldShowMonthlyPriceAmount ? `per ${featureUnit} ${pricePeriod}` : `per ${featureUnit} ${pricePeriod}`;
|
|
60
66
|
} else if (price.pricingModel === BillingModel.UsageBased) {
|
|
61
67
|
unit = `per ${featureUnit}`;
|
|
62
68
|
}
|
|
@@ -50,7 +50,7 @@ export function getPlanPrice(
|
|
|
50
50
|
|
|
51
51
|
return paywallLocale.price.paid
|
|
52
52
|
? paywallLocale.price.paid({ ...paidParams, plan })
|
|
53
|
-
: getPaidPriceText({ ...paidParams, locale, shouldShowMonthlyPriceAmount });
|
|
53
|
+
: getPaidPriceText({ ...paidParams, locale, shouldShowMonthlyPriceAmount, paywallLocale });
|
|
54
54
|
}
|
|
55
55
|
default:
|
|
56
56
|
return {
|