@stigg/react-sdk 5.28.4 → 5.30.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/paywall/Paywall.d.ts +3 -2
- package/dist/components/paywall/PaywallContainer.d.ts +3 -2
- package/dist/components/paywall/PlanOffering.d.ts +3 -2
- package/dist/components/paywall/PlanOfferingButton.d.ts +3 -2
- package/dist/components/paywall/hooks/useLoadPaywallData.d.ts +3 -2
- package/dist/components/paywall/types.d.ts +8 -0
- package/dist/components/paywall/utils/mapPaywallData.d.ts +3 -2
- package/dist/components/utils/priceTierUtils.d.ts +14 -3
- package/dist/react-sdk.cjs.development.js +106 -34
- 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 +106 -34
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/paywall/Paywall.tsx +11 -2
- package/src/components/paywall/PaywallContainer.tsx +11 -1
- package/src/components/paywall/PlanOffering.tsx +11 -2
- package/src/components/paywall/PlanOfferingButton.tsx +9 -2
- package/src/components/paywall/hooks/useLoadPaywallData.ts +4 -2
- package/src/components/paywall/types.ts +12 -0
- package/src/components/paywall/utils/mapPaywallData.ts +13 -3
- package/src/components/utils/priceTierUtils.ts +54 -13
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BillingPeriod, Customer, Subscription } from '@stigg/js-client-sdk';
|
|
3
|
-
import { ShouldHidePlanFn, OnPlanSelectedCallbackFn, PaywallPlan, SelectDefaultTierIndexFn } from './types';
|
|
3
|
+
import { ShouldHidePlanFn, OnPlanSelectedCallbackFn, PaywallPlan, SelectDefaultTierIndexFn, CurrentSubscriptionOverride } from './types';
|
|
4
4
|
import { PaywallLocalization } from './paywallTextOverrides';
|
|
5
5
|
declare type PaywallProps = {
|
|
6
6
|
plans: PaywallPlan[];
|
|
7
7
|
customer: Customer | null;
|
|
8
8
|
currentSubscription: Subscription | null;
|
|
9
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverride | null;
|
|
9
10
|
selectedBillingPeriod: BillingPeriod;
|
|
10
11
|
highlightedPlanId?: string;
|
|
11
12
|
onBillingPeriodChanged: (billingPeriod: BillingPeriod) => void;
|
|
@@ -17,5 +18,5 @@ declare type PaywallProps = {
|
|
|
17
18
|
shouldHidePlan?: ShouldHidePlanFn;
|
|
18
19
|
selectDefaultTierIndex?: SelectDefaultTierIndexFn;
|
|
19
20
|
};
|
|
20
|
-
export declare const Paywall: ({ plans, customer, currentSubscription, highlightedPlanId, selectedBillingPeriod, onBillingPeriodChanged, availableBillingPeriods, isCustomerOnTrial, onPlanSelected, paywallLocale, locale, shouldHidePlan, selectDefaultTierIndex, }: PaywallProps) => JSX.Element;
|
|
21
|
+
export declare const Paywall: ({ plans, customer, currentSubscription, highlightedPlanId, selectedBillingPeriod, onBillingPeriodChanged, availableBillingPeriods, isCustomerOnTrial, onPlanSelected, paywallLocale, locale, shouldHidePlan, selectDefaultTierIndex, currentSubscriptionOverride, }: PaywallProps) => JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BillingPeriod } from '@stigg/js-client-sdk';
|
|
3
|
-
import { ShouldHidePlanFn, OnPlanSelectedCallbackFn, SelectDefaultTierIndexFn } from './types';
|
|
3
|
+
import { ShouldHidePlanFn, OnPlanSelectedCallbackFn, SelectDefaultTierIndexFn, CurrentSubscriptionOverrideFn } from './types';
|
|
4
4
|
import { PaywallLocalization } from './paywallTextOverrides';
|
|
5
5
|
import { DeepPartial } from '../../types';
|
|
6
6
|
export declare type PaywallContainerProps = {
|
|
@@ -15,5 +15,6 @@ export declare type PaywallContainerProps = {
|
|
|
15
15
|
billingCountryCode?: string;
|
|
16
16
|
shouldHidePlan?: ShouldHidePlanFn;
|
|
17
17
|
selectDefaultTierIndex?: SelectDefaultTierIndexFn;
|
|
18
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverrideFn;
|
|
18
19
|
};
|
|
19
|
-
export declare const PaywallContainer: ({ productId, resourceId, highlightedPlanId, showOnlyEligiblePlans, textOverrides, onPlanSelected, preferredBillingPeriod, onBillingPeriodChange, billingCountryCode, shouldHidePlan, selectDefaultTierIndex, }: PaywallContainerProps) => JSX.Element;
|
|
20
|
+
export declare const PaywallContainer: ({ productId, resourceId, highlightedPlanId, showOnlyEligiblePlans, textOverrides, onPlanSelected, preferredBillingPeriod, onBillingPeriodChange, billingCountryCode, shouldHidePlan, selectDefaultTierIndex, currentSubscriptionOverride: currentSubscriptionOverrideFn, }: PaywallContainerProps) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BillableFeature, BillingPeriod, Customer, Subscription } from '@stigg/js-client-sdk';
|
|
3
|
-
import { PaywallPlan, SelectDefaultTierIndexFn, SubscribeIntentionType } from './types';
|
|
3
|
+
import { CurrentSubscriptionOverride, PaywallPlan, SelectDefaultTierIndexFn, SubscribeIntentionType } from './types';
|
|
4
4
|
import { PaywallLocalization } from './paywallTextOverrides';
|
|
5
5
|
declare type PlanOfferingProps = {
|
|
6
6
|
withUnitPriceRow: boolean;
|
|
@@ -10,6 +10,7 @@ declare type PlanOfferingProps = {
|
|
|
10
10
|
plan: PaywallPlan;
|
|
11
11
|
billingPeriod: BillingPeriod;
|
|
12
12
|
currentSubscription: Subscription | null;
|
|
13
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverride | null;
|
|
13
14
|
isHighlighted: boolean;
|
|
14
15
|
shouldShowDescriptionSection: boolean;
|
|
15
16
|
hasAnnuallyPrice: boolean;
|
|
@@ -22,5 +23,5 @@ declare type PlanOfferingProps = {
|
|
|
22
23
|
isCustomerInCustomPlan: boolean;
|
|
23
24
|
selectDefaultTierIndex?: SelectDefaultTierIndexFn;
|
|
24
25
|
};
|
|
25
|
-
export declare function PlanOffering({ withUnitPriceRow, withTiersRow, withTrialLeftRow, customer, plan, billingPeriod, isHighlighted, currentSubscription, shouldShowDescriptionSection, hasMonthlyPrice, hasAnnuallyPrice, isCustomerOnTrial, onPlanSelected, paywallLocale, locale, withStartingAtRow, isCustomerInCustomPlan, selectDefaultTierIndex, }: PlanOfferingProps): JSX.Element;
|
|
26
|
+
export declare function PlanOffering({ withUnitPriceRow, withTiersRow, withTrialLeftRow, customer, plan, billingPeriod, isHighlighted, currentSubscription, currentSubscriptionOverride, shouldShowDescriptionSection, hasMonthlyPrice, hasAnnuallyPrice, isCustomerOnTrial, onPlanSelected, paywallLocale, locale, withStartingAtRow, isCustomerInCustomPlan, selectDefaultTierIndex, }: PlanOfferingProps): JSX.Element;
|
|
26
27
|
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BillingPeriod, Customer, Subscription } from '@stigg/js-client-sdk';
|
|
3
|
-
import { PaywallPlan, SubscribeIntentionType } from './types';
|
|
3
|
+
import { CurrentSubscriptionOverride, PaywallPlan, SubscribeIntentionType } from './types';
|
|
4
4
|
import { PaywallLocalization } from './paywallTextOverrides';
|
|
5
5
|
declare type PlanOfferingButtonProps = {
|
|
6
6
|
isNextPlan?: boolean;
|
|
7
7
|
customer: Customer | null;
|
|
8
8
|
plan: PaywallPlan;
|
|
9
9
|
currentSubscription: Subscription | null;
|
|
10
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverride | null;
|
|
10
11
|
billingPeriod: BillingPeriod;
|
|
11
12
|
isCustomerOnTrial: boolean;
|
|
12
13
|
paywallLocale: PaywallLocalization;
|
|
@@ -14,5 +15,5 @@ declare type PlanOfferingButtonProps = {
|
|
|
14
15
|
withTrialLeftRow: boolean;
|
|
15
16
|
perUnitQuantityByFeature: Record<string, number>;
|
|
16
17
|
};
|
|
17
|
-
export declare function PlanOfferingButton({ isNextPlan, customer, plan, billingPeriod, isCustomerOnTrial, onPlanSelected, paywallLocale, withTrialLeftRow, currentSubscription, perUnitQuantityByFeature, }: PlanOfferingButtonProps): JSX.Element;
|
|
18
|
+
export declare function PlanOfferingButton({ isNextPlan, customer, plan, billingPeriod, isCustomerOnTrial, onPlanSelected, paywallLocale, withTrialLeftRow, currentSubscription, currentSubscriptionOverride, perUnitQuantityByFeature, }: PlanOfferingButtonProps): JSX.Element;
|
|
18
19
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BillingPeriod } from '@stigg/js-client-sdk';
|
|
2
|
-
import { PaywallData } from '../types';
|
|
2
|
+
import { CurrentSubscriptionOverrideFn, PaywallData } from '../types';
|
|
3
3
|
declare type UseLoadPaywallDataProps = {
|
|
4
4
|
productId?: string;
|
|
5
5
|
resourceId?: string;
|
|
6
6
|
showOnlyEligiblePlans?: boolean;
|
|
7
7
|
billingCountryCode?: string;
|
|
8
8
|
preferredBillingPeriod?: BillingPeriod;
|
|
9
|
+
currentSubscriptionOverrideFn?: CurrentSubscriptionOverrideFn;
|
|
9
10
|
};
|
|
10
|
-
export declare function useLoadPaywallData({ productId, resourceId, showOnlyEligiblePlans, billingCountryCode, preferredBillingPeriod, }: UseLoadPaywallDataProps): PaywallData;
|
|
11
|
+
export declare function useLoadPaywallData({ productId, resourceId, showOnlyEligiblePlans, billingCountryCode, preferredBillingPeriod, currentSubscriptionOverrideFn, }: UseLoadPaywallDataProps): PaywallData;
|
|
11
12
|
export {};
|
|
@@ -4,6 +4,7 @@ export declare type PaywallData = {
|
|
|
4
4
|
plans: PaywallPlan[] | null;
|
|
5
5
|
customer: Customer | null;
|
|
6
6
|
currentSubscription: Subscription | null;
|
|
7
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverride | null;
|
|
7
8
|
isCustomerOnTrial: boolean;
|
|
8
9
|
isLoading: boolean;
|
|
9
10
|
selectedBillingPeriod: BillingPeriod;
|
|
@@ -12,6 +13,10 @@ export declare type PaywallData = {
|
|
|
12
13
|
locale: string;
|
|
13
14
|
configuration?: CustomizedTheme;
|
|
14
15
|
};
|
|
16
|
+
export declare type CurrentSubscriptionOverride = {
|
|
17
|
+
planId: string;
|
|
18
|
+
billableFeatures: BillableFeature[];
|
|
19
|
+
};
|
|
15
20
|
export declare enum SubscribeIntentionType {
|
|
16
21
|
START_TRIAL = "START_TRIAL",
|
|
17
22
|
UPGRADE_TRIAL_TO_PAID = "UPGRADE_TRIAL_TO_PAID",
|
|
@@ -44,6 +49,9 @@ export declare type OnPlanSelectedCallbackFn = ({ plan, customer, subscription,
|
|
|
44
49
|
export declare type ShouldHidePlanFn = ({ plan }: {
|
|
45
50
|
plan: PaywallPlan;
|
|
46
51
|
}) => boolean | Promise<boolean>;
|
|
52
|
+
export declare type CurrentSubscriptionOverrideFn = ({ currentSubscription, }: {
|
|
53
|
+
currentSubscription: Subscription | null;
|
|
54
|
+
}) => CurrentSubscriptionOverride | null | undefined;
|
|
47
55
|
export declare type SelectDefaultTierIndexFn = ({ plan }: {
|
|
48
56
|
plan: PaywallPlan;
|
|
49
57
|
}) => number;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Paywall, Plan, Subscription } from '@stigg/js-client-sdk';
|
|
2
|
-
import { PaywallPlan } from '../types';
|
|
2
|
+
import { CurrentSubscriptionOverride, CurrentSubscriptionOverrideFn, PaywallPlan } from '../types';
|
|
3
3
|
import { DeepPartial } from '../../../types';
|
|
4
4
|
import { StiggTheme } from '../../../theme/types';
|
|
5
5
|
declare type PaywallData = {
|
|
6
6
|
currentPlan?: Plan;
|
|
7
7
|
currentSubscription: Subscription | null;
|
|
8
|
+
currentSubscriptionOverride: CurrentSubscriptionOverride | null | undefined;
|
|
8
9
|
isCustomerOnTrial: boolean;
|
|
9
10
|
plans: PaywallPlan[];
|
|
10
11
|
paywallConfiguration?: DeepPartial<StiggTheme>;
|
|
11
12
|
};
|
|
12
|
-
export declare function mapPaywallData(paywall: Paywall | null, showOnlyEligiblePlans?: boolean): PaywallData;
|
|
13
|
+
export declare function mapPaywallData(paywall: Paywall | null, showOnlyEligiblePlans?: boolean, currentSubscriptionOverrideFn?: CurrentSubscriptionOverrideFn): PaywallData;
|
|
13
14
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BillingPeriod, Price, PriceTierFragment, Subscription } from '@stigg/js-client-sdk';
|
|
2
2
|
import { PaywallPlan } from '../paywall';
|
|
3
|
-
import { SelectDefaultTierIndexFn } from '../paywall/types';
|
|
3
|
+
import { CurrentSubscriptionOverride, SelectDefaultTierIndexFn } from '../paywall/types';
|
|
4
4
|
export declare function getPriceFeatureUnit(price: Price): string;
|
|
5
5
|
export declare function getTierByQuantity(tiers: PriceTierFragment[], quantity: number): PriceTierFragment;
|
|
6
6
|
export declare function calculateTierPriceGraduated(tiers: PriceTierFragment[], unitQuantity: number, selectedBillingPeriod?: BillingPeriod, shouldShowMonthlyPriceAmount?: boolean): {
|
|
@@ -14,10 +14,21 @@ export declare function calculateTierPrice(price: Pick<Price, 'tiers' | 'tiersMo
|
|
|
14
14
|
export declare function hasTierWithUnitPrice(tiers: PriceTierFragment[] | null | undefined): boolean | undefined;
|
|
15
15
|
export declare function isBulkTiers(tiers: PriceTierFragment[] | null | undefined): boolean | undefined;
|
|
16
16
|
export declare function isQuantityInFirstTier(tiers: PriceTierFragment[] | null | undefined, quantity: number): boolean | 0 | null | undefined;
|
|
17
|
-
export declare function getTiersPerUnitQuantities(plan
|
|
17
|
+
export declare function getTiersPerUnitQuantities({ plan, billingPeriod, currentSubscription, currentSubscriptionOverride, selectDefaultTierIndex, }: {
|
|
18
|
+
plan: PaywallPlan;
|
|
19
|
+
billingPeriod: BillingPeriod;
|
|
20
|
+
currentSubscription: Subscription | null;
|
|
21
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverride | null;
|
|
22
|
+
selectDefaultTierIndex?: SelectDefaultTierIndexFn;
|
|
23
|
+
}): Record<string, number>;
|
|
18
24
|
export declare enum PriceTierComparison {
|
|
19
25
|
Lower = -1,
|
|
20
26
|
Equal = 0,
|
|
21
27
|
Higher = 1
|
|
22
28
|
}
|
|
23
|
-
export declare function compareSelectedTierToCurrentTier(perUnitQuantityByFeature
|
|
29
|
+
export declare function compareSelectedTierToCurrentTier({ perUnitQuantityByFeature, plan, currentSubscription, currentSubscriptionOverride, }: {
|
|
30
|
+
perUnitQuantityByFeature: Record<string, number>;
|
|
31
|
+
plan: PaywallPlan;
|
|
32
|
+
currentSubscription: Subscription | null;
|
|
33
|
+
currentSubscriptionOverride?: CurrentSubscriptionOverride | null;
|
|
34
|
+
}): PriceTierComparison;
|