@stigg/react-sdk 8.1.0 → 8.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.
@@ -8,7 +8,7 @@
8
8
  @media (max-width: 1040px) {
9
9
  ${({$smallScreenAlign:t})=>t&&`align-self: ${t};`}
10
10
  }
11
- `;function l2({source:t,showWatermark:e,align:o,smallScreenAlign:n="center",style:s={}}){if(!e)return null;let a=()=>{let l=window.location.hostname.replace("www.","");window.open(`https://www.stigg.io/?utm_source=${l}&utm_medium=referral&utm_campaign=${t}`,"_blank");};return jsxRuntime.jsx(vt,{$alignSelf:o,$smallScreenAlign:n,className:yt,style:r({cursor:"pointer"},s),onClick:a,children:jsxRuntime.jsx(kt,{})})}var O=class{error(e,o,...n){console.error(e,o||{},n);}log(e,o){console.log(e,o||{});}debug(e,o){console.debug(e,o||{});}},m1=new O;var u1="8.1.0";var h1="@stigg/react-sdk";var _=Lt__default.default.createContext(null);_.displayName="StiggContext";var Tt="en-US",v2=({apiKey:t,baseUri:e,baseEdgeUri:o,enableEdge:n,customerId:s,customerToken:a,resourceId:l,theme:d,locale:g,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,entitlementsFallback:P,stiggClient:U,children:R,offline:W,clientName:Z=h1,clientVersion:ct=u1})=>{let o1=Lt.useRef(t),r1={apiKey:t,customerId:s,customerToken:a,resourceId:l,baseUri:e,baseEdgeUri:o,enableEdge:n,entitlementsFallback:P,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,clientName:Z,clientVersion:ct,offline:W},[M,G]=Lt.useState(()=>({stigg:U!=null?U:x1__default.default.initialize(i(r({},r1),{lazyLoad:true})),locale:g||Tt,isInitialized:false,theme:d,refreshData:()=>y(null,null,function*(){G(u=>i(r({},u),{customerPortalUpdatedAt:new Date})),yield M.stigg.refresh();})}));return Lt.useEffect(()=>{let u=true,N=f=>{u&&G(f);},$=()=>N(f=>i(r({},f),{updatedAt:new Date})),Ct=f=>N(b=>(b.stigg&&b.stigg.removeListener("entitlementsUpdated",$),f.addListener("entitlementsUpdated",$),i(r({},b),{stigg:f,isInitialized:true,updatedAt:new Date})));return y(null,null,function*(){let f=M.stigg;t!==o1.current&&(m1.log("Updating stigg client",{apiKey:t}),o1.current=t,f=x1__default.default.initialize(r({},r1)),N(b=>i(r({},b),{isInitialized:false,updatedAt:new Date}))),yield f.waitForInitialization(),Ct(f);}),()=>{u=false,M.stigg.removeListener("entitlementsUpdated",$),M.stigg.clearCustomer();}},[t]),Lt.useEffect(()=>{let u=M.stigg;s?u.setCustomerId(s,a,l):u.clearCustomer();},[s,a,l]),Lt.useEffect(()=>{G(u=>i(r({},u),{theme:d}));},[d]),jsxRuntime.jsx(_.Provider,{value:M,children:jsxRuntime.jsx(Je.SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:R})})};function p(t){let{optional:e}=t||{},o=Lt.useContext(_);if(!o&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return o}var y1=({externalFontUrl:t})=>jsxRuntime.jsx(react.Global,{styles:react.css`
11
+ `;function l2({source:t,showWatermark:e,align:o,smallScreenAlign:n="center",style:s={}}){if(!e)return null;let a=()=>{let l=window.location.hostname.replace("www.","");window.open(`https://www.stigg.io/?utm_source=${l}&utm_medium=referral&utm_campaign=${t}`,"_blank");};return jsxRuntime.jsx(vt,{$alignSelf:o,$smallScreenAlign:n,className:yt,style:r({cursor:"pointer"},s),onClick:a,children:jsxRuntime.jsx(kt,{})})}var O=class{error(e,o,...n){console.error(e,o||{},n);}log(e,o){console.log(e,o||{});}debug(e,o){console.debug(e,o||{});}},m1=new O;var u1="8.3.0";var h1="@stigg/react-sdk";var _=Lt__default.default.createContext(null);_.displayName="StiggContext";var Tt="en-US",v2=({apiKey:t,baseUri:e,baseEdgeUri:o,enableEdge:n,customerId:s,customerToken:a,resourceId:l,theme:d,locale:g,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,entitlementsFallback:P,stiggClient:U,children:R,offline:W,clientName:Z=h1,clientVersion:ct=u1})=>{let o1=Lt.useRef(t),r1={apiKey:t,customerId:s,customerToken:a,resourceId:l,baseUri:e,baseEdgeUri:o,enableEdge:n,entitlementsFallback:P,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,clientName:Z,clientVersion:ct,offline:W},[M,G]=Lt.useState(()=>({stigg:U!=null?U:x1__default.default.initialize(i(r({},r1),{lazyLoad:true})),locale:g||Tt,isInitialized:false,theme:d,refreshData:()=>y(null,null,function*(){G(u=>i(r({},u),{customerPortalUpdatedAt:new Date})),yield M.stigg.refresh();})}));return Lt.useEffect(()=>{let u=true,N=f=>{u&&G(f);},$=()=>N(f=>i(r({},f),{updatedAt:new Date})),Ct=f=>N(b=>(b.stigg&&b.stigg.removeListener("entitlementsUpdated",$),f.addListener("entitlementsUpdated",$),i(r({},b),{stigg:f,isInitialized:true,updatedAt:new Date})));return y(null,null,function*(){let f=M.stigg;t!==o1.current&&(m1.log("Updating stigg client",{apiKey:t}),o1.current=t,f=x1__default.default.initialize(r({},r1)),N(b=>i(r({},b),{isInitialized:false,updatedAt:new Date}))),yield f.waitForInitialization(),Ct(f);}),()=>{u=false,M.stigg.removeListener("entitlementsUpdated",$),M.stigg.clearCustomer();}},[t]),Lt.useEffect(()=>{let u=M.stigg;s?u.setCustomerId(s,a,l):u.clearCustomer();},[s,a,l]),Lt.useEffect(()=>{G(u=>i(r({},u),{theme:d}));},[d]),jsxRuntime.jsx(_.Provider,{value:M,children:jsxRuntime.jsx(Je.SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:R})})};function p(t){let{optional:e}=t||{},o=Lt.useContext(_);if(!o&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return o}var y1=({externalFontUrl:t})=>jsxRuntime.jsx(react.Global,{styles:react.css`
12
12
  ${t&&`
13
13
  @font-face {
14
14
  font-family: 'custom-font';
@@ -8,7 +8,7 @@ import d1 from'@emotion/styled';import Lt,{forwardRef,useRef,useState,useEffect,
8
8
  @media (max-width: 1040px) {
9
9
  ${({$smallScreenAlign:t})=>t&&`align-self: ${t};`}
10
10
  }
11
- `;function l2({source:t,showWatermark:e,align:o,smallScreenAlign:n="center",style:s={}}){if(!e)return null;let a=()=>{let l=window.location.hostname.replace("www.","");window.open(`https://www.stigg.io/?utm_source=${l}&utm_medium=referral&utm_campaign=${t}`,"_blank");};return jsx(vt,{$alignSelf:o,$smallScreenAlign:n,className:yt,style:r({cursor:"pointer"},s),onClick:a,children:jsx(kt,{})})}var O=class{error(e,o,...n){console.error(e,o||{},n);}log(e,o){console.log(e,o||{});}debug(e,o){console.debug(e,o||{});}},m1=new O;var u1="8.1.0";var h1="@stigg/react-sdk";var _=Lt.createContext(null);_.displayName="StiggContext";var Tt="en-US",v2=({apiKey:t,baseUri:e,baseEdgeUri:o,enableEdge:n,customerId:s,customerToken:a,resourceId:l,theme:d,locale:g,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,entitlementsFallback:P,stiggClient:U,children:R,offline:W,clientName:Z=h1,clientVersion:ct=u1})=>{let o1=useRef(t),r1={apiKey:t,customerId:s,customerToken:a,resourceId:l,baseUri:e,baseEdgeUri:o,enableEdge:n,entitlementsFallback:P,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,clientName:Z,clientVersion:ct,offline:W},[M,G]=useState(()=>({stigg:U!=null?U:x1.initialize(i(r({},r1),{lazyLoad:true})),locale:g||Tt,isInitialized:false,theme:d,refreshData:()=>y(null,null,function*(){G(u=>i(r({},u),{customerPortalUpdatedAt:new Date})),yield M.stigg.refresh();})}));return useEffect(()=>{let u=true,N=f=>{u&&G(f);},$=()=>N(f=>i(r({},f),{updatedAt:new Date})),Ct=f=>N(b=>(b.stigg&&b.stigg.removeListener("entitlementsUpdated",$),f.addListener("entitlementsUpdated",$),i(r({},b),{stigg:f,isInitialized:true,updatedAt:new Date})));return y(null,null,function*(){let f=M.stigg;t!==o1.current&&(m1.log("Updating stigg client",{apiKey:t}),o1.current=t,f=x1.initialize(r({},r1)),N(b=>i(r({},b),{isInitialized:false,updatedAt:new Date}))),yield f.waitForInitialization(),Ct(f);}),()=>{u=false,M.stigg.removeListener("entitlementsUpdated",$),M.stigg.clearCustomer();}},[t]),useEffect(()=>{let u=M.stigg;s?u.setCustomerId(s,a,l):u.clearCustomer();},[s,a,l]),useEffect(()=>{G(u=>i(r({},u),{theme:d}));},[d]),jsx(_.Provider,{value:M,children:jsx(SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:R})})};function p(t){let{optional:e}=t||{},o=useContext(_);if(!o&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return o}var y1=({externalFontUrl:t})=>jsx(Global,{styles:css`
11
+ `;function l2({source:t,showWatermark:e,align:o,smallScreenAlign:n="center",style:s={}}){if(!e)return null;let a=()=>{let l=window.location.hostname.replace("www.","");window.open(`https://www.stigg.io/?utm_source=${l}&utm_medium=referral&utm_campaign=${t}`,"_blank");};return jsx(vt,{$alignSelf:o,$smallScreenAlign:n,className:yt,style:r({cursor:"pointer"},s),onClick:a,children:jsx(kt,{})})}var O=class{error(e,o,...n){console.error(e,o||{},n);}log(e,o){console.log(e,o||{});}debug(e,o){console.debug(e,o||{});}},m1=new O;var u1="8.3.0";var h1="@stigg/react-sdk";var _=Lt.createContext(null);_.displayName="StiggContext";var Tt="en-US",v2=({apiKey:t,baseUri:e,baseEdgeUri:o,enableEdge:n,customerId:s,customerToken:a,resourceId:l,theme:d,locale:g,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,entitlementsFallback:P,stiggClient:U,children:R,offline:W,clientName:Z=h1,clientVersion:ct=u1})=>{let o1=useRef(t),r1={apiKey:t,customerId:s,customerToken:a,resourceId:l,baseUri:e,baseEdgeUri:o,enableEdge:n,entitlementsFallback:P,cacheTtlMs:c,useEntitlementPolling:S,entitlementPollingInterval:E,clientName:Z,clientVersion:ct,offline:W},[M,G]=useState(()=>({stigg:U!=null?U:x1.initialize(i(r({},r1),{lazyLoad:true})),locale:g||Tt,isInitialized:false,theme:d,refreshData:()=>y(null,null,function*(){G(u=>i(r({},u),{customerPortalUpdatedAt:new Date})),yield M.stigg.refresh();})}));return useEffect(()=>{let u=true,N=f=>{u&&G(f);},$=()=>N(f=>i(r({},f),{updatedAt:new Date})),Ct=f=>N(b=>(b.stigg&&b.stigg.removeListener("entitlementsUpdated",$),f.addListener("entitlementsUpdated",$),i(r({},b),{stigg:f,isInitialized:true,updatedAt:new Date})));return y(null,null,function*(){let f=M.stigg;t!==o1.current&&(m1.log("Updating stigg client",{apiKey:t}),o1.current=t,f=x1.initialize(r({},r1)),N(b=>i(r({},b),{isInitialized:false,updatedAt:new Date}))),yield f.waitForInitialization(),Ct(f);}),()=>{u=false,M.stigg.removeListener("entitlementsUpdated",$),M.stigg.clearCustomer();}},[t]),useEffect(()=>{let u=M.stigg;s?u.setCustomerId(s,a,l):u.clearCustomer();},[s,a,l]),useEffect(()=>{G(u=>i(r({},u),{theme:d}));},[d]),jsx(_.Provider,{value:M,children:jsx(SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:R})})};function p(t){let{optional:e}=t||{},o=useContext(_);if(!o&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return o}var y1=({externalFontUrl:t})=>jsx(Global,{styles:css`
12
12
  ${t&&`
13
13
  @font-face {
14
14
  font-family: 'custom-font';
package/dist/index.d.mts CHANGED
@@ -135,13 +135,18 @@ type PaywallPlan = Plan & {
135
135
  paywallCurrency?: PaywallCurrency;
136
136
  paywallCalculatedPricePoints?: PaywallCalculatedPricePoint[];
137
137
  };
138
- type OnPlanSelectedCallbackFn = ({ plan, customer, subscription, intentionType, selectedBillingPeriod, billableFeatures, }: {
138
+ type BillableCredit = {
139
+ topUpCustomCurrencyId: string;
140
+ quantity: number;
141
+ };
142
+ type OnPlanSelectedCallbackFn = ({ plan, customer, subscription, intentionType, selectedBillingPeriod, billableFeatures, billableCredits, }: {
139
143
  plan: Plan;
140
144
  customer: Customer | null;
141
145
  subscription: Subscription | null;
142
146
  intentionType: SubscribeIntentionType;
143
147
  selectedBillingPeriod: BillingPeriod;
144
148
  billableFeatures?: BillableFeature[];
149
+ billableCredits?: BillableCredit[];
145
150
  }) => void | Promise<void>;
146
151
  type ShouldHidePlanFn = ({ plan }: {
147
152
  plan: PaywallPlan;
@@ -227,6 +232,7 @@ type CustomerPortalLocalization = {
227
232
  editPaymentDetails: string;
228
233
  paywallSectionTitle: string;
229
234
  cancelScheduledUpdatesButtonTitle: string;
235
+ formatResetPeriod?: (usagePeriodEnd: Date) => string;
230
236
  };
231
237
 
232
238
  type CustomerPortalTheme = {
@@ -569,6 +575,7 @@ type CheckoutProviderProps = {
569
575
  onMockCheckoutState?: MockCheckoutStateCallback;
570
576
  skipCheckoutSteps?: CheckoutSteps[];
571
577
  onBeforeStepChange?: OnBeforeStepChangeCallback;
578
+ resetBillingPeriod?: boolean;
572
579
  };
573
580
 
574
581
  type CheckoutContainerProps = {
@@ -586,7 +593,7 @@ type CheckoutContainerProps = {
586
593
  };
587
594
 
588
595
  type CheckoutProps = CheckoutProviderProps & CheckoutContainerProps & CheckoutMockProps;
589
- declare const Checkout: ({ textOverrides, theme, resourceId, planId, preferredBillingPeriod, billingCountryCode, billableFeatures, billingInformation, onMockCheckoutState, skipCheckoutSteps, onBeforeStepChange, ...containerProps }: CheckoutProps) => JSX.Element;
596
+ declare const Checkout: ({ textOverrides, theme, resourceId, planId, preferredBillingPeriod, billingCountryCode, billableFeatures, billingInformation, onMockCheckoutState, skipCheckoutSteps, onBeforeStepChange, resetBillingPeriod, ...containerProps }: CheckoutProps) => JSX.Element;
590
597
 
591
598
  declare enum ProvisionStatus {
592
599
  IN_PROGRESS = "IN_PROGRESS",
@@ -688,6 +695,7 @@ type CreditBalanceProps = {
688
695
  type CreditBalanceLocalization = {
689
696
  title: string;
690
697
  addCredits: string;
698
+ formatResetPeriod?: (usagePeriodEnd: Date) => string;
691
699
  };
692
700
  declare function CreditBalance({ currencyId, localization, decimalPlaces, showUnits, onAddCredits, }: CreditBalanceProps): JSX.Element;
693
701
 
@@ -721,6 +729,7 @@ type CreditUtilizationLocalization = {
721
729
  title: string;
722
730
  remaining: string;
723
731
  addCredits: string;
732
+ formatResetPeriod?: (usagePeriodEnd: Date) => string;
724
733
  };
725
734
  declare function CreditUtilization({ currencyId, localization, decimalPlaces, showUnits, onAddCredits, }: CreditUtilizationProps): JSX.Element;
726
735
 
package/dist/index.d.ts CHANGED
@@ -135,13 +135,18 @@ type PaywallPlan = Plan & {
135
135
  paywallCurrency?: PaywallCurrency;
136
136
  paywallCalculatedPricePoints?: PaywallCalculatedPricePoint[];
137
137
  };
138
- type OnPlanSelectedCallbackFn = ({ plan, customer, subscription, intentionType, selectedBillingPeriod, billableFeatures, }: {
138
+ type BillableCredit = {
139
+ topUpCustomCurrencyId: string;
140
+ quantity: number;
141
+ };
142
+ type OnPlanSelectedCallbackFn = ({ plan, customer, subscription, intentionType, selectedBillingPeriod, billableFeatures, billableCredits, }: {
139
143
  plan: Plan;
140
144
  customer: Customer | null;
141
145
  subscription: Subscription | null;
142
146
  intentionType: SubscribeIntentionType;
143
147
  selectedBillingPeriod: BillingPeriod;
144
148
  billableFeatures?: BillableFeature[];
149
+ billableCredits?: BillableCredit[];
145
150
  }) => void | Promise<void>;
146
151
  type ShouldHidePlanFn = ({ plan }: {
147
152
  plan: PaywallPlan;
@@ -227,6 +232,7 @@ type CustomerPortalLocalization = {
227
232
  editPaymentDetails: string;
228
233
  paywallSectionTitle: string;
229
234
  cancelScheduledUpdatesButtonTitle: string;
235
+ formatResetPeriod?: (usagePeriodEnd: Date) => string;
230
236
  };
231
237
 
232
238
  type CustomerPortalTheme = {
@@ -569,6 +575,7 @@ type CheckoutProviderProps = {
569
575
  onMockCheckoutState?: MockCheckoutStateCallback;
570
576
  skipCheckoutSteps?: CheckoutSteps[];
571
577
  onBeforeStepChange?: OnBeforeStepChangeCallback;
578
+ resetBillingPeriod?: boolean;
572
579
  };
573
580
 
574
581
  type CheckoutContainerProps = {
@@ -586,7 +593,7 @@ type CheckoutContainerProps = {
586
593
  };
587
594
 
588
595
  type CheckoutProps = CheckoutProviderProps & CheckoutContainerProps & CheckoutMockProps;
589
- declare const Checkout: ({ textOverrides, theme, resourceId, planId, preferredBillingPeriod, billingCountryCode, billableFeatures, billingInformation, onMockCheckoutState, skipCheckoutSteps, onBeforeStepChange, ...containerProps }: CheckoutProps) => JSX.Element;
596
+ declare const Checkout: ({ textOverrides, theme, resourceId, planId, preferredBillingPeriod, billingCountryCode, billableFeatures, billingInformation, onMockCheckoutState, skipCheckoutSteps, onBeforeStepChange, resetBillingPeriod, ...containerProps }: CheckoutProps) => JSX.Element;
590
597
 
591
598
  declare enum ProvisionStatus {
592
599
  IN_PROGRESS = "IN_PROGRESS",
@@ -688,6 +695,7 @@ type CreditBalanceProps = {
688
695
  type CreditBalanceLocalization = {
689
696
  title: string;
690
697
  addCredits: string;
698
+ formatResetPeriod?: (usagePeriodEnd: Date) => string;
691
699
  };
692
700
  declare function CreditBalance({ currencyId, localization, decimalPlaces, showUnits, onAddCredits, }: CreditBalanceProps): JSX.Element;
693
701
 
@@ -721,6 +729,7 @@ type CreditUtilizationLocalization = {
721
729
  title: string;
722
730
  remaining: string;
723
731
  addCredits: string;
732
+ formatResetPeriod?: (usagePeriodEnd: Date) => string;
724
733
  };
725
734
  declare function CreditUtilization({ currencyId, localization, decimalPlaces, showUnits, onAddCredits, }: CreditUtilizationProps): JSX.Element;
726
735