@stigg/react-sdk 4.13.1 → 4.14.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.
Files changed (34) hide show
  1. package/dist/components/common/TiersSelectContainer.d.ts +8 -3
  2. package/dist/components/common/VolumeBulkSelect.d.ts +5 -0
  3. package/dist/components/common/VolumePerUnitInput.d.ts +5 -0
  4. package/dist/components/paywall/PlanOfferingButton.d.ts +2 -1
  5. package/dist/components/paywall/PlanPrice.d.ts +3 -1
  6. package/dist/components/paywall/index.d.ts +1 -1
  7. package/dist/components/paywall/paywallTextOverrides.d.ts +9 -5
  8. package/dist/components/utils/getPaidPriceText.d.ts +2 -1
  9. package/dist/components/utils/getPlanPrice.d.ts +1 -1
  10. package/dist/components/utils/priceTierUtils.d.ts +3 -2
  11. package/dist/index.d.ts +1 -1
  12. package/dist/react-sdk.cjs.development.js +558 -365
  13. package/dist/react-sdk.cjs.development.js.map +1 -1
  14. package/dist/react-sdk.cjs.production.min.js +1 -1
  15. package/dist/react-sdk.cjs.production.min.js.map +1 -1
  16. package/dist/react-sdk.esm.js +628 -430
  17. package/dist/react-sdk.esm.js.map +1 -1
  18. package/package.json +2 -2
  19. package/src/components/checkout/hooks/usePlanStepModel.ts +3 -3
  20. package/src/components/checkout/steps/payment/stripe/stripe.utils.ts +10 -7
  21. package/src/components/checkout/steps/plan/CheckoutChargeList.tsx +10 -2
  22. package/src/components/common/TiersSelectContainer.tsx +33 -62
  23. package/src/components/common/VolumeBulkSelect.tsx +68 -0
  24. package/src/components/common/VolumePerUnitInput.tsx +40 -0
  25. package/src/components/paywall/PlanOffering.tsx +15 -6
  26. package/src/components/paywall/PlanOfferingButton.tsx +8 -2
  27. package/src/components/paywall/PlanPrice.tsx +20 -0
  28. package/src/components/paywall/index.ts +1 -1
  29. package/src/components/paywall/paywallTextOverrides.ts +7 -2
  30. package/src/components/utils/getPaidPriceText.ts +9 -1
  31. package/src/components/utils/getPlanPrice.ts +6 -1
  32. package/src/components/utils/priceTierUtils.ts +60 -14
  33. package/src/index.ts +1 -0
  34. package/src/stories/mocks/checkout/mockCheckoutPreview.ts +1 -1
@@ -1,9 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { PriceTierFragment } from '@stigg/js-client-sdk';
3
- export declare function TiersSelectContainer({ componentId, tiers, tierUnits, selectedTier, handleTierChange, }: {
2
+ import { PriceTierFragment, TiersMode } from '@stigg/js-client-sdk';
3
+ export declare type TiersSelectContainerProps = {
4
4
  componentId: string;
5
5
  tiers?: PriceTierFragment[] | null;
6
6
  tierUnits?: string;
7
7
  selectedTier?: PriceTierFragment;
8
8
  handleTierChange: (tier: PriceTierFragment) => void;
9
- }): JSX.Element;
9
+ tiersMode?: TiersMode | null;
10
+ handlePerUnitQuantityChange: (quantity: number) => void;
11
+ perUnitQuantity?: number;
12
+ width?: number;
13
+ };
14
+ export declare function TiersSelectContainer(props: TiersSelectContainerProps): JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { TiersSelectContainerProps } from './TiersSelectContainer';
3
+ export declare function VolumeBulkSelect({ selectedTier, componentId, tierUnits, tiers, handleChange, }: Pick<TiersSelectContainerProps, 'selectedTier' | 'componentId' | 'tiers' | 'tierUnits'> & {
4
+ handleChange: (quantity: number) => void;
5
+ }): JSX.Element | null;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { TiersSelectContainerProps } from './TiersSelectContainer';
3
+ export declare function VolumePerUnitInput({ width, tierUnits, perUnitQuantity, handlePerUnitQuantityChange, handleChange, }: Pick<TiersSelectContainerProps, 'width' | 'tierUnits' | 'perUnitQuantity' | 'handlePerUnitQuantityChange'> & {
4
+ handleChange: (quantity: number) => void;
5
+ }): JSX.Element;
@@ -13,6 +13,7 @@ declare type PlanOfferingButtonProps = {
13
13
  onPlanSelected: (intentionType: SubscribeIntentionType) => void | Promise<void>;
14
14
  withTrialLeftRow: boolean;
15
15
  selectedTierByFeature: Record<string, PriceTierFragment>;
16
+ perUnitQuantityByFeature: Record<string, number>;
16
17
  };
17
- export declare function PlanOfferingButton({ isNextPlan, customer, plan, billingPeriod, isCustomerOnTrial, onPlanSelected, paywallLocale, withTrialLeftRow, currentSubscription, selectedTierByFeature, }: PlanOfferingButtonProps): JSX.Element;
18
+ export declare function PlanOfferingButton({ isNextPlan, customer, plan, billingPeriod, isCustomerOnTrial, onPlanSelected, paywallLocale, withTrialLeftRow, currentSubscription, selectedTierByFeature, perUnitQuantityByFeature, }: PlanOfferingButtonProps): JSX.Element;
18
19
  export {};
@@ -2,13 +2,15 @@ import React from 'react';
2
2
  import { BillingPeriod, PriceTierFragment } from '@stigg/js-client-sdk';
3
3
  import { PaywallPlan } from './types';
4
4
  import { PaywallLocalization } from './paywallTextOverrides';
5
- export declare const PlanPrice: ({ showStartingAt, withUnitPriceRow, withStartingAtRow, withTiersRow, selectedTierByFeature, setSelectedTierByFeature, plan, billingPeriod, paywallLocale, locale, hasMonthlyPrice, hasAnnuallyPrice, }: {
5
+ export declare const PlanPrice: ({ showStartingAt, withUnitPriceRow, withStartingAtRow, withTiersRow, selectedTierByFeature, setSelectedTierByFeature, plan, billingPeriod, paywallLocale, locale, hasMonthlyPrice, hasAnnuallyPrice, perUnitQuantityByFeature, setPerUnitQuantityByFeature, }: {
6
6
  showStartingAt: boolean;
7
7
  withUnitPriceRow: boolean;
8
8
  withStartingAtRow: boolean;
9
9
  withTiersRow: boolean;
10
10
  selectedTierByFeature: Record<string, PriceTierFragment>;
11
11
  setSelectedTierByFeature: React.Dispatch<React.SetStateAction<Record<string, PriceTierFragment>>>;
12
+ perUnitQuantityByFeature: Record<string, number>;
13
+ setPerUnitQuantityByFeature: React.Dispatch<React.SetStateAction<Record<string, number>>>;
12
14
  plan: PaywallPlan;
13
15
  billingPeriod: BillingPeriod;
14
16
  paywallLocale: PaywallLocalization;
@@ -1,3 +1,3 @@
1
1
  export { PaywallContainer as Paywall, PaywallContainerProps as PaywallProps } from './PaywallContainer';
2
2
  export { PaywallPlan, OnPlanSelectedCallbackFn, SubscribeIntentionType } from './types';
3
- export { PaywallLocalization, PlanPriceText } from './paywallTextOverrides';
3
+ export { PaywallLocalization, PlanPriceText, CurrentPlanParams } from './paywallTextOverrides';
@@ -3,6 +3,10 @@ import { DeepPartial } from '../../types';
3
3
  import { PlanPriceText } from '../utils/getPlanPrice';
4
4
  import { PaywallPlan } from './types';
5
5
  export { PlanPriceText } from '../utils/getPlanPrice';
6
+ export declare type CurrentPlanParams = {
7
+ plan: Plan;
8
+ selectedBillingPeriod: BillingPeriod;
9
+ };
6
10
  export declare type PaywallLocalization = {
7
11
  highlightChip: string;
8
12
  entitlementsTitle?: (plan: PaywallPlan) => string;
@@ -10,7 +14,7 @@ export declare type PaywallLocalization = {
10
14
  upgrade: string | ((plan: PaywallPlan) => string);
11
15
  downgrade: string | ((plan: PaywallPlan) => string);
12
16
  startTrial: (plan: PaywallPlan) => string;
13
- custom: string;
17
+ custom: ((data: CurrentPlanParams) => string) | string;
14
18
  currentPlan: string;
15
19
  startNew: string;
16
20
  switchToBillingPeriod: (billingPeriod: BillingPeriod) => string;
@@ -20,7 +24,7 @@ export declare type PaywallLocalization = {
20
24
  startingAtCaption: string;
21
25
  billingPeriod?: (billingPeriod: BillingPeriod) => string;
22
26
  pricePeriod: (billingPeriod: BillingPeriod) => string;
23
- custom: string;
27
+ custom: ((data: CurrentPlanParams) => string) | string;
24
28
  priceNotSet: string;
25
29
  free: PlanPriceText | ((currency?: PaywallCurrency) => PlanPriceText);
26
30
  paid?: (priceData: {
@@ -39,7 +43,7 @@ export declare function getResolvedPaywallLocalize(localizeOverride?: DeepPartia
39
43
  upgrade?: string | {} | undefined;
40
44
  downgrade?: string | {} | undefined;
41
45
  startTrial?: {} | undefined;
42
- custom?: string | undefined;
46
+ custom?: string | {} | undefined;
43
47
  currentPlan?: string | undefined;
44
48
  startNew?: string | undefined;
45
49
  switchToBillingPeriod?: {} | undefined;
@@ -49,14 +53,14 @@ export declare function getResolvedPaywallLocalize(localizeOverride?: DeepPartia
49
53
  startingAtCaption?: string | undefined;
50
54
  billingPeriod?: {} | undefined;
51
55
  pricePeriod?: {} | undefined;
52
- custom?: string | undefined;
56
+ custom?: string | {} | undefined;
53
57
  priceNotSet?: string | undefined;
54
58
  free?: {
55
59
  price?: string | undefined;
56
60
  unit?: string | undefined;
57
61
  tiers?: ({
58
62
  __typename?: "PriceTier" | undefined;
59
- upTo?: number | undefined;
63
+ upTo?: number | null | undefined;
60
64
  unitPrice?: {
61
65
  __typename?: "Money" | undefined;
62
66
  amount?: number | undefined;
@@ -9,6 +9,7 @@ declare type GetPaidPriceTextParams = {
9
9
  shouldShowMonthlyPriceAmount: boolean;
10
10
  selectedTierByFeature: Record<string, PriceTierFragment>;
11
11
  paywallLocale: PaywallLocalization;
12
+ perUnitQuantityByFeature?: Record<string, number>;
12
13
  };
13
- export declare function getPaidPriceText({ planPrices, paywallCalculatedPrice, selectedBillingPeriod, locale, shouldShowMonthlyPriceAmount, selectedTierByFeature, paywallLocale, }: GetPaidPriceTextParams): PlanPriceText;
14
+ export declare function getPaidPriceText({ planPrices, paywallCalculatedPrice, selectedBillingPeriod, locale, shouldShowMonthlyPriceAmount, selectedTierByFeature, paywallLocale, perUnitQuantityByFeature, }: GetPaidPriceTextParams): PlanPriceText;
14
15
  export {};
@@ -6,4 +6,4 @@ export declare type PlanPriceText = {
6
6
  tiers?: PriceTierFragment[] | null | undefined;
7
7
  tierUnits?: string;
8
8
  };
9
- export declare function getPlanPrice(plan: PaywallPlan, billingPeriod: BillingPeriod, paywallLocale: PaywallLocalization, locale: string, shouldShowMonthlyPriceAmount: boolean, selectedTierByFeature?: Record<string, PriceTierFragment>): PlanPriceText;
9
+ export declare function getPlanPrice(plan: PaywallPlan, billingPeriod: BillingPeriod, paywallLocale: PaywallLocalization, locale: string, shouldShowMonthlyPriceAmount: boolean, selectedTierByFeature?: Record<string, PriceTierFragment>, perUnitQuantityByFeature?: Record<string, number>): PlanPriceText;
@@ -3,11 +3,12 @@ import { PaywallPlan } from '../paywall';
3
3
  import { SelectDefaultTierIndexFn } from '../paywall/types';
4
4
  export declare function getPriceFeatureUnit(price: Price): string;
5
5
  export declare function getTierByQuantity(tiers: PriceTierFragment[], quantity: number): PriceTierFragment | undefined;
6
- export declare function calculateTierPrice(price: Price, currentTier: PriceTierFragment, selectedBillingPeriod: BillingPeriod, shouldShowMonthlyPriceAmount: boolean): number;
6
+ export declare function calculateTierPrice(price: Price, currentTier: PriceTierFragment, selectedBillingPeriod: BillingPeriod, shouldShowMonthlyPriceAmount: boolean, perUnitQuantity?: number): number;
7
+ export declare function getSelectedTierQuantityBeFeature(plan: PaywallPlan, billingPeriod: BillingPeriod, currentSubscription: Subscription | null): Record<string, number>;
7
8
  export declare function getSelectedTier(plan: PaywallPlan, billingPeriod: BillingPeriod, currentSubscription: Subscription | null, selectedTierByFeature: Record<string, PriceTierFragment>, selectDefaultTierIndex?: SelectDefaultTierIndexFn): Record<string, PriceTierFragment>;
8
9
  export declare enum PriceTierComparison {
9
10
  Lower = -1,
10
11
  Equal = 0,
11
12
  Higher = 1
12
13
  }
13
- export declare function compareSelectedTierToCurrentTier(selectedTierByFeature: Record<string, PriceTierFragment>, currentSubscription: Subscription | null): PriceTierComparison;
14
+ export declare function compareSelectedTierToCurrentTier(selectedTierByFeature: Record<string, PriceTierFragment>, perUnitQuantityByFeature: Record<string, number>, currentSubscription: Subscription | null): PriceTierComparison;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './styles.css';
2
2
  export * from '@stigg/js-client-sdk';
3
- export { Paywall, PaywallProps, OnPlanSelectedCallbackFn, PaywallPlan, SubscribeIntentionType, PaywallLocalization, PlanPriceText, } from './components/paywall';
3
+ export { Paywall, PaywallProps, OnPlanSelectedCallbackFn, PaywallPlan, SubscribeIntentionType, PaywallLocalization, PlanPriceText, CurrentPlanParams, } from './components/paywall';
4
4
  export { CustomerPortalProvider, CustomerPortal, CustomerPortalProps, CustomerPortalSection, AddonsList, PaymentDetailsSection, InvoicesSection, CustomerUsageData, CustomerUsageDataProps, SubscriptionsOverview, SubscriptionsOverviewProps, Promotions, } from './components/customerPortal';
5
5
  export { StiggProvider, StiggProviderProps, useStiggContext, StiggContextValue, StiggContext, } from './components/StiggProvider';
6
6
  export { Checkout, CheckoutProps, CheckoutProviderProps, CheckoutContainerProps, CheckoutLocalization, CheckoutResult, OnCheckoutCompletedParams, OnCheckoutParams, CheckoutTheme, CheckoutMockProps, MockCheckoutPreviewCallback, MockCheckoutStateCallback, BillingInformation, TaxDetailsInput, } from './components/checkout';