@stigg/react-sdk 4.3.0-beta.1 → 4.3.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 (169) hide show
  1. package/README.md +1 -1
  2. package/dist/components/common/Icon.d.ts +2 -3
  3. package/dist/components/common/PoweredByStigg.d.ts +1 -1
  4. package/dist/components/common/customIcons.d.ts +5 -17
  5. package/dist/components/common/mapExternalTheme.d.ts +1 -2
  6. package/dist/components/customerPortal/subscriptionOverview/tabs/SubscriptionTabs.d.ts +1 -1
  7. package/dist/components/{common/TiersSelectContainer.d.ts → paywall/TiersLayout.d.ts} +3 -2
  8. package/dist/components/paywall/paywallTextOverrides.d.ts +2 -0
  9. package/dist/components/{utils/priceTierUtils.d.ts → paywall/planPriceTier.d.ts} +1 -3
  10. package/dist/components/utils/calculateDiscountRate.d.ts +0 -1
  11. package/dist/components/utils/currencyUtils.d.ts +1 -1
  12. package/dist/index.d.ts +0 -1
  13. package/dist/react-sdk.cjs.development.js +207 -3479
  14. package/dist/react-sdk.cjs.development.js.map +1 -1
  15. package/dist/react-sdk.cjs.production.min.js +1 -1
  16. package/dist/react-sdk.cjs.production.min.js.map +1 -1
  17. package/dist/react-sdk.esm.js +213 -3619
  18. package/dist/react-sdk.esm.js.map +1 -1
  19. package/dist/stories/CustomerPortal.stories.d.ts +1 -1
  20. package/dist/theme/getResolvedTheme.d.ts +0 -1
  21. package/dist/theme/types.d.ts +0 -1
  22. package/package.json +22 -11
  23. package/src/components/StiggProvider.tsx +2 -0
  24. package/src/components/common/Icon.tsx +22 -17
  25. package/src/components/common/PoweredByStigg.tsx +1 -1
  26. package/src/components/common/Typography.tsx +1 -11
  27. package/src/components/common/customIcons.ts +28 -17
  28. package/src/components/common/mapExternalTheme.ts +8 -24
  29. package/src/components/customerPortal/subscriptionOverview/tabs/SubscriptionTabs.tsx +12 -6
  30. package/src/components/paywall/Paywall.tsx +1 -1
  31. package/src/components/paywall/PlanOffering.tsx +1 -1
  32. package/src/components/paywall/PlanOfferingButton.tsx +1 -1
  33. package/src/components/paywall/PlanPrice.tsx +13 -5
  34. package/src/components/{common/TiersSelectContainer.tsx → paywall/TiersLayout.tsx} +7 -8
  35. package/src/components/paywall/paywallTextOverrides.ts +1 -0
  36. package/src/components/{utils/priceTierUtils.ts → paywall/planPriceTier.ts} +3 -25
  37. package/src/components/paywall/utils/calculateUnitQuantityText.ts +4 -9
  38. package/src/components/utils/calculateDiscountRate.ts +1 -1
  39. package/src/components/utils/currencyUtils.ts +1 -1
  40. package/src/components/utils/getPaidPriceText.ts +2 -2
  41. package/src/index.ts +0 -1
  42. package/src/stories/CustomerPortal.stories.tsx +12 -12
  43. package/src/stories/Paywall.stories.tsx +4 -6
  44. package/src/stories/baseArgs.ts +1 -1
  45. package/src/theme/Fonts.tsx +1 -1
  46. package/src/theme/Theme.tsx +7 -9
  47. package/src/theme/getResolvedTheme.ts +0 -1
  48. package/src/theme/types.ts +0 -1
  49. package/dist/components/checkout/Checkout.d.ts +0 -5
  50. package/dist/components/checkout/CheckoutContainer.d.ts +0 -22
  51. package/dist/components/checkout/CheckoutContainer.style.d.ts +0 -26
  52. package/dist/components/checkout/CheckoutProvider.d.ts +0 -35
  53. package/dist/components/checkout/CheckoutSummary.d.ts +0 -9
  54. package/dist/components/checkout/components/Button.d.ts +0 -6
  55. package/dist/components/checkout/components/InputField.d.ts +0 -8
  56. package/dist/components/checkout/components/index.d.ts +0 -2
  57. package/dist/components/checkout/formatting.d.ts +0 -2
  58. package/dist/components/checkout/hooks/index.d.ts +0 -8
  59. package/dist/components/checkout/hooks/useAddonsStepModel.d.ts +0 -21
  60. package/dist/components/checkout/hooks/useCheckoutModel.d.ts +0 -9
  61. package/dist/components/checkout/hooks/useCouponModel.d.ts +0 -7
  62. package/dist/components/checkout/hooks/useLoadCheckout.d.ts +0 -11
  63. package/dist/components/checkout/hooks/usePaymentStepModel.d.ts +0 -16
  64. package/dist/components/checkout/hooks/usePlanStepModel.d.ts +0 -23
  65. package/dist/components/checkout/hooks/usePreviewSubscription.d.ts +0 -13
  66. package/dist/components/checkout/hooks/useProgressBarModel.d.ts +0 -26
  67. package/dist/components/checkout/hooks/useSubscriptionModel.d.ts +0 -5
  68. package/dist/components/checkout/hooks/useSubscriptionState.d.ts +0 -2
  69. package/dist/components/checkout/index.d.ts +0 -3
  70. package/dist/components/checkout/planHeader/PlanHeader.d.ts +0 -7
  71. package/dist/components/checkout/planHeader/PlanHeader.style.d.ts +0 -25
  72. package/dist/components/checkout/planHeader/index.d.ts +0 -1
  73. package/dist/components/checkout/progressBar/CheckoutProgressBar.d.ts +0 -2
  74. package/dist/components/checkout/progressBar/CheckoutProgressBar.style.d.ts +0 -45
  75. package/dist/components/checkout/promotionCode/AddPromotionCode.d.ts +0 -5
  76. package/dist/components/checkout/promotionCode/AddPromotionCodeButton.d.ts +0 -7
  77. package/dist/components/checkout/promotionCode/AppliedPromotionCode.d.ts +0 -6
  78. package/dist/components/checkout/promotionCode/PromotionCodeSection.d.ts +0 -5
  79. package/dist/components/checkout/promotionCode/index.d.ts +0 -1
  80. package/dist/components/checkout/steps/addons/CheckoutAddonsStep.d.ts +0 -2
  81. package/dist/components/checkout/steps/addons/CheckoutAddonsStep.style.d.ts +0 -93
  82. package/dist/components/checkout/steps/addons/addon.utils.d.ts +0 -15
  83. package/dist/components/checkout/steps/addons/index.d.ts +0 -1
  84. package/dist/components/checkout/steps/payment/PaymentMethods.d.ts +0 -19
  85. package/dist/components/checkout/steps/payment/PaymentMethods.style.d.ts +0 -113
  86. package/dist/components/checkout/steps/payment/PaymentStep.d.ts +0 -2
  87. package/dist/components/checkout/steps/payment/index.d.ts +0 -1
  88. package/dist/components/checkout/steps/payment/stripe/StripePaymentForm.d.ts +0 -2
  89. package/dist/components/checkout/steps/payment/stripe/index.d.ts +0 -3
  90. package/dist/components/checkout/steps/payment/stripe/stripe.utils.d.ts +0 -33
  91. package/dist/components/checkout/steps/payment/stripe/useStripeIntegration.d.ts +0 -5
  92. package/dist/components/checkout/steps/payment/stripe/useSubmit.d.ts +0 -10
  93. package/dist/components/checkout/steps/plan/BillingPeriodPicker.d.ts +0 -9
  94. package/dist/components/checkout/steps/plan/BillingPeriodPicker.style.d.ts +0 -52
  95. package/dist/components/checkout/steps/plan/CheckoutChargeList.d.ts +0 -16
  96. package/dist/components/checkout/steps/plan/CheckoutPlanStep.d.ts +0 -4
  97. package/dist/components/checkout/steps/plan/CheckoutPlanStep.style.d.ts +0 -12
  98. package/dist/components/checkout/steps/plan/index.d.ts +0 -1
  99. package/dist/components/checkout/steps/surprise/SurpriseStep.d.ts +0 -2
  100. package/dist/components/checkout/textOverrides.d.ts +0 -28
  101. package/dist/components/checkout/theme.d.ts +0 -12
  102. package/dist/components/hooks/useChargeSort.d.ts +0 -3
  103. package/dist/components/utils/priceUtils.d.ts +0 -2
  104. package/dist/stories/Checkout.stories.d.ts +0 -3
  105. package/src/assets/arrow-forward.svg +0 -3
  106. package/src/assets/arrow-right.svg +0 -6
  107. package/src/assets/close.svg +0 -3
  108. package/src/assets/nyancat.svg +0 -634
  109. package/src/assets/outlined-checked-circle.svg +0 -6
  110. package/src/assets/outlined-circle.svg +0 -3
  111. package/src/assets/payment-method.svg +0 -11
  112. package/src/assets/plus-icon.svg +0 -6
  113. package/src/assets/trash.svg +0 -8
  114. package/src/components/checkout/Checkout.tsx +0 -30
  115. package/src/components/checkout/CheckoutContainer.style.ts +0 -34
  116. package/src/components/checkout/CheckoutContainer.tsx +0 -88
  117. package/src/components/checkout/CheckoutProvider.tsx +0 -140
  118. package/src/components/checkout/CheckoutSummary.tsx +0 -361
  119. package/src/components/checkout/components/Button.tsx +0 -30
  120. package/src/components/checkout/components/InputField.tsx +0 -22
  121. package/src/components/checkout/components/index.ts +0 -2
  122. package/src/components/checkout/formatting.ts +0 -12
  123. package/src/components/checkout/hooks/index.ts +0 -8
  124. package/src/components/checkout/hooks/useAddonsStepModel.ts +0 -96
  125. package/src/components/checkout/hooks/useCheckoutModel.ts +0 -31
  126. package/src/components/checkout/hooks/useCouponModel.ts +0 -28
  127. package/src/components/checkout/hooks/useLoadCheckout.ts +0 -40
  128. package/src/components/checkout/hooks/usePaymentStepModel.ts +0 -49
  129. package/src/components/checkout/hooks/usePlanStepModel.ts +0 -170
  130. package/src/components/checkout/hooks/usePreviewSubscription.ts +0 -82
  131. package/src/components/checkout/hooks/useProgressBarModel.ts +0 -89
  132. package/src/components/checkout/hooks/useSubscriptionModel.ts +0 -16
  133. package/src/components/checkout/hooks/useSubscriptionState.ts +0 -26
  134. package/src/components/checkout/index.ts +0 -3
  135. package/src/components/checkout/planHeader/PlanHeader.style.tsx +0 -23
  136. package/src/components/checkout/planHeader/PlanHeader.tsx +0 -61
  137. package/src/components/checkout/planHeader/index.ts +0 -1
  138. package/src/components/checkout/progressBar/CheckoutProgressBar.style.ts +0 -29
  139. package/src/components/checkout/progressBar/CheckoutProgressBar.tsx +0 -48
  140. package/src/components/checkout/promotionCode/AddPromotionCode.tsx +0 -85
  141. package/src/components/checkout/promotionCode/AddPromotionCodeButton.tsx +0 -39
  142. package/src/components/checkout/promotionCode/AppliedPromotionCode.tsx +0 -37
  143. package/src/components/checkout/promotionCode/PromotionCodeSection.tsx +0 -27
  144. package/src/components/checkout/promotionCode/index.ts +0 -1
  145. package/src/components/checkout/steps/addons/CheckoutAddonsStep.style.tsx +0 -24
  146. package/src/components/checkout/steps/addons/CheckoutAddonsStep.tsx +0 -125
  147. package/src/components/checkout/steps/addons/addon.utils.ts +0 -68
  148. package/src/components/checkout/steps/addons/index.ts +0 -1
  149. package/src/components/checkout/steps/payment/PaymentMethods.style.ts +0 -26
  150. package/src/components/checkout/steps/payment/PaymentMethods.tsx +0 -83
  151. package/src/components/checkout/steps/payment/PaymentStep.tsx +0 -41
  152. package/src/components/checkout/steps/payment/index.ts +0 -1
  153. package/src/components/checkout/steps/payment/stripe/StripePaymentForm.tsx +0 -43
  154. package/src/components/checkout/steps/payment/stripe/index.ts +0 -3
  155. package/src/components/checkout/steps/payment/stripe/stripe.utils.ts +0 -109
  156. package/src/components/checkout/steps/payment/stripe/useStripeIntegration.ts +0 -27
  157. package/src/components/checkout/steps/payment/stripe/useSubmit.ts +0 -100
  158. package/src/components/checkout/steps/plan/BillingPeriodPicker.style.tsx +0 -46
  159. package/src/components/checkout/steps/plan/BillingPeriodPicker.tsx +0 -63
  160. package/src/components/checkout/steps/plan/CheckoutChargeList.tsx +0 -138
  161. package/src/components/checkout/steps/plan/CheckoutPlanStep.style.tsx +0 -6
  162. package/src/components/checkout/steps/plan/CheckoutPlanStep.tsx +0 -22
  163. package/src/components/checkout/steps/plan/index.ts +0 -1
  164. package/src/components/checkout/steps/surprise/SurpriseStep.tsx +0 -27
  165. package/src/components/checkout/textOverrides.ts +0 -58
  166. package/src/components/checkout/theme.ts +0 -43
  167. package/src/components/hooks/useChargeSort.ts +0 -17
  168. package/src/components/utils/priceUtils.ts +0 -10
  169. package/src/stories/Checkout.stories.tsx +0 -62
@@ -1,4 +1,4 @@
1
- declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react").ReactFramework, import("..").CustomerPortalProps>;
1
+ declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react").ReactFramework, import("..").PaywallProps>;
2
2
  export default _default;
3
3
  export declare const DefaultCustomerPortal: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, any>;
4
4
  export declare const CustomerPortalTheming: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, any>;
@@ -3,7 +3,6 @@ export declare const flexLayoutMapper: (horizontalAlignment: HorizontalAlignment
3
3
  export declare const getResolvedTheme: (customizedTheme?: {
4
4
  palette?: {
5
5
  primary?: string | undefined;
6
- primaryDark?: string | undefined;
7
6
  backgroundPaper?: string | undefined;
8
7
  backgroundHighlight?: string | undefined;
9
8
  backgroundSection?: string | undefined;
@@ -8,7 +8,6 @@ export declare type FontVariant = {
8
8
  export declare type StiggTheme = {
9
9
  palette: {
10
10
  primary: string;
11
- primaryDark: string;
12
11
  backgroundPaper: string;
13
12
  backgroundHighlight: string;
14
13
  backgroundSection: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.3.0-beta.1",
2
+ "version": "4.3.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -14,10 +14,10 @@
14
14
  "start": "tsdx watch",
15
15
  "build": "tsdx build",
16
16
  "test": "tsdx test --passWithNoTests",
17
- "lint": "tsdx lint",
17
+ "lint": "eslint src/**/*.{ts,tsx} --fix --max-warnings=0",
18
18
  "size": "size-limit",
19
19
  "analyze": "size-limit --why",
20
- "storybook": "export NODE_OPTIONS=--openssl-legacy-provider && start-storybook -p 6006",
20
+ "storybook": "start-storybook -p 6006",
21
21
  "build-storybook": "build-storybook",
22
22
  "docs": "typedoc",
23
23
  "link-sdk": "yarn link && cd node_modules/react && yarn link && cd ../../node_modules/react-dom && yarn link && cd ../../",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "husky": {
30
30
  "hooks": {
31
- "pre-commit": "tsdx lint"
31
+ "pre-commit": "yarn lint"
32
32
  }
33
33
  },
34
34
  "name": "@stigg/react-sdk",
@@ -50,7 +50,6 @@
50
50
  "@commitlint/config-conventional": "^17.0.3",
51
51
  "@rollup/plugin-image": "^2.1.1",
52
52
  "@size-limit/preset-small-lib": "^7.0.8",
53
- "@stigg/eslint-config-stigg": "^0.0.7",
54
53
  "@storybook/addon-actions": "^6.5.9",
55
54
  "@storybook/addon-essentials": "^6.5.9",
56
55
  "@storybook/addon-interactions": "^6.5.9",
@@ -79,20 +78,32 @@
79
78
  "tsdx": "^0.14.1",
80
79
  "tslib": "^2.4.0",
81
80
  "typedoc": "^0.23.7",
82
- "typescript": "^4.6.3"
81
+ "typescript": "^4.6.3",
82
+ "prettier": "^3.0.2",
83
+ "eslint": "^7.11.0",
84
+ "@stigg/eslint-config-stigg": "^0.0.7",
85
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
86
+ "@typescript-eslint/parser": "^5.0.0",
87
+ "eslint-config-airbnb": "^18.0.4",
88
+ "eslint-config-airbnb-typescript": "^16.1.0",
89
+ "eslint-config-prettier": "^8.3.0",
90
+ "eslint-plugin-jsx-a11y": "^6.3.1",
91
+ "eslint-plugin-import": "^2.28.1",
92
+ "eslint-plugin-jest": "^25.3.2",
93
+ "eslint-plugin-prettier": "^5.0.0",
94
+ "eslint-plugin-react": "^7.28.0",
95
+ "eslint-plugin-react-hooks": "^4.2.0",
96
+ "eslint-plugin-unused-imports": "^2.0.0"
83
97
  },
84
98
  "dependencies": {
85
99
  "@emotion/react": "^11.10.5",
86
100
  "@emotion/styled": "^11.10.5",
87
101
  "@mui/material": "^5.10.13",
88
- "@stigg/js-client-sdk": "2.19.1",
89
- "@stripe/react-stripe-js": "^2.1.1",
90
- "@stripe/stripe-js": "^1.54.1",
102
+ "@stigg/js-client-sdk": "2.18.1",
91
103
  "@types/styled-components": "^5.1.26",
92
104
  "classnames": "^2.3.2",
93
105
  "color": "^4.2.3",
94
106
  "currency-symbol-map": "^5.1.0",
95
- "immer": "^10.0.2",
96
107
  "lodash": "^4.17.21",
97
108
  "lodash-es": "^4.17.21",
98
109
  "moment": "^2.29.4",
@@ -104,5 +115,5 @@
104
115
  "styled-typography": "^1.0.3"
105
116
  },
106
117
  "readme": "ERROR: No README data found!",
107
- "_id": "@stigg/react-sdk@1.0.0"
118
+ "_id": "@stigg/react-sdk@0.18.0"
108
119
  }
@@ -128,6 +128,7 @@ export const StiggProvider: React.FC<PropsWithChildren<StiggProviderProps>> = ({
128
128
  ctx.stigg.removeListener('entitlementsUpdated', onEntitlementsUpdated);
129
129
  ctx.stigg.clearCustomer();
130
130
  };
131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
131
132
  }, [apiKey]);
132
133
 
133
134
  useEffect(() => {
@@ -137,6 +138,7 @@ export const StiggProvider: React.FC<PropsWithChildren<StiggProviderProps>> = ({
137
138
  } else {
138
139
  stiggClient.clearCustomer();
139
140
  }
141
+ // eslint-disable-next-line react-hooks/exhaustive-deps
140
142
  }, [customerId, customerToken, resourceId]);
141
143
 
142
144
  useEffect(() => {
@@ -2,14 +2,12 @@ import React from 'react';
2
2
  import styled from '@emotion/styled/macro';
3
3
  import { CSSProperties } from 'react';
4
4
  import { css, Theme, useTheme } from '@emotion/react';
5
+ import { ICON_COMPONENTS, Icons } from './customIcons';
5
6
  import { getIconColor, IconColor } from './iconColor';
6
- import * as customIcons from './customIcons';
7
7
 
8
- export type Icons = keyof typeof customIcons;
9
-
10
- const IconWrapper = styled.div<{ $pathColor?: string; $rectColor?: string; $strokeColor?: string }>`
8
+ const IconWrapper = styled.div<{ $pathColor?: string, $rectColor?: string; $strokeColor?: string }>`
11
9
  ${({ $pathColor }) =>
12
- $pathColor &&
10
+ $pathColor &&
13
11
  css`
14
12
  path {
15
13
  fill: ${$pathColor};
@@ -17,20 +15,20 @@ const IconWrapper = styled.div<{ $pathColor?: string; $rectColor?: string; $stro
17
15
  `}
18
16
 
19
17
  ${({ $rectColor }) =>
20
- $rectColor &&
21
- css`
22
- svg rect {
23
- fill: ${$rectColor};
24
- }
18
+ $rectColor &&
19
+ css`
20
+ svg rect {
21
+ fill: ${$rectColor};
22
+ }
25
23
  `}
26
24
 
27
25
 
28
26
  ${({ $strokeColor }) =>
29
- $strokeColor &&
30
- css`
31
- g {
32
- stroke: ${$strokeColor};
33
- }
27
+ $strokeColor &&
28
+ css`
29
+ g {
30
+ stroke: ${$strokeColor};
31
+ }
34
32
  `}
35
33
  `;
36
34
 
@@ -43,8 +41,15 @@ export type IconProps = {
43
41
  svgStrokeColor?: IconColor | string;
44
42
  };
45
43
 
46
- export function Icon({ icon, className, style, svgPathColor, svgRectColor, svgStrokeColor }: IconProps) {
47
- const IconComponent = (customIcons as any)[icon];
44
+ export function Icon({
45
+ icon,
46
+ className,
47
+ style,
48
+ svgPathColor,
49
+ svgRectColor,
50
+ svgStrokeColor,
51
+ }: IconProps) {
52
+ const IconComponent = ICON_COMPONENTS[icon];
48
53
  const theme = useTheme() as Theme;
49
54
 
50
55
  return (
@@ -4,7 +4,7 @@ import styled from '@emotion/styled/macro';
4
4
 
5
5
  export const STIGG_WATERMARK_CLASSNAME = 'stigg-watermark';
6
6
 
7
- export type PoweredByStiggSources = 'paywall' | 'customer_portal' | 'checkout';
7
+ export type PoweredByStiggSources = 'paywall' | 'customer_portal';
8
8
 
9
9
  const PoweredByStiggThemedSvg = styled(PoweredByStiggSvg)`
10
10
  * {
@@ -86,17 +86,7 @@ function getFontWeight(theme: Theme, variant: TypographyProps['variant']) {
86
86
  }
87
87
 
88
88
  export const Typography = forwardRef((props: TypographyProps, ref) => {
89
- const {
90
- children,
91
- span,
92
- style,
93
- fontWeight,
94
- variant = 'body1',
95
- color = 'primary',
96
- overrideColor,
97
- bold,
98
- ...rest
99
- } = props;
89
+ const { children, span, style, fontWeight, variant = 'body1', color = 'primary', overrideColor, bold, ...rest } = props;
100
90
  const theme = useTheme() as Theme;
101
91
  const level = getLevel(variant);
102
92
  const levelClassName = `typography-level-${level}`;
@@ -1,17 +1,28 @@
1
- export { default as Addons } from '../../assets/addons.svg';
2
- export { default as BillingInfoCustomer } from '../../assets/billing-info-customer.svg';
3
- export { default as ContactSupport } from '../../assets/contact-support.svg';
4
- export { default as CreditCard } from '../../assets/credit-card.svg';
5
- export { default as DollarCoin } from '../../assets/dollar-coin.svg';
6
- export { default as MiniSchedule } from '../../assets/mini-schedule.svg';
7
- export { default as Promotions } from '../../assets/promotions.svg';
8
- export { default as Restore } from '../../assets/restore.svg';
9
- export { default as ScheduleBox } from '../../assets/schedule-box.svg';
10
- export { default as ScheduleClock } from '../../assets/schedule.svg';
11
- export { default as RenewSubscription } from '../../assets/subscription-renews-icon.svg';
12
- export { default as Trash } from '../../assets/trash.svg';
13
- export { default as PaymentMethod } from '../../assets/payment-method.svg';
14
- export { default as OutlinedCircle } from '../../assets/outlined-circle.svg';
15
- export { default as OutlinedCheckedCircle } from '../../assets/outlined-checked-circle.svg';
16
- export { default as ArrowForward } from '../../assets/arrow-forward.svg';
17
- export { default as Close } from '../../assets/close.svg';
1
+ import { ReactElement, SVGProps } from 'react';
2
+ import RenewSubscription from '../../assets/subscription-renews-icon.svg';
3
+ import BillingInfoCustomer from '../../assets/billing-info-customer.svg';
4
+ import CreditCard from '../../assets/credit-card.svg';
5
+ import ScheduleBox from '../../assets/schedule-box.svg';
6
+ import ScheduleClock from '../../assets/schedule.svg';
7
+ import Restore from '../../assets/restore.svg';
8
+ import MiniSchedule from '../../assets/mini-schedule.svg';
9
+ import DollarCoin from '../../assets/dollar-coin.svg';
10
+ import Promotions from '../../assets/promotions.svg';
11
+ import Addons from '../../assets/addons.svg';
12
+ import ContactSupport from '../../assets/contact-support.svg';
13
+
14
+ export const ICON_COMPONENTS: {[name: string]: ((props: SVGProps<SVGElement>) => ReactElement)} = {
15
+ RenewSubscription,
16
+ BillingInfoCustomer,
17
+ CreditCard,
18
+ ScheduleBox,
19
+ ScheduleClock,
20
+ Restore,
21
+ MiniSchedule,
22
+ DollarCoin,
23
+ Promotions,
24
+ Addons,
25
+ ContactSupport,
26
+ };
27
+
28
+ export type Icons = keyof typeof ICON_COMPONENTS;
@@ -1,10 +1,8 @@
1
1
  import {
2
2
  Alignment,
3
- CheckoutConfiguration,
4
3
  CustomerPortalConfiguration,
5
4
  FontWeight as JSFontWeight,
6
5
  PaywallConfiguration,
7
- TypographyConfiguration,
8
6
  } from '@stigg/js-client-sdk';
9
7
  import { CustomizedTheme } from '../../theme/Theme';
10
8
  import { HorizontalAlignment, FontWeight } from '../../theme/types';
@@ -31,7 +29,10 @@ function mapFontWeight(defaultValue: FontWeight, fontWeight?: JSFontWeight | nul
31
29
  }
32
30
  }
33
31
 
34
- function mapTypography(typography?: TypographyConfiguration | null): CustomizedTheme['typography'] {
32
+ function mapTypography(
33
+ configuration: CustomerPortalConfiguration | PaywallConfiguration,
34
+ ): CustomizedTheme['typography'] {
35
+ const { typography } = configuration;
35
36
  return {
36
37
  fontFamilyUrl: typography?.fontFamily || undefined,
37
38
  h1: {
@@ -68,7 +69,7 @@ function mapAlignment(alignment?: Alignment | null): HorizontalAlignment | undef
68
69
  }
69
70
 
70
71
  export function mapCustomerPortalConfiguration(configuration: CustomerPortalConfiguration): CustomizedTheme {
71
- const { palette, typography } = configuration;
72
+ const { palette } = configuration;
72
73
  return {
73
74
  palette: {
74
75
  primary: palette?.primary || undefined,
@@ -79,12 +80,12 @@ export function mapCustomerPortalConfiguration(configuration: CustomerPortalConf
79
80
  primary: palette?.textColor || undefined,
80
81
  },
81
82
  },
82
- typography: mapTypography(typography),
83
+ typography: mapTypography(configuration),
83
84
  };
84
85
  }
85
86
 
86
87
  export function mapPaywallConfiguration(paywallConfiguration: PaywallConfiguration): CustomizedTheme {
87
- const { palette, layout, customCss, typography } = paywallConfiguration;
88
+ const { palette, layout, customCss } = paywallConfiguration;
88
89
  return {
89
90
  customCss: customCss || undefined,
90
91
  palette: {
@@ -96,7 +97,7 @@ export function mapPaywallConfiguration(paywallConfiguration: PaywallConfigurati
96
97
  primary: palette?.textColor || undefined,
97
98
  },
98
99
  },
99
- typography: mapTypography(typography),
100
+ typography: mapTypography(paywallConfiguration),
100
101
  layout: {
101
102
  ctaAlignment: mapAlignment(layout?.alignment),
102
103
  headerAlignment: mapAlignment(layout?.alignment),
@@ -108,20 +109,3 @@ export function mapPaywallConfiguration(paywallConfiguration: PaywallConfigurati
108
109
  },
109
110
  };
110
111
  }
111
-
112
- export function mapCheckoutConfiguration(configuration: CheckoutConfiguration): CustomizedTheme {
113
- const { palette, typography } = configuration;
114
- return {
115
- palette: {
116
- primary: palette?.primary || undefined,
117
- backgroundPaper: palette?.backgroundColor || undefined,
118
- outlinedBorder: palette?.borderColor || undefined,
119
- text: {
120
- primary: palette?.textColor || undefined,
121
- },
122
- backgroundHighlight: palette?.selectionColor || undefined,
123
- backgroundSection: palette?.summaryBackgroundColor || undefined,
124
- },
125
- typography: mapTypography(typography),
126
- };
127
- }
@@ -10,7 +10,8 @@ import { CustomerPortalSection } from '../../CustomerPortal';
10
10
  import { CustomerPortalLocalization } from '../../customerPortalTextOverrides';
11
11
  import { StyledTabs, TabContent, TabsLayout } from './SubscriptionTabs.style';
12
12
  import { CustomerPortalTheme } from '../../customerPortalTheme';
13
- import { Icon, Icons } from '../../../common/Icon';
13
+ import { Icon } from '../../../common/Icon';
14
+ import { Icons } from '../../../common/customIcons';
14
15
  import { FontWeight } from 'styled-typography';
15
16
 
16
17
  type TabPanelProps = {
@@ -40,16 +41,21 @@ export type SubscriptionTabsProps = {
40
41
  function TabTitle({ isSelected, label, icon }: { isSelected: boolean; label: string; icon: Icons }) {
41
42
  const color = isSelected ? 'primary' : 'secondary';
42
43
  return (
43
- <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
44
+ <div style={{display: 'flex', gap: 8, alignItems: 'center' }}>
44
45
  <Icon icon={icon} svgStrokeColor={color} />
45
- <Typography variant="h6" bold={isSelected} fontWeight={FontWeight.Medium} color={color}>
46
+ <Typography variant="h6" bold={isSelected} fontWeight={FontWeight.Medium} color={color}>
46
47
  {label}
47
48
  </Typography>
48
49
  </div>
49
50
  );
50
51
  }
51
52
 
52
- export function SubscriptionTabs({ customerPortal, hiddenSections, textOverrides, theme }: SubscriptionTabsProps) {
53
+ export function SubscriptionTabs({
54
+ customerPortal,
55
+ hiddenSections,
56
+ textOverrides,
57
+ theme,
58
+ }: SubscriptionTabsProps) {
53
59
  const allAddons = flatMap(customerPortal.subscriptions, subscription => subscription.addons);
54
60
  const isSectionHidden = (sectionName: CustomerPortalSection) =>
55
61
  hiddenSections?.some(section => section === sectionName);
@@ -75,14 +81,14 @@ export function SubscriptionTabs({ customerPortal, hiddenSections, textOverrides
75
81
  <Tab
76
82
  sx={{ textTransform: 'none' }}
77
83
  value={1}
78
- label={<TabTitle isSelected={value === 1} label={textOverrides.addonsTabTitle} icon="Addons" />}
84
+ label={<TabTitle isSelected={value === 1} label={textOverrides.addonsTabTitle} icon='Addons' />}
79
85
  />
80
86
  ) : null}
81
87
  {showPromotions ? (
82
88
  <Tab
83
89
  sx={{ textTransform: 'none' }}
84
90
  value={2}
85
- label={<TabTitle isSelected={value === 2} label={textOverrides.promotionsTabTitle} icon="Promotions" />}
91
+ label={<TabTitle isSelected={value === 2} label={textOverrides.promotionsTabTitle} icon='Promotions' />}
86
92
  />
87
93
  ) : null}
88
94
  </StyledTabs>
@@ -11,7 +11,7 @@ import { useStiggContext } from '../..';
11
11
  import { hasPricePointsForPlans } from './utils/hasPricePoints';
12
12
  import { getPlansToDisplay } from './utils/getPlansToDisplay';
13
13
  import { getPlanPrice } from '../utils/getPlanPrice';
14
- import { getSelectedTier } from '../utils/priceTierUtils';
14
+ import { getSelectedTier } from './planPriceTier';
15
15
 
16
16
  const PaywallPlansContainer = styled.div`
17
17
  color: ${({ theme }) => theme.stigg.palette.text.primary};
@@ -11,7 +11,7 @@ import classNames from 'classnames';
11
11
  import { Grid } from '@mui/material';
12
12
  import MiniSchedule from '../../assets/mini-schedule.svg';
13
13
  import { PlanPrice } from './PlanPrice';
14
- import { getSelectedTier } from '../utils/priceTierUtils';
14
+ import { getSelectedTier } from './planPriceTier';
15
15
 
16
16
  const PlanOfferingContainer = styled.div<{ $isHighlighted: boolean; $isCurrentPlan: boolean }>`
17
17
  position: relative;
@@ -9,7 +9,7 @@ import ClipLoader from 'react-spinners/ClipLoader';
9
9
  import { Typography } from '../common/Typography';
10
10
  import { getSubscriptionScheduleUpdateTexts } from '../utils/getSubscriptionScheduleUpdateTexts';
11
11
  import { isFunction } from 'lodash';
12
- import { compareSelectedTierToCurrentTier, PriceTierComparison } from '../utils/priceTierUtils';
12
+ import { compareSelectedTierToCurrentTier, PriceTierComparison } from './planPriceTier';
13
13
 
14
14
  const LoadingIndicator = styled(ClipLoader)`
15
15
  margin-left: 10px;
@@ -5,7 +5,7 @@ import { Typography } from '../common/Typography';
5
5
  import React, { useEffect, useState } from 'react';
6
6
  import styled from '@emotion/styled/macro';
7
7
  import { BillingPeriod, PriceTierFragment } from '@stigg/js-client-sdk';
8
- import { TiersSelectContainer } from '../common/TiersSelectContainer';
8
+ import { TiersLayout } from './TiersLayout';
9
9
 
10
10
  const EMPTY_CHAR = '‎';
11
11
 
@@ -28,14 +28,21 @@ type PriceBillingPeriodProps = {
28
28
  billingPeriod: BillingPeriod;
29
29
  hasMonthlyPrice: boolean;
30
30
  hasAnnuallyPrice: boolean;
31
+ paywallLocale: PaywallLocalization;
31
32
  };
32
33
 
33
- function PriceBillingPeriod({ plan, billingPeriod, hasMonthlyPrice, hasAnnuallyPrice }: PriceBillingPeriodProps) {
34
+ function PriceBillingPeriod({
35
+ plan,
36
+ billingPeriod,
37
+ hasMonthlyPrice,
38
+ hasAnnuallyPrice,
39
+ paywallLocale,
40
+ }: PriceBillingPeriodProps) {
34
41
  const hasPrice = plan.pricePoints.find(pricePoint => pricePoint.billingPeriod === billingPeriod);
35
42
 
36
43
  let content = EMPTY_CHAR;
37
44
  if (hasPrice && hasMonthlyPrice && hasAnnuallyPrice) {
38
- content = `, billed ${billingPeriod.toLowerCase()}`;
45
+ content = paywallLocale.price.billingPeriod?.(billingPeriod) || `, billed ${billingPeriod.toLowerCase()}`;
39
46
  }
40
47
 
41
48
  return (
@@ -133,13 +140,14 @@ export const PlanPrice = ({
133
140
  billingPeriod={billingPeriod}
134
141
  hasAnnuallyPrice={hasAnnuallyPrice}
135
142
  hasMonthlyPrice={hasMonthlyPrice}
143
+ paywallLocale={paywallLocale}
136
144
  />
137
145
  </Typography>
138
146
  )}
139
147
 
140
148
  {withTiersRow && (
141
- <TiersSelectContainer
142
- componentId={`${plan.id}_${featureId}_tier`}
149
+ <TiersLayout
150
+ plan={plan}
143
151
  tiers={tiers}
144
152
  tierUnits={tierUnits}
145
153
  selectedTier={selectedTier}
@@ -1,10 +1,10 @@
1
+ import { PaywallPlan } from './types';
1
2
  import { PriceTierFragment } from '@stigg/js-client-sdk';
2
3
  import { MenuItem, OutlinedInput, Select, SelectChangeEvent } from '@mui/material';
3
4
  import { Typography } from '../common/Typography';
4
5
  import { map } from 'lodash';
5
6
  import React, { ReactNode } from 'react';
6
7
  import styled from '@emotion/styled/macro';
7
- import { getTierByQuantity } from '../utils/priceTierUtils';
8
8
 
9
9
  const TierSelect = styled(Select)`
10
10
  border-radius: 10px;
@@ -24,33 +24,32 @@ const TierInput = styled(OutlinedInput)`
24
24
  }
25
25
  `;
26
26
 
27
- export function TiersSelectContainer({
28
- componentId,
27
+ export function TiersLayout({
28
+ plan,
29
29
  tiers,
30
30
  tierUnits,
31
31
  selectedTier,
32
32
  handleTierChange,
33
33
  }: {
34
- componentId: string;
34
+ plan: PaywallPlan;
35
35
  tiers?: PriceTierFragment[] | null;
36
36
  tierUnits?: string;
37
37
  selectedTier?: PriceTierFragment;
38
38
  handleTierChange: (tier: PriceTierFragment) => void;
39
39
  }) {
40
40
  const handleChange = (event: SelectChangeEvent<unknown>, _: ReactNode) => {
41
- if (!tiers) return;
42
-
43
- handleTierChange(getTierByQuantity(tiers, event.target.value as number)!);
41
+ handleTierChange(tiers!.find(tier => tier.upTo.toString() === event.target.value)!);
44
42
  };
45
43
 
46
44
  return (
47
45
  <Typography className="stigg-price-tier-select" style={{ minHeight: '46px' }}>
48
46
  {tiers ? (
49
47
  <TierSelect
48
+ labelId="demo-simple-select-label"
49
+ id={`select_${plan.id}`}
50
50
  value={selectedTier ? selectedTier.upTo.toString() : tiers[0].upTo.toString()}
51
51
  fullWidth
52
52
  onChange={handleChange}
53
- id={componentId}
54
53
  input={<TierInput />}
55
54
  MenuProps={{
56
55
  MenuListProps: { disablePadding: true },
@@ -26,6 +26,7 @@ export type PaywallLocalization = {
26
26
  };
27
27
  price: {
28
28
  startingAtCaption: string;
29
+ billingPeriod?: (billingPeriod: BillingPeriod) => string;
29
30
  custom: string;
30
31
  priceNotSet: string;
31
32
  free: PlanPriceText | ((currency?: PaywallCurrency) => PlanPriceText);
@@ -1,30 +1,7 @@
1
- import { PaywallPlan } from '../paywall/types';
1
+ import { PaywallPlan } from './types';
2
2
 
3
3
  import { BillingModel, TiersMode, BillingPeriod, Price, PriceTierFragment, Subscription } from '@stigg/js-client-sdk';
4
4
 
5
- export function getPriceFeatureUnit(price: Price) {
6
- if (!price.feature) {
7
- return '';
8
- }
9
-
10
- return (price.feature!.unitQuantity != 1 ? price.feature!.unitsPlural : price.feature!.units) || '';
11
- }
12
-
13
- export function getTierByQuantity(tiers: PriceTierFragment[], quantity: number) {
14
- if (!tiers) return;
15
-
16
- const ascendingTiers = [...tiers];
17
- ascendingTiers.sort((a, b) => a.upTo - b.upTo);
18
-
19
- for (const tier of ascendingTiers) {
20
- if (quantity <= tier.upTo) {
21
- return tier;
22
- }
23
- }
24
-
25
- return ascendingTiers[ascendingTiers.length - 1];
26
- }
27
-
28
5
  export function calculateTierPrice(
29
6
  price: Price,
30
7
  currentTier: PriceTierFragment,
@@ -69,7 +46,8 @@ export function getSelectedTier(
69
46
  );
70
47
 
71
48
  if (tieredPrice) {
72
- currentTier = getTierByQuantity(price.tiers!, tieredPrice.feature!.unitQuantity || 1)!;
49
+ const customerTier = price.tiers!.find(tier => tier.upTo === tieredPrice.feature!.unitQuantity);
50
+ currentTier = customerTier || price.tiers![0];
73
51
  }
74
52
  }
75
53
 
@@ -3,21 +3,16 @@ export function calculateUnitQuantityText(
3
3
  maxUnitQuantity?: number | null,
4
4
  unitsPlural?: string | null,
5
5
  ) {
6
- const unitsText = unitsPlural ? ` ${unitsPlural}` : '';
7
-
8
6
  // copy for only maxunit
9
7
  if ((!minUnitQuantity || minUnitQuantity === 1) && maxUnitQuantity) {
10
- return `Up to ${maxUnitQuantity}${unitsText}`;
8
+ return `Up to ${maxUnitQuantity} ${unitsPlural}`;
11
9
  }
12
-
13
10
  // both limits
14
11
  if (minUnitQuantity && minUnitQuantity > 1 && maxUnitQuantity) {
15
- return `${minUnitQuantity}-${maxUnitQuantity}${unitsText}`;
12
+ return `${minUnitQuantity}-${maxUnitQuantity} ${unitsPlural}`;
16
13
  }
17
-
18
14
  if (minUnitQuantity && minUnitQuantity > 1) {
19
- return `Minimum ${minUnitQuantity}${unitsText}`;
15
+ return `Minimum ${minUnitQuantity} ${unitsPlural}`;
20
16
  }
21
-
22
17
  return '';
23
- }
18
+ }
@@ -2,7 +2,7 @@ import { BillingPeriod, PaywallCalculatedPricePoint, Price } from '@stigg/js-cli
2
2
  import isNil from 'lodash/isNil';
3
3
  import { PaywallPlan } from '../paywall';
4
4
 
5
- export function calculateDiscountRate(monthlyPrice?: number | null, annuallyPrice?: number | null) {
5
+ function calculateDiscountRate(monthlyPrice?: number | null, annuallyPrice?: number | null) {
6
6
  if (!isNil(monthlyPrice) && !isNil(annuallyPrice)) {
7
7
  const annuallyPerMonthPrice = annuallyPrice / 12;
8
8
  return Math.round(((monthlyPrice - annuallyPerMonthPrice) / monthlyPrice) * 100);
@@ -8,7 +8,7 @@ export const currencyPriceFormatter = ({
8
8
  maximumFractionDigits = 5,
9
9
  }: {
10
10
  amount: number;
11
- currency?: Currency | string;
11
+ currency?: Currency;
12
12
  locale?: string;
13
13
  maximumFractionDigits?: number;
14
14
  }) => {
@@ -7,7 +7,7 @@ import {
7
7
  } from '@stigg/js-client-sdk';
8
8
  import { currencyPriceFormatter } from './currencyUtils';
9
9
  import { PlanPriceText } from './getPlanPrice';
10
- import { calculateTierPrice, getPriceFeatureUnit } from './priceTierUtils';
10
+ import { calculateTierPrice } from '../paywall/planPriceTier';
11
11
 
12
12
  type GetPaidPriceTextParams = {
13
13
  planPrices: Price[];
@@ -44,7 +44,7 @@ export function getPaidPriceText({
44
44
  currentTier = selectedTierByFeature[price.feature!.featureId] || currentTier;
45
45
 
46
46
  tiers = price.tiers;
47
- tierUnits = getPriceFeatureUnit(price);
47
+ tierUnits = price.feature!.unitsPlural || '';
48
48
  }
49
49
 
50
50
  priceNumber += calculateTierPrice(price, currentTier, selectedBillingPeriod, shouldShowMonthlyPriceAmount);
package/src/index.ts CHANGED
@@ -29,7 +29,6 @@ export {
29
29
  StiggContextValue,
30
30
  StiggContext,
31
31
  } from './components/StiggProvider';
32
- export { Checkout, CheckoutProps, CheckoutTheme } from './components/checkout';
33
32
  export { useWaitForCheckoutCompleted, ProvisionStatus } from './components/hooks';
34
33
  export { HorizontalAlignment, TextAlignment } from './theme/types';
35
34
  export { CustomizedTheme as Theme } from './theme/Theme';