@stigg/react-sdk 8.8.0 → 8.9.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.
- package/dist/{CreditUsageChart-L6HD2XSG.cjs.js → CreditUsageChart-7KXGSWCE.cjs.js} +19 -19
- package/dist/{CreditUsageChart-P72TCRCM.esm.js → CreditUsageChart-UASE7WPU.esm.js} +1 -1
- package/dist/{chunk-IPLRVWUY.cjs.js → chunk-FO6MFJ5S.cjs.js} +12 -12
- package/dist/{chunk-CDTYBQF6.esm.js → chunk-KH666OQG.esm.js} +12 -12
- package/dist/index.d.mts +23 -22
- package/dist/index.d.ts +23 -22
- package/dist/stigg-sdk.cjs.js +170 -170
- package/dist/stigg-sdk.esm.js +3 -3
- package/package.json +6 -31
package/dist/stigg-sdk.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {e,f,i,j,a,g,b,h,c,p,w,u,v,d,x,y,z,B,G,A,H as H$1,C,I,q,r,
|
|
1
|
+
import {e,f,i,j,a,g,b,h,c,p,w,u,v,d,x,y,z,B,G,A,H as H$1,C,I,q,r,K,o,l,m,n,k}from'./chunk-KH666OQG.esm.js';export{s as StiggContext,t as StiggProvider,D as useActiveSubscriptions,x as useBooleanEntitlement,A as useCreditEntitlement,L as useCreditUsage,F as useCustomerPortal,B as useEnumEntitlement,z as useMeteredEntitlement,y as useNumericEntitlement,E as usePaywall,u as useStiggContext}from'./chunk-KH666OQG.esm.js';import {BillingModel,PaymentCollection,SubscriptionStatus,PricingType,BillingPeriod,SubscriptionScheduleType,ThresholdType,DiscountType,DiscountDurationType,Currency,BillingVendorIdentifier,CreditGrantType,WidgetType,BillingCadence,FontWeight,MeterType,EntitlementResetPeriod,TiersMode,Alignment,CreditCadence,SubscriptionProrationBehavior,SubscriptionBillingCycleAnchor}from'@stigg/js-client-sdk';export*from'@stigg/js-client-sdk';import hi,{forwardRef,lazy,useContext,useMemo,useState,useEffect,Suspense,useCallback,useRef,createElement}from'react';import Ou from'classnames';import Re from'@mui/material/Grid/index.js';import Cc from'lodash/compact.js';import {NumericFormat,numericFormatter}from'react-number-format';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Wa from'lodash/isFunction.js';import ru from'react-spinners/ClipLoader.js';import {css,useTheme}from'@emotion/react';import Bo from'dayjs';import Qm from'dayjs/plugin/utc.js';import Km from'dayjs/plugin/relativeTime.js';import qm from'dayjs/plugin/advancedFormat.js';import Fo from'lodash/isNil.js';import tu from'lodash/sum.js';import gu from'currency-symbol-map';import Tu from'@mui/material/InputAdornment/index.js';import hu,{buttonClasses}from'@mui/material/Button/index.js';import xu from'@mui/material/TextField/index.js';import Ll from'@mui/material/Divider/index.js';import ku from'@mui/material/OutlinedInput/index.js';import wu from'@mui/material/Select/index.js';import Bu from'@mui/material/MenuItem/index.js';import Au from'lodash/map.js';import ke from'@mui/material/Box/index.js';import fg from'react-switch';import Ig from'lodash/countBy.js';import Fg from'lodash/uniq.js';import ac from'lodash/sortBy.js';import Mg from'lodash/merge.js';import Xe from'react-loading-skeleton';import Kg from'lodash/flatMap.js';import Qs from'@mui/material/Tab/index.js';import qg from'lodash/isEmpty.js';import of from'@mui/material/Tabs/index.js';import sf from'@mui/material/useMediaQuery/index.js';import {ExternalLink,ChevronRight,Info,Minus,Plus,ArrowDown}from'react-feather';import Of from'@mui/material/Link/index.js';import _f,{tooltipClasses}from'@mui/material/Tooltip/index.js';import Dl from'lodash/keyBy.js';import Ni from'color';import Qf,{linearProgressClasses}from'@mui/material/LinearProgress/index.js';import uy from'lodash/padStart.js';import Yl from'lodash/isUndefined.js';import {BillingModel as BillingModel$1,BillingPeriod as BillingPeriod$1}from'@stigg/api-client-js/src/generated/sdk';import jn from'lodash/lowerCase.js';import wy from'lodash/range.js';import {produce}from'immer';import My from'lodash/cloneDeep.js';import Ry from'lodash/remove.js';import {Elements,useStripe,useElements,AddressElement,PaymentElement}from'@stripe/react-stripe-js';import _h from'@mui/material/StepIcon/index.js';import Wx from'lodash/partition.js';import Kh from'@mui/material/CircularProgress/index.js';import Kx from'@mui/material/Paper/index.js';import qx from'@mui/material/Alert/index.js';import tC from'@mui/material/Checkbox/index.js';import oC from'@mui/material/FormControlLabel/index.js';import rC from'lodash/isString.js';import WP from'@mui/material/Autocomplete/index.js';import ZP from'@mui/material/Collapse/index.js';import {AL,AD,AO,AR,AM,AW,AU,AT,AZ,BS as BS$1,BH,BD,BB,BY,BE,BJ,BO,BA,BR,BG,BF,KH,CM,CA,CV,CL,CN,CO,CD,CR,HR,CY,CZ,DK,DO,EC,EG,SV,EE,ET,EU,FI,FR,GE,DE,GR,GN,HK,HU,IS as IS$1,IN,ID,IE,IL,IT,JP,KZ,KE,KG,LA,LV,LI,LT,LU,MY,MT,MR,MX,MD,ME,MA,NP,NL,NZ,NG,MK,NO,OM,PE,PH,PL,PT,RO,RU,SA,SN,RS,SG,SK,SI,ZA,KR,ES as ES$1,SR,SE,CH,TW,TJ,TZ,TH,TR,UG,UA,AE,GB,US,UY,UZ,VE,VN,ZM,ZW}from'country-flag-icons/react/3x2';import gd from'lodash/startCase.js';import fd from'lodash/upperCase.js';import dx from'react-lottie';import Gx from'@mui/material/IconButton/index.js';import {styled}from'@mui/material/styles/index.js';import bb from'@mui/material/Radio/index.js';import Fb from'@mui/material/Chip/index.js';import {TableContainer,Table,Divider,TableCell,TableRow,TablePagination,TableBody,TableHead}from'@mui/material';import US$1 from'@mui/material/TableRow/index.js';function So(e,t,o){let r=o?` ${o}`:"";return (!e||e===1)&&t?`Up to ${t}${r}`:e&&e>1&&t?`${e}-${t}${r}`:e&&e>1?`Minimum ${e}${r}`:""}function se(e,t="en-US"){if(e==null)return;let o={thousandSeparator:t==="en-US"?",":" ",decimalSeparator:".",decimalScale:0,fixedDecimalScale:true};return numericFormatter(String(Math.round(e)),o)}function pn(e,t="en-US"){let o={thousandSeparator:t==="en-US"?",":" ",decimalSeparator:".",decimalScale:2,fixedDecimalScale:true};return numericFormatter(String(e),o)}function Gt(e,t=1){if(e<1e6)return se(e)||"0";let o=[{value:1e12,suffix:"T"},{value:1e9,suffix:"B"},{value:1e6,suffix:"M"}];for(let{value:r,suffix:n}of o)if(e>=r){let a=(e/r).toFixed(t);return a.includes(".")&&(a=a.replace(/\.0+$/,"").replace(/(\.\d*[1-9])0+$/,"$1")),`${a}${n}`}return se(e)||"0"}var Bm=e(f)`
|
|
2
2
|
margin: 0;
|
|
3
3
|
`,Am=e.div`
|
|
4
4
|
display: flex;
|
|
@@ -653,7 +653,7 @@ import {e,f,i,j,a,g,b,h,c,p,w,u,v,d,x,y,z,B,G,A,H as H$1,C,I,q,r,k,K,o,l,m,n}fro
|
|
|
653
653
|
align-items: center;
|
|
654
654
|
justify-content: space-between;
|
|
655
655
|
}
|
|
656
|
-
`,Ox=({checkoutLocalization:e})=>{let t=jsx(f,{variant:"body1",children:e.summary.payAsYouGoTooltipText});return jsx(Ze,{placement:"left",title:t,children:jsx(i,{icon:"PayAsYouGoCharge",style:{display:"flex"}})})},vr=({checkoutLocalization:e,label:t,quantity:o,price:r})=>{let{checkoutState:n}=D(),i=n==null?void 0:n.plan,a=me("lg"),[l,s]=useState(false),c=()=>s(h=>!h),u=r.pricingModel===BillingModel.UsageBased,f$1=r.isTieredPrice?xt(r,o):(r.amount||0)*Math.ceil(o/(r.blockSize||1)),y;r.tiersMode===TiersMode.Graduated
|
|
656
|
+
`,Ox=({checkoutLocalization:e})=>{let t=jsx(f,{variant:"body1",children:e.summary.payAsYouGoTooltipText});return jsx(Ze,{placement:"left",title:t,children:jsx(i,{icon:"PayAsYouGoCharge",style:{display:"flex"}})})},vr=({checkoutLocalization:e,label:t,quantity:o,price:r})=>{let{checkoutState:n}=D(),i=n==null?void 0:n.plan,a=me("lg"),[l,s]=useState(false),c=()=>s(h=>!h),u=r.pricingModel===BillingModel.UsageBased,f$1=r.isTieredPrice?xt(r,o):(r.amount||0)*Math.ceil(o/(r.blockSize||1)),y;r.tiersMode===TiersMode.Graduated&&r.tiers&&!qg(r.tiers)&&!Fo(r.tiers[0].upTo)&&o>r.tiers[0].upTo&&(y=jsx(Nd,{price:r,unitQuantity:o}));let g=jsx(f,{variant:"body1",color:"secondary",children:t});return y&&(g=jsx(Of,{onClick:c,underline:"none",style:{cursor:"pointer"},children:g})),jsxs($e,{className:"stigg-checkout-summary-base-charges-container",children:[jsxs(Fe,{style:{alignItems:"flex-start"},children:[jsxs(Re,{item:true,display:"flex",gap:.5,style:{whiteSpace:a?"nowrap":"break-spaces"},children:[g,y&&jsx(Gx,{onClick:c,sx:{padding:0},children:jsx(Md,{$isOpen:l,$size:16})})]}),jsxs(Re,{item:true,display:"flex",gap:1,alignItems:"center",children:[u&&jsx(Ox,{checkoutLocalization:e}),jsxs(f,{variant:"body1",color:"secondary",style:{whiteSpace:a?"nowrap":"break-spaces"},children:[Ld({totalAmount:f$1,quantity:o,currency:r.currency,pricingModel:r.pricingModel,billingPeriod:r.billingPeriod,tiers:r.tiers,tiersMode:r.tiersMode,blockSize:r.blockSize,priceAmount:r.amount,availableBillingPeriods:new Set(i==null?void 0:i.pricePoints.map(h=>h.billingPeriod))}),u&&" / unit"]})]})]}),y&&jsx(ZP,{in:l,children:jsx(zx,{children:y})})]})},Rd=({label:e})=>jsx($e,{children:jsxs(Fe,{style:{alignItems:"flex-end"},children:[jsx(Re,{item:true,children:jsx(f,{variant:"body1",color:"secondary",children:e})}),jsx(Re,{item:true,display:"flex",gap:1,alignItems:"center",children:jsx(f,{variant:"body1",color:"secondary",style:{wordBreak:"break-word"},children:"Free"})})]})}),Ud=({subscriptionPreview:e,isFetchingSubscriptionPreview:t,checkoutLocalization:o$1})=>{let{immediateInvoice:r,recurringInvoice:n}=e,{discount:i,discountDetails:a}=n||{};return !i||!a?null:jsx($e,{children:jsxs(Fe,{children:[jsx(f,{variant:"body1",color:"secondary",children:o$1.summary.discountText({discountDetails:a,currency:r.total.currency})}),jsx(f,{variant:"body1",color:"secondary",children:t?jsx(o,{width:50,height:16}):H({amount:i.amount,currency:i.currency,minimumFractionDigits:2})})]})})},_d=({subscriptionPreview:e,isFetchingSubscriptionPreview:t,checkoutLocalization:o})=>{let{immediateInvoice:r}=e||{},{credits:n}=r||{};return !n||!n.used||n.used.amount<=0?null:jsx($e,{children:jsxs(Fe,{children:[jsx(f,{variant:"body1",color:"secondary",children:o.summary.appliedCreditsTitle}),jsx(f,{variant:"body1",color:"secondary",children:jsx(Ie,{isLoading:t,children:H({amount:-1*n.used.amount,currency:n.used.currency,minimumFractionDigits:2})})})]})})},Dd=({tax:e,taxDetails:t,isFetchingSubscriptionPreview:o,checkoutLocalization:r})=>!t||!e||(e==null?void 0:e.amount)<=0?null:jsx($e,{children:jsxs(Fe,{children:[jsx(f,{variant:"body1",color:"secondary",children:r.summary.taxTitle({taxDetails:t})}),jsx(f,{variant:"body1",color:"secondary",children:jsx(Ie,{isLoading:o,children:H({amount:e==null?void 0:e.amount,currency:e==null?void 0:e.currency,minimumFractionDigits:2})})})]})});var _i=e(ke)`
|
|
657
657
|
width: 100%;
|
|
658
658
|
max-width: 470px;
|
|
659
659
|
flex: 1.5;
|
|
@@ -885,7 +885,7 @@ import {e,f,i,j,a,g,b,h,c,p,w,u,v,d,x,y,z,B,G,A,H as H$1,C,I,q,r,k,K,o,l,m,n}fro
|
|
|
885
885
|
border-radius: 8px;
|
|
886
886
|
border: 1px solid ${({theme:e})=>{var t,o;return (o=(t=e.stigg)==null?void 0:t.palette)==null?void 0:o.outlinedBorder}};
|
|
887
887
|
background-color: ${({theme:e})=>{var t,o;return (o=(t=e==null?void 0:e.stigg)==null?void 0:t.palette)==null?void 0:o.backgroundPaper}};
|
|
888
|
-
`;function $p({currencyId:e,localization:t,decimalPlaces:o,showUnits:r=true,onAddCredits:n}){let i=he(ee),a$1=u({optional:true}),l=a$1==null?void 0:a$1.theme,{title:s,addCredits:c,formatResetPeriod:u$1}=a(a({},G),t),f$1=A({currencyId:e}),y=jsx(PS,{className:"stigg-credit-balance-container",children:jsxs(xS,{className:"stigg-credit-balance-card",children:[jsxs(Rt,{children:[jsx(f,{variant:"h6",color:"primary",className:"stigg-credit-balance-title",children:s}),n&&!f$1.isFallback&&jsxs(Ut,{type:"button",onClick:()=>n(f$1),className:"stigg-credit-balance-add-credits-button",children:[jsx(Hr,{className:"stigg-credit-balance-add-credits-icon"}),c]})]}),jsx(Dp,{entitlement:f$1,decimalPlaces:o,showUnits:r,formatResetPeriod:u$1})]})});return i?y:jsx(w,{componentTheme:l,children:y})}var TS=lazy(()=>import('./CreditUsageChart-
|
|
888
|
+
`;function $p({currencyId:e,localization:t,decimalPlaces:o,showUnits:r=true,onAddCredits:n}){let i=he(ee),a$1=u({optional:true}),l=a$1==null?void 0:a$1.theme,{title:s,addCredits:c,formatResetPeriod:u$1}=a(a({},G),t),f$1=A({currencyId:e}),y=jsx(PS,{className:"stigg-credit-balance-container",children:jsxs(xS,{className:"stigg-credit-balance-card",children:[jsxs(Rt,{children:[jsx(f,{variant:"h6",color:"primary",className:"stigg-credit-balance-title",children:s}),n&&!f$1.isFallback&&jsxs(Ut,{type:"button",onClick:()=>n(f$1),className:"stigg-credit-balance-add-credits-button",children:[jsx(Hr,{className:"stigg-credit-balance-add-credits-icon"}),c]})]}),jsx(Dp,{entitlement:f$1,decimalPlaces:o,showUnits:r,formatResetPeriod:u$1})]})});return i?y:jsx(w,{componentTheme:l,children:y})}var TS=lazy(()=>import('./CreditUsageChart-UASE7WPU.esm.js').then(e=>({default:e.CreditUsageChart})));function Vp(e){return jsx(Suspense,{fallback:null,children:jsx(TS,a({},e))})}var kS=(e,t,o)=>o==="primary"?t.palette.primary:e>=100?t.palette.progress.high:e>=75?t.palette.progress.medium:t.palette.progress.low,wS=e.div`
|
|
889
889
|
width: 100%;
|
|
890
890
|
height: 8px;
|
|
891
891
|
background-color: ${({theme:e})=>e.stigg.palette.progress.background};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "8.
|
|
2
|
+
"version": "8.9.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/stigg-sdk.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
@@ -26,34 +26,20 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "tsup --watch",
|
|
28
28
|
"build": "tsup",
|
|
29
|
-
"test": "vitest",
|
|
29
|
+
"test:unit": "vitest run",
|
|
30
|
+
"test:size": "size-limit",
|
|
31
|
+
"test:integration": "node integration-tests/run-tests.js",
|
|
30
32
|
"lint": "eslint src --max-warnings=0",
|
|
31
33
|
"lint-fix": "yarn run lint --fix",
|
|
32
|
-
"size": "size-limit",
|
|
33
34
|
"analyze": "size-limit --why",
|
|
34
|
-
"fix:prettier": "prettier \"src/**/*.(js|jsx|ts|tsx)\" --write",
|
|
35
|
-
"pretty-quick": "pretty-quick --staged --pattern 'src/**/*.*(js|jsx|ts|tsx)'",
|
|
36
35
|
"storybook": "storybook dev -p 6006",
|
|
37
36
|
"build-storybook": "storybook build",
|
|
38
|
-
"prepare": "husky install",
|
|
39
37
|
"docs": "typedoc",
|
|
40
|
-
"link-sdk": "yarn link && cd node_modules/react && yarn link && cd ../../node_modules/react-dom && yarn link && cd ../../",
|
|
41
38
|
"type-check": "tsc --noEmit --skipLibCheck"
|
|
42
39
|
},
|
|
43
40
|
"peerDependencies": {
|
|
44
41
|
"react": ">=16"
|
|
45
42
|
},
|
|
46
|
-
"husky": {
|
|
47
|
-
"hooks": {
|
|
48
|
-
"pre-commit": "yarn lint"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"lint-staged": {
|
|
52
|
-
"src/**/*.{js,jsx,ts,tsx}": [
|
|
53
|
-
"prettier --check",
|
|
54
|
-
"eslint --cache --max-warnings=0 --fix"
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
43
|
"name": "@stigg/react-sdk",
|
|
58
44
|
"author": {
|
|
59
45
|
"name": "Stigg"
|
|
@@ -65,8 +51,6 @@
|
|
|
65
51
|
}
|
|
66
52
|
],
|
|
67
53
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^19.7.1",
|
|
69
|
-
"@commitlint/config-conventional": "^19.7.1",
|
|
70
54
|
"@lottiefiles/dotlottie-react": "^0.17.13",
|
|
71
55
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
72
56
|
"@storybook/addon-docs": "^9.1.5",
|
|
@@ -86,27 +70,18 @@
|
|
|
86
70
|
"autoprefixer": "^10.4.14",
|
|
87
71
|
"esbuild-plugin-svgr": "^2.1.0",
|
|
88
72
|
"eslint": "^9.0.0",
|
|
89
|
-
"eslint-config-prettier": "^9.0.0",
|
|
90
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
91
73
|
"eslint-plugin-react": "^7.37.5",
|
|
92
74
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
93
75
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
94
|
-
"husky": "^7.0.4",
|
|
95
76
|
"jiti": "^2.6.1",
|
|
96
77
|
"jsdom": "^26.1.0",
|
|
97
|
-
"lint-staged": "^14.0.1",
|
|
98
78
|
"postcss": "^8.4.24",
|
|
99
|
-
"prettier": "^3.8.1",
|
|
100
|
-
"pretty-quick": "^4.0.0",
|
|
101
79
|
"react": "^18.0.0",
|
|
102
80
|
"react-dom": "^18.0.0",
|
|
103
81
|
"size-limit": "^7.0.8",
|
|
104
82
|
"storybook": "9.1.5",
|
|
105
|
-
"tslib": "^2.4.0",
|
|
106
83
|
"tsup": "^8.3.5",
|
|
107
84
|
"typedoc": "^0.28.7",
|
|
108
|
-
"typescript": "^5.9.3",
|
|
109
|
-
"typescript-eslint": "^8.0.0",
|
|
110
85
|
"vite": "^7.1.5",
|
|
111
86
|
"vite-plugin-dts": "^4.5.4",
|
|
112
87
|
"vite-plugin-svgr": "^4.5.0",
|
|
@@ -116,7 +91,7 @@
|
|
|
116
91
|
"@emotion/react": "^11.10.5",
|
|
117
92
|
"@emotion/styled": "^11.10.5",
|
|
118
93
|
"@mui/material": "^5.12.0",
|
|
119
|
-
"@stigg/js-client-sdk": "3.
|
|
94
|
+
"@stigg/js-client-sdk": "3.105.0",
|
|
120
95
|
"@stripe/react-stripe-js": "^2.1.1",
|
|
121
96
|
"@stripe/stripe-js": "^1.54.1",
|
|
122
97
|
"chart.js": "^3.8.2",
|
|
@@ -139,4 +114,4 @@
|
|
|
139
114
|
"react-switch": "^7.0.0"
|
|
140
115
|
},
|
|
141
116
|
"readme": "ERROR: No README data found!"
|
|
142
|
-
}
|
|
117
|
+
}
|