@stigg/react-sdk 4.14.0 → 5.0.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 (46) hide show
  1. package/dist/components/customerPortal/CustomerPortal.d.ts +2 -2
  2. package/dist/components/customerPortal/CustomerPortalContainer.d.ts +4 -0
  3. package/dist/components/customerPortal/index.d.ts +3 -0
  4. package/dist/components/customerPortal/subscriptionOverview/SubscriptionsOverview.d.ts +2 -1
  5. package/dist/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.d.ts +2 -1
  6. package/dist/components/customerPortal/subscriptionOverview/charges/ChargeItem.d.ts +2 -1
  7. package/dist/components/customerPortal/subscriptionOverview/charges/ChargeList.d.ts +2 -1
  8. package/dist/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.d.ts +2 -1
  9. package/dist/components/customerPortal/subscriptionOverview/subscriptionView/TrialPanel.d.ts +2 -1
  10. package/dist/components/customerPortal/types.d.ts +10 -1
  11. package/dist/components/customerPortal/usage/CustomerUsageData.d.ts +2 -1
  12. package/dist/components/customerPortal/usage/featureUsage/EntitlementCTAButton.d.ts +2 -1
  13. package/dist/components/customerPortal/usage/featureUsage/FeatureUsage.d.ts +2 -1
  14. package/dist/components/paywall/index.d.ts +1 -1
  15. package/dist/components/paywall/paywallTextOverrides.d.ts +6 -1
  16. package/dist/components/utils/priceTierUtils.d.ts +3 -1
  17. package/dist/index.d.ts +3 -3
  18. package/dist/react-sdk.cjs.development.js +82 -55
  19. package/dist/react-sdk.cjs.development.js.map +1 -1
  20. package/dist/react-sdk.cjs.production.min.js +1 -1
  21. package/dist/react-sdk.cjs.production.min.js.map +1 -1
  22. package/dist/react-sdk.esm.js +87 -58
  23. package/dist/react-sdk.esm.js.map +1 -1
  24. package/package.json +2 -2
  25. package/src/components/checkout/hooks/usePlanStepModel.ts +3 -3
  26. package/src/components/checkout/summary/components/LineItems.tsx +7 -3
  27. package/src/components/common/TiersSelectContainer.tsx +7 -14
  28. package/src/components/customerPortal/CustomerPortal.tsx +2 -2
  29. package/src/components/customerPortal/CustomerPortalContainer.tsx +8 -3
  30. package/src/components/customerPortal/index.ts +3 -0
  31. package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverview.tsx +2 -1
  32. package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.tsx +7 -2
  33. package/src/components/customerPortal/subscriptionOverview/charges/ChargeItem.tsx +2 -1
  34. package/src/components/customerPortal/subscriptionOverview/charges/ChargeList.tsx +2 -1
  35. package/src/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.tsx +2 -1
  36. package/src/components/customerPortal/subscriptionOverview/subscriptionView/TrialPanel.tsx +6 -2
  37. package/src/components/customerPortal/types.ts +15 -1
  38. package/src/components/customerPortal/usage/CustomerUsageData.tsx +2 -1
  39. package/src/components/customerPortal/usage/featureUsage/EntitlementCTAButton.tsx +6 -3
  40. package/src/components/customerPortal/usage/featureUsage/FeatureUsage.tsx +2 -1
  41. package/src/components/paywall/index.ts +1 -1
  42. package/src/components/utils/calculateDiscountRate.ts +2 -1
  43. package/src/components/utils/getPaidPriceText.ts +1 -1
  44. package/src/components/utils/priceTierUtils.ts +41 -21
  45. package/src/index.ts +9 -1
  46. package/src/stories/mocks/checkout/mockCheckoutState.ts +4 -4
@@ -3,10 +3,10 @@ import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
3
3
  import { DeepPartial } from '../../types';
4
4
  import { CustomerPortalLocalization } from './customerPortalTextOverrides';
5
5
  import { CustomerPortalTheme } from './customerPortalTheme';
6
- import { OnBuyMoreCallbackFn } from './types';
6
+ import { OnBuyMoreCallbackFn, OnManageSubscriptionFn } from './types';
7
7
  export declare type CustomerPortalSection = 'usage' | 'addons' | 'promotionalEntitlements' | 'billingInformation' | 'paymentDetails' | 'invoices';
8
8
  export declare type CustomerPortalProps = {
9
- onManageSubscription?: () => Promise<void> | void;
9
+ onManageSubscription?: OnManageSubscriptionFn;
10
10
  onBuyMore?: OnBuyMoreCallbackFn;
11
11
  onCancelScheduledUpdates?: (subscription: CustomerPortalSubscription) => Promise<void> | void;
12
12
  onContactSupport?: () => Promise<void> | void;
@@ -1,3 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomerPortalProps } from './CustomerPortal';
3
+ import { CustomerPortalIntentionType } from './types';
4
+ export declare type OnManageClick = ({ intentionType }: {
5
+ intentionType: CustomerPortalIntentionType;
6
+ }) => void;
3
7
  export declare function CustomerPortalContainer({ onManageSubscription, onBuyMore, onCancelScheduledUpdates, onContactSupport, paywallComponent, hiddenSections, }: CustomerPortalProps): JSX.Element;
@@ -6,3 +6,6 @@ export { CustomerUsageData, CustomerUsageDataProps } from './usage/CustomerUsage
6
6
  export { AddonsList } from './subscriptionOverview/tabs/AddonsList';
7
7
  export { Promotions } from './subscriptionOverview/tabs/Promotions';
8
8
  export { CustomerPortalProvider } from './CustomerPortalProvider';
9
+ export { CustomerPortalLocalization } from './customerPortalTextOverrides';
10
+ export { CustomerPortalTheme } from './customerPortalTheme';
11
+ export * from './types';
@@ -2,8 +2,9 @@
2
2
  import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
3
3
  import { CustomerPortalSection } from '../CustomerPortal';
4
4
  import { OnBuyMoreCallbackFn } from '../types';
5
+ import { OnManageClick } from '../CustomerPortalContainer';
5
6
  export declare type SubscriptionsOverviewProps = {
6
- onManageSubscription: () => void;
7
+ onManageSubscription: OnManageClick;
7
8
  onBuyMore?: OnBuyMoreCallbackFn;
8
9
  onCancelScheduledUpdates?: (subscription: CustomerPortalSubscription) => void;
9
10
  onContactSupport?: () => void;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomerPortalLocalization } from '../customerPortalTextOverrides';
3
+ import { OnManageClick } from '../CustomerPortalContainer';
3
4
  declare type SubscriptionsOverviewHeaderProps = {
4
- onManageSubscription: () => void;
5
+ onManageSubscription: OnManageClick;
5
6
  hideManageButton: boolean;
6
7
  textOverrides: CustomerPortalLocalization;
7
8
  };
@@ -2,13 +2,14 @@
2
2
  import { Currency, CustomerPortalEntitlement } from '@stigg/js-client-sdk';
3
3
  import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
4
4
  import { OnBuyMoreCallbackFn } from '../../types';
5
+ import { OnManageClick } from '../../CustomerPortalContainer';
5
6
  export declare type UsageBasedChargeProps = {
6
7
  entitlement: Exclude<CustomerPortalEntitlement, 'feature'>;
7
8
  feature: FeatureFragment;
8
9
  amount: number;
9
10
  currency: Currency;
10
11
  onBuyMore?: OnBuyMoreCallbackFn;
11
- onManageSubscription: () => void;
12
+ onManageSubscription: OnManageClick;
12
13
  canUpgradeSubscription: boolean;
13
14
  hasCustomSubscription: boolean;
14
15
  hideChargePrice?: boolean;
@@ -1,11 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomerPortalEntitlement, CustomerPortalSubscription } from '@stigg/js-client-sdk';
3
3
  import { OnBuyMoreCallbackFn } from '../../types';
4
+ import { OnManageClick } from '../../CustomerPortalContainer';
4
5
  export declare type ChargesProps = {
5
6
  subscription: CustomerPortalSubscription;
6
7
  entitlements: CustomerPortalEntitlement[];
7
8
  onBuyMore?: OnBuyMoreCallbackFn;
8
- onManageSubscription: () => void;
9
+ onManageSubscription: OnManageClick;
9
10
  canUpgradeSubscription: boolean;
10
11
  hasCustomSubscription: boolean;
11
12
  };
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
3
3
  import { CustomerPortalTheme } from '../../customerPortalTheme';
4
+ import { OnManageClick } from '../../CustomerPortalContainer';
4
5
  declare type SubscriptionViewProps = {
5
6
  mainSubscription: CustomerPortalSubscription;
6
7
  trialSubscription: CustomerPortalSubscription | undefined;
7
- onManageSubscription: () => void;
8
+ onManageSubscription: OnManageClick;
8
9
  theme: CustomerPortalTheme;
9
10
  };
10
11
  export declare function SubscriptionView({ mainSubscription, trialSubscription, onManageSubscription, theme, }: SubscriptionViewProps): JSX.Element;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
3
+ import { OnManageClick } from '../../CustomerPortalContainer';
3
4
  export declare function TrialPanel({ subscription, includePlanName, onManageSubscription, }: {
4
5
  subscription: CustomerPortalSubscription | undefined;
5
6
  includePlanName: boolean;
6
- onManageSubscription?: () => void;
7
+ onManageSubscription: OnManageClick;
7
8
  }): JSX.Element | null;
@@ -1,3 +1,12 @@
1
- import { CustomerPortalEntitlement } from '@stigg/js-client-sdk';
1
+ import { CustomerPortalEntitlement, CustomerPortalSubscription } from '@stigg/js-client-sdk';
2
2
  import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
3
3
  export declare type OnBuyMoreCallbackFn = (feature: FeatureFragment, entitlement: CustomerPortalEntitlement) => void;
4
+ export declare enum CustomerPortalIntentionType {
5
+ MANAGE_SUBSCRIPTION = "MANAGE_SUBSCRIPTION",
6
+ UPGRADE_PLAN = "UPGRADE_PLAN",
7
+ UPGRADE_TRIAL_PLAN = "UPGRADE_TRIAL_PLAN"
8
+ }
9
+ export declare type OnManageSubscriptionFn = ({ intentionType, customerSubscriptions, }: {
10
+ intentionType: CustomerPortalIntentionType;
11
+ customerSubscriptions: CustomerPortalSubscription[];
12
+ }) => Promise<void> | void;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { OnBuyMoreCallbackFn } from '../types';
3
+ import { OnManageClick } from '../CustomerPortalContainer';
3
4
  export declare type CustomerUsageDataProps = {
4
- onManageSubscription?: () => void;
5
+ onManageSubscription?: OnManageClick;
5
6
  onBuyMore?: OnBuyMoreCallbackFn;
6
7
  };
7
8
  export declare function CustomerUsageData({ onManageSubscription, onBuyMore }: CustomerUsageDataProps): JSX.Element | null;
@@ -2,10 +2,11 @@
2
2
  import { CustomerPortalEntitlement } from '@stigg/js-client-sdk';
3
3
  import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
4
4
  import { OnBuyMoreCallbackFn } from '../../types';
5
+ import { OnManageClick } from '../../CustomerPortalContainer';
5
6
  export declare type EntitlementCtaButtonProps = {
6
7
  entitlement: Exclude<CustomerPortalEntitlement, 'feature'>;
7
8
  feature: FeatureFragment;
8
- onManageSubscription: (() => void) | undefined;
9
+ onManageSubscription: OnManageClick | undefined;
9
10
  onBuyMore?: OnBuyMoreCallbackFn;
10
11
  canBuyMore: boolean;
11
12
  canUpgradeSubscription: boolean;
@@ -2,10 +2,11 @@
2
2
  import { CustomerPortalEntitlement } from '@stigg/js-client-sdk';
3
3
  import { CustomerPortalSubscriptionPriceFragment } from '@stigg/api-client-js/src/generated/sdk';
4
4
  import { OnBuyMoreCallbackFn } from '../../types';
5
+ import { OnManageClick } from '../../CustomerPortalContainer';
5
6
  export declare type UsageBoxProps = {
6
7
  entitlement: CustomerPortalEntitlement;
7
8
  subscriptionPrice: CustomerPortalSubscriptionPriceFragment | undefined;
8
- onManageSubscription: (() => void) | undefined;
9
+ onManageSubscription: OnManageClick | undefined;
9
10
  onBuyMore?: OnBuyMoreCallbackFn;
10
11
  hasCustomSubscription: boolean;
11
12
  canUpgradeSubscription: boolean;
@@ -1,3 +1,3 @@
1
1
  export { PaywallContainer as Paywall, PaywallContainerProps as PaywallProps } from './PaywallContainer';
2
- export { PaywallPlan, OnPlanSelectedCallbackFn, SubscribeIntentionType } from './types';
2
+ export * from './types';
3
3
  export { PaywallLocalization, PlanPriceText, CurrentPlanParams } from './paywallTextOverrides';
@@ -65,7 +65,12 @@ export declare function getResolvedPaywallLocalize(localizeOverride?: DeepPartia
65
65
  __typename?: "Money" | undefined;
66
66
  amount?: number | undefined;
67
67
  currency?: import("@stigg/js-client-sdk").Currency | undefined;
68
- } | undefined;
68
+ } | null | undefined;
69
+ flatPrice?: {
70
+ __typename?: "Money" | undefined;
71
+ amount?: number | undefined;
72
+ currency?: import("@stigg/js-client-sdk").Currency | undefined;
73
+ } | null | undefined;
69
74
  } | undefined)[] | null | undefined;
70
75
  tierUnits?: string | undefined;
71
76
  } | {} | undefined;
@@ -3,8 +3,10 @@ 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, perUnitQuantity?: number): number;
6
+ export declare function calculateTierPriceVolume(currentTier: PriceTierFragment, perUnitQuantity: number, selectedBillingPeriod?: BillingPeriod, shouldShowMonthlyPriceAmount?: boolean): number;
7
+ export declare function calculateTierPrice(price: Price, currentTier: PriceTierFragment, selectedBillingPeriod: BillingPeriod, shouldShowMonthlyPriceAmount: boolean, perUnitQuantity: number): number;
7
8
  export declare function getSelectedTierQuantityBeFeature(plan: PaywallPlan, billingPeriod: BillingPeriod, currentSubscription: Subscription | null): Record<string, number>;
9
+ export declare function hasTierWithUnitPrice(tiers: PriceTierFragment[] | null | undefined): boolean | undefined;
8
10
  export declare function getSelectedTier(plan: PaywallPlan, billingPeriod: BillingPeriod, currentSubscription: Subscription | null, selectedTierByFeature: Record<string, PriceTierFragment>, selectDefaultTierIndex?: SelectDefaultTierIndexFn): Record<string, PriceTierFragment>;
9
11
  export declare enum PriceTierComparison {
10
12
  Lower = -1,
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import './styles.css';
2
2
  export * from '@stigg/js-client-sdk';
3
- export { Paywall, PaywallProps, OnPlanSelectedCallbackFn, PaywallPlan, SubscribeIntentionType, PaywallLocalization, PlanPriceText, CurrentPlanParams, } from './components/paywall';
4
- export { CustomerPortalProvider, CustomerPortal, CustomerPortalProps, CustomerPortalSection, AddonsList, PaymentDetailsSection, InvoicesSection, CustomerUsageData, CustomerUsageDataProps, SubscriptionsOverview, SubscriptionsOverviewProps, Promotions, } from './components/customerPortal';
3
+ export { Paywall, PaywallProps, OnPlanSelectedCallbackFn, PaywallPlan, SubscribeIntentionType, PaywallLocalization, PlanPriceText, CurrentPlanParams, PaywallData, SelectDefaultTierIndexFn, ShouldHidePlanFn, } from './components/paywall';
4
+ export { CustomerPortalProvider, CustomerPortal, CustomerPortalProps, CustomerPortalSection, AddonsList, PaymentDetailsSection, InvoicesSection, CustomerUsageData, CustomerUsageDataProps, SubscriptionsOverview, SubscriptionsOverviewProps, Promotions, CustomerPortalIntentionType, OnBuyMoreCallbackFn, OnManageSubscriptionFn, CustomerPortalLocalization, CustomerPortalTheme, } 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';
7
7
  export { useWaitForCheckoutCompleted, ProvisionStatus } from './components/hooks';
8
- export { HorizontalAlignment, TextAlignment } from './theme/types';
8
+ export { HorizontalAlignment, TextAlignment, FontVariant, FontWeight, StiggTheme } from './theme/types';
9
9
  export { CustomizedTheme as Theme } from './theme/Theme';