@stigg/react-sdk 4.4.0-beta.1 → 4.4.0-beta.3

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.
@@ -29,6 +29,6 @@ export declare type CheckoutProviderProps = {
29
29
  billingCountryCode?: string;
30
30
  billableFeatures?: BillableFeature[];
31
31
  };
32
- export declare function CheckoutProvider({ children, textOverrides, theme, resourceId, planId, preferredBillingPeriod, billingCountryCode, billableFeatures, }: {
32
+ export declare function CheckoutProvider({ children, textOverrides, theme, preferredBillingPeriod, billableFeatures, resourceId, planId, billingCountryCode, }: {
33
33
  children: React.ReactNode;
34
34
  } & CheckoutProviderProps): JSX.Element;
@@ -17,6 +17,7 @@ export declare function getProgressBarInitialState({ availableAddons }: {
17
17
  availableAddons?: Addon[];
18
18
  }): ProgressBarState;
19
19
  export declare function useProgressBarModel(): {
20
+ currentStep: CheckoutStep;
20
21
  progressBarState: ProgressBarState;
21
22
  isLastStep: boolean;
22
23
  isCheckoutComplete: boolean;
@@ -1,3 +1,4 @@
1
1
  export { CheckoutTheme } from './theme';
2
2
  export { Checkout, CheckoutProps } from './Checkout';
3
+ export { OnCheckoutCompletedParams, OnCheckoutParams, CheckoutResult } from './CheckoutContainer';
3
4
  export { CheckoutLocalization } from './textOverrides';
@@ -2,5 +2,5 @@
2
2
  /// <reference types="@emotion/styled/macro" />
3
3
  export declare const SubscriptionViewLayout: import("@emotion/styled/macro").StyledComponent<{
4
4
  theme?: import("@emotion/react").Theme | undefined;
5
- as?: "symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
5
+ as?: "symbol" | "object" | "big" | "link" | "small" | "sub" | "sup" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "section" | "select" | "source" | "span" | "strong" | "style" | "summary" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined;
6
6
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -6665,7 +6665,9 @@ function useGoNext() {
6665
6665
 
6666
6666
  function useProgressBarModel() {
6667
6667
  var progressBarState = useProgressBarState();
6668
+ var currentStep = progressBarState.steps[progressBarState.activeStep];
6668
6669
  return {
6670
+ currentStep: currentStep,
6669
6671
  progressBarState: progressBarState,
6670
6672
  isLastStep: progressBarState.activeStep === progressBarState.steps.length - 1,
6671
6673
  isCheckoutComplete: isCheckoutComplete(progressBarState),
@@ -6704,7 +6706,6 @@ var usePreviewSubscriptionAction = function usePreviewSubscriptionAction() {
6704
6706
 
6705
6707
  var _ref = checkoutState || {},
6706
6708
  plan = _ref.plan,
6707
- activeSubscription = _ref.activeSubscription,
6708
6709
  customer = _ref.customer;
6709
6710
 
6710
6711
  var previewSubscriptionAction = React.useCallback( /*#__PURE__*/function () {
@@ -6776,7 +6777,7 @@ var usePreviewSubscriptionAction = function usePreviewSubscriptionAction() {
6776
6777
  return function (_x) {
6777
6778
  return _ref2.apply(this, arguments);
6778
6779
  };
6779
- }(), [activeSubscription, customer, plan, resourceId, stigg, subscription.addons, subscription.billingPeriod, subscription.billableFeatures, subscription.promotionCode, planStep.billingCountryCode]);
6780
+ }(), [customer, plan, resourceId, stigg, subscription.addons, subscription.billingPeriod, subscription.billableFeatures, subscription.promotionCode, planStep.billingCountryCode]);
6780
6781
  return {
6781
6782
  previewSubscriptionAction: previewSubscriptionAction
6782
6783
  };
@@ -6968,6 +6969,9 @@ var CheckoutContextProvider = function CheckoutContextProvider(_ref) {
6968
6969
  state = _useState[0],
6969
6970
  innerSetState = _useState[1];
6970
6971
 
6972
+ React.useEffect(function () {
6973
+ innerSetState(initialState);
6974
+ }, [initialState]);
6971
6975
  var setState = React.useCallback(function (updater) {
6972
6976
  return innerSetState(function (old) {
6973
6977
  return immer.produce(old, function (draft) {
@@ -6978,7 +6982,7 @@ var CheckoutContextProvider = function CheckoutContextProvider(_ref) {
6978
6982
 
6979
6983
  var _useMemo = React.useMemo(function () {
6980
6984
  return [state, setState];
6981
- }, [state]),
6985
+ }, [setState, state]),
6982
6986
  contextValue = _useMemo[0],
6983
6987
  setContextValue = _useMemo[1];
6984
6988
 
@@ -6991,11 +6995,11 @@ function CheckoutProvider(_ref2) {
6991
6995
  var children = _ref2.children,
6992
6996
  textOverrides = _ref2.textOverrides,
6993
6997
  theme = _ref2.theme,
6998
+ preferredBillingPeriod = _ref2.preferredBillingPeriod,
6999
+ billableFeatures = _ref2.billableFeatures,
6994
7000
  resourceId = _ref2.resourceId,
6995
7001
  planId = _ref2.planId,
6996
- preferredBillingPeriod = _ref2.preferredBillingPeriod,
6997
- billingCountryCode = _ref2.billingCountryCode,
6998
- billableFeatures = _ref2.billableFeatures;
7002
+ billingCountryCode = _ref2.billingCountryCode;
6999
7003
 
7000
7004
  var _useLoadCheckout = useLoadCheckout({
7001
7005
  resourceId: resourceId,
@@ -7045,8 +7049,8 @@ function CheckoutProvider(_ref2) {
7045
7049
  isLoadingCheckoutData: isLoading
7046
7050
  }
7047
7051
  };
7048
- return initialState;
7049
- }, [theme, textOverrides, preferredBillingPeriod, billingCountryCode, billableFeatures, globalTheme, checkout, isLoading]);
7052
+ return initialState; // eslint-disable-next-line react-hooks/exhaustive-deps
7053
+ }, [preferredBillingPeriod, billingCountryCode, checkout, isLoading]);
7050
7054
  return React__default.createElement(SdkThemeProvider, {
7051
7055
  key: checkout == null ? void 0 : checkout.plan.id,
7052
7056
  componentTheme: configuration
@@ -12516,20 +12520,20 @@ var CheckoutPlanStep = function CheckoutPlanStep() {
12516
12520
  }));
12517
12521
  };
12518
12522
 
12519
- var getStepProps = function getStepProps(step) {
12520
- switch (step) {
12521
- case 0:
12523
+ var getStepProps = function getStepProps(currentStep) {
12524
+ switch (currentStep.key) {
12525
+ case CheckoutStepKey.PLAN:
12522
12526
  return {
12523
12527
  allowChangePlan: true,
12524
12528
  content: React__default.createElement(CheckoutPlanStep, null)
12525
12529
  };
12526
12530
 
12527
- case 1:
12531
+ case CheckoutStepKey.ADDONS:
12528
12532
  return {
12529
12533
  content: React__default.createElement(CheckoutAddonsStep, null)
12530
12534
  };
12531
12535
 
12532
- case 2:
12536
+ case CheckoutStepKey.PAYMENT:
12533
12537
  return {
12534
12538
  content: React__default.createElement(PaymentStep, null)
12535
12539
  };
@@ -12556,15 +12560,14 @@ function CheckoutContainer(_ref) {
12556
12560
  widgetState = _useCheckoutContext$.widgetState;
12557
12561
 
12558
12562
  var _useProgressBarModel = useProgressBarModel(),
12559
- progressBarState = _useProgressBarModel.progressBarState;
12563
+ currentStep = _useProgressBarModel.currentStep;
12560
12564
 
12561
- var activeStep = progressBarState.activeStep;
12562
12565
  var isLoadingCheckoutData = widgetState.isLoadingCheckoutData; // uncomment for fun!
12563
12566
  // if (activeStep > 2) {
12564
12567
  // return <SurpriseStep />;
12565
12568
  // }
12566
12569
 
12567
- var _getStepProps = getStepProps(activeStep),
12570
+ var _getStepProps = getStepProps(currentStep),
12568
12571
  content = _getStepProps.content,
12569
12572
  allowChangePlan = _getStepProps.allowChangePlan;
12570
12573