@donotdev/billing 0.0.3 → 0.0.5

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.
@@ -1 +1 @@
1
- import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Crown as o,Check as E}from"lucide-react";import{Card as F,Badge as b,BADGE_VARIANT as w,Stack as s}from"@donotdev/components";import{useTranslation as I,maybeTranslate as m,translateArray as R}from"@donotdev/core";import{PurchaseButton as j}from"./PurchaseButton";import{SubscriptionButton as k}from"./SubscriptionButton";function V({namespace:C="billing",configKey:d,id:D,name:l,price:t,currency:p,description:S,features:a,popular:n=!1,limitedTime:x=!1,mode:u,priceId:g,allowPromotionCodes:f=!0,metadata:h={},successUrl:y="/billing/success",cancelUrl:v="/purchase",className:z=""}){const{t:e}=I([C,"billing"]),N=t==="Free"?"Free":t,T=u==="subscription"?"/month":"",A=m(e,l),U=m(e,S),P=Array.isArray(a)?a.map(c=>m(e,c)):a?R(e,a,10):[];return i(F,{className:z,style:{position:"relative",...n&&{boxShadow:"var(--shadow-xl)",transform:"scale(1.05)"}},title:i("div",{style:{textAlign:"center"},children:[r(s,{align:"center",style:{marginBottom:"var(--gap-md)"},children:r(o,{className:"dndev-size-touch",style:{color:"var(--warning)"}})}),i(s,{direction:"row",align:"center",justify:"center",gap:"tight",style:{fontSize:"var(--font-size-2xl)"},children:[A,x&&r(b,{as:"span",variant:w.DESTRUCTIVE,children:e("billing:components.productCard.limitedTime")})]}),i("div",{style:{fontSize:"var(--font-size-3xl)",fontWeight:700,color:"var(--primary)"},children:[N,t!=="Free"&&i("span",{style:{fontSize:"var(--font-size-lg)",fontWeight:400,color:"var(--muted-foreground)"},children:[T," ",e("billing:components.productCard.exclVat")]})]})]}),subtitle:U,children:[r(s,{as:"ul",gap:"tight",style:{marginBottom:"var(--gap-lg)"},children:P.map((c,B)=>i(s,{as:"li",direction:"row",align:"start",children:[r(E,{className:"dndev-size-md",style:{color:"var(--success)",marginRight:"var(--gap-md)",marginTop:"0.125rem",flexShrink:0}}),r("span",{style:{fontSize:"var(--font-size-sm)"},children:c})]},B))}),u==="payment"?r(j,{configKey:d,config:{type:"StripePayment",name:l,price:t,currency:p,priceId:g,tier:"premium",duration:"lifetime",metadata:h,allowPromotionCodes:f},successUrl:y,cancelUrl:v,variant:n?"primary":"outline",className:"dndev-w-full",icon:o,children:e("billing:components.productCard.purchaseNow")}):r(k,{configKey:d,config:{type:"StripeSubscription",name:l,price:t,currency:p,priceId:g,tier:"pro",duration:"1year",metadata:h,allowPromotionCodes:f},successUrl:y,cancelUrl:v,variant:n?"primary":"outline",className:"dndev-w-full",icon:o,children:e("billing:components.productCard.subscribeNow")}),n&&r("div",{style:{position:"absolute",top:"-0.75rem",left:"50%",transform:"translateX(-50%)"},children:i(b,{variant:w.DEFAULT,children:[r(o,{style:{width:"0.75rem",height:"0.75rem",marginRight:"0.25rem"}}),e("billing:components.productCard.mostPopular")]})})]})}export{V as ProductCard};
1
+ import{jsx as t,jsxs as i}from"react/jsx-runtime";import{Crown as s,Check as F}from"lucide-react";import{Card as E,Badge as b,BADGE_VARIANT as x,Stack as o}from"@donotdev/components";import{useTranslation as R,maybeTranslate as d,translateArray as U}from"@donotdev/core";import{PurchaseButton as k}from"./PurchaseButton";import{SubscriptionButton as P}from"./SubscriptionButton";function X({namespace:S="billing",configKey:m,id:V,name:l,price:e,currency:p,description:w,features:n,popular:a=!1,limitedTime:z=!1,mode:g,priceId:h,allowPromotionCodes:u=!0,metadata:f={},successUrl:y="/billing/success",cancelUrl:v="/purchase",className:C=""}){const{t:r}=R([S,"billing"]),N=e==="Free"?"Free":e,T=g==="subscription"?"/month":"",A=d(r,l),B=d(r,w),j=Array.isArray(n)?n.map(c=>d(r,c)):n?U(r,n,10):[];return i(E,{className:C,style:{position:"relative",...a&&{boxShadow:"var(--shadow-xl)",transform:"scale(1.05)"}},title:i("div",{style:{textAlign:"center"},children:[t(o,{align:"center",style:{marginBottom:"var(--gap-md)"},children:t(s,{className:"dndev-size-touch",style:{color:"var(--warning)"}})}),i(o,{direction:"row",align:"center",justify:"center",gap:"tight",style:{fontSize:"var(--font-size-2xl)"},children:[A,z&&t(b,{as:"span",variant:x.DESTRUCTIVE,children:r("billing:components.productCard.limitedTime")})]}),i("div",{style:{fontSize:"var(--font-size-3xl)",fontWeight:700,color:"var(--primary)"},children:[N,e!=="Free"&&i("span",{style:{fontSize:"var(--font-size-lg)",fontWeight:400,color:"var(--muted-foreground)"},children:[T," ",r("billing:components.productCard.exclVat")]})]})]}),subtitle:B,children:[t(o,{as:"ul",gap:"tight",style:{marginBottom:"var(--gap-lg)"},children:j.map((c,D)=>i(o,{as:"li",direction:"row",align:"start",children:[t(F,{className:"dndev-size-md",style:{color:"var(--success)",marginRight:"var(--gap-md)",marginTop:"0.125rem",flexShrink:0}}),t("span",{style:{fontSize:"var(--font-size-sm)"},children:c})]},D))}),g==="payment"?t(k,{configKey:m,config:{type:"StripePayment",name:l,price:e,currency:p,priceId:h,tier:"premium",duration:"lifetime",metadata:f,allowPromotionCodes:u},successUrl:y,cancelUrl:v,variant:a?"primary":"outline",className:"dndev-w-full",icon:s,children:r("billing:components.productCard.purchaseNow")}):t(P,{configKey:m,config:{type:"StripeSubscription",name:l,price:e,currency:p,priceId:h,tier:"pro",duration:"1year",metadata:f,allowPromotionCodes:u},successUrl:y,cancelUrl:v,variant:a?"primary":"outline",className:"dndev-w-full",icon:s,children:r("billing:components.productCard.subscribeNow")}),a&&t("div",{style:{position:"absolute",top:"-0.75rem",left:"50%",transform:"translateX(-50%)"},children:i(b,{variant:x.DEFAULT,children:[t(s,{style:{width:"0.75rem",height:"0.75rem",marginRight:"0.25rem"}}),r("billing:components.productCard.mostPopular")]})})]})}export{X as ProductCard};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useTranslation as n}from"@donotdev/core";import{StripeCheckoutButton as i}from"./StripeCheckoutButton";function s({config:t,children:o,...a}){const{t:r}=n("billing");return e(i,{...a,priceId:t.priceId,mode:"payment",metadata:{tier:t.tier,duration:t.duration,...t.metadata,...a.metadata},children:o||r("components.buttons.purchase")})}export{s as PurchaseButton};
1
+ import{jsx as o}from"react/jsx-runtime";import{useTranslation as n}from"@donotdev/core";import{StripeCheckoutButton as i}from"./StripeCheckoutButton";function s({config:t,children:e,...r}){const{t:a}=n("billing");return o(i,{...r,priceId:t.priceId,mode:"payment",metadata:{tier:t.tier,duration:t.duration,...t.metadata,...r.metadata},children:e||a("components.buttons.purchase")})}export{s as PurchaseButton};
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Shield as g,Lock as f,CreditCard as v,X as h}from"lucide-react";import{useState as a,useEffect as l}from"react";import{Card as S,Button as w,BUTTON_VARIANT as b,Stack as r}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";function z({dismissible:o=!0,className:s="",show:n=!0,onDismiss:m}){const{t}=N("billing"),[u,c]=a(n),[p,d]=a(!1);l(()=>{typeof window<"u"&&localStorage.getItem("billing-security-notice-dismissed")==="true"&&(d(!0),c(!1))},[]);const y=()=>{typeof window<"u"&&localStorage.setItem("billing-security-notice-dismissed","true"),d(!0),c(!1),m?.()};return!u||p?null:e(S,{className:s,style:{border:"1px solid var(--primary)",backgroundColor:"var(--primary)",opacity:"var(--opacity-subtle)"},children:e("div",{style:{padding:"var(--gap-md)"},children:i(r,{direction:"row",align:"start",justify:"between",children:[i(r,{direction:"row",align:"start",gap:"tight",children:[e("div",{className:"dndev-flex-shrink-0",children:e(g,{className:"dndev-size-md",style:{color:"var(--primary)"}})}),i("div",{className:"dndev-flex-1",children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:"var(--foreground)"},children:t("security.title","Secure Payment Processing")}),i("div",{style:{marginTop:"var(--gap-md)",fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[e("p",{style:{marginBottom:"var(--gap-md)"},children:t("security.description","Your payment information is processed securely by Stripe, a PCI DSS Level 1 certified payment processor.")}),i(r,{direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)"},children:[i(r,{direction:"row",align:"center",gap:"tight",children:[e(f,{className:"dndev-size-md"}),e("span",{children:t("security.encrypted","256-bit SSL encryption")})]}),i(r,{direction:"row",align:"center",gap:"tight",children:[e(v,{className:"dndev-size-md"}),e("span",{children:t("security.stripe","Powered by Stripe")})]})]})]})]})]}),o&&e(w,{variant:b.GHOST,onClick:y,className:"dndev-flex-shrink-0 dndev-size-touch","aria-label":t("security.dismiss","Dismiss security notice"),children:e(h,{className:"dndev-size-md"})})]})})})}function x(){const[o,s]=a(!1);return l(()=>{if(typeof window<"u"){const n=localStorage.getItem("billing-security-notice-dismissed");s(n==="true")}},[]),{isDismissed:o,dismiss:()=>{typeof window<"u"&&localStorage.setItem("billing-security-notice-dismissed","true"),s(!0)},reset:()=>{typeof window<"u"&&localStorage.removeItem("billing-security-notice-dismissed"),s(!1)}}}export{z as SecurityNotice,x as useSecurityNotice};
1
+ "use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Shield as y,Lock as g,CreditCard as v,X as h}from"lucide-react";import{useState as o,useEffect as m}from"react";import{Card as S,Button as w,BUTTON_VARIANT as b,Stack as r}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";function T({dismissible:n=!0,className:t="",show:d=!0,onDismiss:c}){const{t:i}=N("billing"),[u,a]=o(d),[f,l]=o(!1);m(()=>{typeof window<"u"&&localStorage.getItem("billing-security-notice-dismissed")==="true"&&(l(!0),a(!1))},[]);const p=()=>{typeof window<"u"&&localStorage.setItem("billing-security-notice-dismissed","true"),l(!0),a(!1),c?.()};return!u||f?null:e(S,{className:t,style:{border:"1px solid var(--primary)",backgroundColor:"var(--primary)",opacity:"var(--opacity-subtle)"},children:e("div",{style:{padding:"var(--gap-md)"},children:s(r,{direction:"row",align:"start",justify:"between",children:[s(r,{direction:"row",align:"start",gap:"tight",children:[e("div",{className:"dndev-flex-shrink-0",children:e(y,{className:"dndev-size-md",style:{color:"var(--primary)"}})}),s("div",{className:"dndev-flex-1",children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:"var(--foreground)"},children:i("security.title","Secure Payment Processing")}),s("div",{style:{marginTop:"var(--gap-md)",fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[e("p",{style:{marginBottom:"var(--gap-md)"},children:i("security.description","Your payment information is processed securely by Stripe, a PCI DSS Level 1 certified payment processor.")}),s(r,{direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)"},children:[s(r,{direction:"row",align:"center",gap:"tight",children:[e(g,{className:"dndev-size-md"}),e("span",{children:i("security.encrypted","256-bit SSL encryption")})]}),s(r,{direction:"row",align:"center",gap:"tight",children:[e(v,{className:"dndev-size-md"}),e("span",{children:i("security.stripe","Powered by Stripe")})]})]})]})]})]}),n&&e(w,{variant:b.GHOST,onClick:p,className:"dndev-flex-shrink-0 dndev-size-touch","aria-label":i("security.dismiss","Dismiss security notice"),children:e(h,{className:"dndev-size-md"})})]})})})}function j(){const[n,t]=o(!1);return m(()=>{if(typeof window<"u"){const i=localStorage.getItem("billing-security-notice-dismissed");t(i==="true")}},[]),{isDismissed:n,dismiss:()=>{typeof window<"u"&&localStorage.setItem("billing-security-notice-dismissed","true"),t(!0)},reset:()=>{typeof window<"u"&&localStorage.removeItem("billing-security-notice-dismissed"),t(!1)}}}export{T as SecurityNotice,j as useSecurityNotice};
@@ -1 +1 @@
1
- {"version":3,"file":"StripeCheckoutButton.d.ts","sourceRoot":"","sources":["../../src/components/StripeCheckoutButton.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACrD,WAAW,EACX,SAAS,GAAG,UAAU,GAAG,SAAS,CACnC;IACC,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,SAAS,EACT,QAAa,EACb,mBAA0B,EAC1B,OAAmB,EACnB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,GAAG,WAAW,EACf,EAAE,yBAAyB,2CAoF3B"}
1
+ {"version":3,"file":"StripeCheckoutButton.d.ts","sourceRoot":"","sources":["../../src/components/StripeCheckoutButton.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACrD,WAAW,EACX,SAAS,GAAG,UAAU,GAAG,SAAS,CACnC;IACC,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,SAAS,EACT,QAAa,EACb,mBAA0B,EAC1B,OAAmB,EACnB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,GAAG,WAAW,EACf,EAAE,yBAAyB,2CAmF3B"}
@@ -1 +1 @@
1
- import{jsx as n,Fragment as v,jsxs as k}from"react/jsx-runtime";import{Button as j,cn as B}from"@donotdev/components";import{useTranslation as F,redirectToExternalUrlWithErrorHandling as P}from"@donotdev/core";import{useStripeBilling as s}from"../useStripeBilling";import{PaymentRedirectOverlay as S}from"./PaymentRedirectOverlay";function T({configKey:e,priceId:c,mode:r,successUrl:l,cancelUrl:m,metadata:d={},allowPromotionCodes:p=!0,variant:u="primary",className:f,disabled:a,loadingText:g,icon:b,children:h,onError:y,...w}){const{t:i}=F("billing"),U=s("checkout"),t=s("status")==="initializing",x=g||i("components.buttons.processing"),C=h||i(r==="payment"?"components.buttons.purchase":"components.buttons.subscribe"),E=async()=>{if(!(t||a))try{const o=await U({priceId:c,mode:r,successUrl:l,cancelUrl:m,metadata:{...e&&{billingConfigKey:e},...d},allowPromotionCodes:p});o.sessionUrl&&await P(o.sessionUrl,{},"Failed to redirect to payment page")}catch(o){y?.(o instanceof Error?o:new Error("Checkout failed"))}};return k(v,{children:[n(S,{show:t}),n(j,{...w,onClick:E,disabled:a||t,variant:u,className:B("dndev-w-full",f),icon:b,children:t?x:C})]})}export{T as StripeCheckoutButton};
1
+ import{jsx as i,Fragment as w}from"react/jsx-runtime";import{Button as x,cn as y}from"@donotdev/components";import{useTranslation as E,redirectToExternalUrlWithErrorHandling as F}from"@donotdev/core";import{useStripeBilling as c}from"../useStripeBilling";function R({configKey:n,priceId:l,mode:r,successUrl:a,cancelUrl:u,metadata:d={},allowPromotionCodes:p=!0,variant:h="primary",className:g,disabled:s,loadingText:k,icon:m,children:C,onError:f,...B}){const{t:o}=E("billing"),b=c("checkout"),e=c("status")==="initializing",S=k||o("components.buttons.processing"),U=C||o(r==="payment"?"components.buttons.purchase":"components.buttons.subscribe");return i(w,{children:i(x,{...B,onClick:async()=>{if(!(e||s))try{const t=await b({priceId:l,mode:r,successUrl:a,cancelUrl:u,metadata:{...n&&{billingConfigKey:n},...d},allowPromotionCodes:p});t.sessionUrl&&await F(t.sessionUrl,{},"Failed to redirect to payment page")}catch(t){f?.(t instanceof Error?t:new Error("Checkout failed"))}},disabled:s||e,variant:h,className:y("dndev-w-full",g),icon:m,children:e?S:U})})}export{R as StripeCheckoutButton};
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import{useTranslation as a}from"@donotdev/core";import{StripeCheckoutButton as e}from"./StripeCheckoutButton";function s({config:t,children:i,...o}){const{t:r}=a("billing");return n(e,{...o,priceId:t.priceId,mode:"subscription",allowPromotionCodes:!0,metadata:{tier:t.tier,duration:t.duration,...t.metadata,...o.metadata},children:i||r("components.buttons.subscribe")})}export{s as SubscriptionButton};
1
+ import{jsx as i}from"react/jsx-runtime";import{useTranslation as a}from"@donotdev/core";import{StripeCheckoutButton as n}from"./StripeCheckoutButton";function d({config:t,children:r,...o}){const{t:e}=a("billing");return i(n,{...o,priceId:t.priceId,mode:"subscription",allowPromotionCodes:!0,metadata:{tier:t.tier,duration:t.duration,...t.metadata,...o.metadata},children:r||e("components.buttons.subscribe")})}export{d as SubscriptionButton};
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/components/SubscriptionManager.tsx"],"names":[],"mappings":"AAiEA,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;IACH,0BAA0B;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,cAAmB,EACnB,eAAuB,EACvB,SAAc,GACf,EAAE,wBAAwB,2CAwS1B"}
1
+ {"version":3,"file":"SubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/components/SubscriptionManager.tsx"],"names":[],"mappings":"AA0EA,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;IACH,0BAA0B;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,cAAmB,EACnB,eAAuB,EACvB,SAAc,GACf,EAAE,wBAAwB,2CAwS1B"}
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import{AlertCircle as D,CreditCard as I,AlertTriangle as k}from"lucide-react";import{useState as U,lazy as P,Suspense as B}from"react";import{isClient as L}from"@donotdev/core";import{Card as S,Button as p,BUTTON_VARIANT as g,Badge as c,BADGE_VARIANT as l,Stack as o}from"@donotdev/components";import{SUBSCRIPTION_STATUS as m,useTranslation as x}from"@donotdev/core";import{useStripeBilling as d}from"../useStripeBilling";const O=()=>null,V=P(async()=>{try{return{default:(await import("@donotdev/auth")).FeatureGuard}}catch{return{default:O}}});let v=null;L()&&import("@donotdev/auth").then(t=>{v=t.useAuth}).catch(()=>{});function j(t){return t==="user"?null:t==="status"?"degraded":(()=>{})}function _(t){return v?v(t):j(t)}function W({availablePlans:t=[],allowPlanChange:T=!1,className:b=""}){const{t:n}=x("billing"),f=_("user"),E=d("cancelSubscription"),M=d("changePlan"),A=d("openCustomerPortal"),u=d("status")==="initializing",C=d("error"),[N,h]=U(!1),i=f?.customClaims?.subscription,w=async()=>{try{const r=await E();h(!1);const s=new Date(r.endsAt).toLocaleDateString();alert(n("components.subscriptionManager.subscriptionEnds",{date:s}))}catch{}},z=async(r,s)=>{try{await M(r,s),alert(n("components.subscriptionManager.planChanged"))}catch{}},R=r=>{switch(r){case m.ACTIVE:return e(c,{children:n("components.subscriptionManager.status.active")});case m.CANCELED:return e(c,{variant:l.DESTRUCTIVE,children:n("components.subscriptionManager.status.cancelled")});case m.PAST_DUE:return e(c,{variant:l.DESTRUCTIVE,children:n("components.subscriptionManager.status.pastDue")});case m.TRIALING:return e(c,{variant:l.SECONDARY,children:n("components.subscriptionManager.status.trialing")});default:return e(c,{variant:l.OUTLINE,children:r})}},y=r=>e(S,{className:b,children:e("p",{style:{color:"var(--muted-foreground)"},children:n(f?"components.subscriptionManager.noSubscription":"components.subscriptionManager.signInRequired")})});return e(B,{fallback:e(y,{}),children:e(V,{subscription:!0,fallback:y,children:e(S,{className:b,title:n("components.subscriptionManager.title"),children:a(o,{gap:"medium",children:[a("div",{children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.currentPlan")}),a(o,{direction:"row",align:"center",justify:"between",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)"},children:[a("div",{children:[e("p",{style:{fontWeight:600},children:i.tier}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:R(i.status)})]}),i.cancelAtPeriodEnd&&a(o,{direction:"row",align:"center",style:{color:"var(--warning)"},children:[e(k,{className:"dndev-size-md",style:{marginRight:"var(--gap-md)"}}),a("span",{style:{fontSize:"var(--font-size-sm)"},children:[n("components.subscriptionManager.ends")," ",new Date(i.subscriptionEnd).toLocaleDateString()]})]})]})]}),a(o,{gap:"large",children:[e(p,{variant:g.OUTLINE,className:"dndev-w-full",onClick:()=>A(),disabled:u,icon:I,children:n("components.subscriptionManager.managePaymentMethod")}),!i.cancelAtPeriodEnd&&e(p,{variant:g.DESTRUCTIVE,className:"dndev-w-full",onClick:()=>h(!0),disabled:u,icon:D,children:n("components.subscriptionManager.cancelSubscription")})]}),N&&a("div",{className:"dndev-surface","data-variant":"default",style:{padding:"var(--gap-md)",border:"1px solid var(--warning)",borderRadius:"var(--radius-lg)",backgroundColor:"var(--muted)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.cancelConfirm",{date:new Date(i.subscriptionEnd).toLocaleDateString()})}),a(o,{direction:"row",gap:"tight",children:[e(p,{variant:g.DESTRUCTIVE,onClick:w,disabled:u,children:n("components.subscriptionManager.yesCancel")}),e(p,{variant:g.OUTLINE,onClick:()=>h(!1),children:n("components.subscriptionManager.noKeep")})]})]}),T&&t.length>0&&a("div",{children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.changePlan")}),e(o,{gap:"tight",children:t.map(r=>e("button",{className:"dndev-w-full",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)",textAlign:"left",backgroundColor:"transparent",cursor:"pointer"},onMouseEnter:s=>{s.currentTarget.style.backgroundColor="var(--accent)"},onMouseLeave:s=>{s.currentTarget.style.backgroundColor="transparent"},onClick:()=>z(r.priceId,r.billingConfigKey),disabled:u||i.tier===r.id,children:a(o,{direction:"row",justify:"between",align:"center",children:[a("div",{children:[e("p",{style:{fontWeight:500},children:r.name}),a("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[r.currency==="EUR"?"\u20AC":"$",r.price,"/month"]})]}),i.tier===r.id&&e(c,{variant:l.SECONDARY,children:n("components.subscriptionManager.current")})]})},r.id))})]}),C&&e("div",{className:"dndev-surface","data-variant":"destructive",style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",border:"1px solid var(--destructive)",borderRadius:"var(--radius-lg)"},children:e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--destructive-foreground)"},children:C})})]})})})})}export{W as SubscriptionManager};
1
+ "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{AlertCircle as D,CreditCard as I,AlertTriangle as k}from"lucide-react";import{useState as U,lazy as P,Suspense as x}from"react";import{isClient as B}from"@donotdev/core";import{Card as y,Button as p,BUTTON_VARIANT as g,Badge as c,BADGE_VARIANT as l,Stack as s}from"@donotdev/components";import{SUBSCRIPTION_STATUS as m,useTranslation as L}from"@donotdev/core";import{useStripeBilling as d}from"../useStripeBilling";const O=()=>null,V=P(async()=>{try{return{default:(await import("@donotdev/auth")).FeatureGuard}}catch{return{default:O}}});let f=null;B()&&import("@donotdev/auth").then(a=>{f=a.useAuth}).catch(()=>{});function _(a){return a==="user"?null:a==="status"?"degraded":(()=>{})}function j(a){return f?f(a):_(a)}function X({availablePlans:a=[],allowPlanChange:E=!1,className:v=""}){const{t:n}=L("billing"),b=j("user"),T=d("cancelSubscription"),A=d("changePlan"),M=d("openCustomerPortal"),u=d("status")==="initializing",C=d("error"),[w,h]=U(!1),i=b?.customClaims?.subscription,N=async()=>{try{const r=await T();h(!1);const o=new Date(r.endsAt).toLocaleDateString();alert(n("components.subscriptionManager.subscriptionEnds",{date:o}))}catch{}},R=async(r,o)=>{try{await A(r,o),alert(n("components.subscriptionManager.planChanged"))}catch{}},z=r=>{switch(r){case m.ACTIVE:return e(c,{children:n("components.subscriptionManager.status.active")});case m.CANCELED:return e(c,{variant:l.DESTRUCTIVE,children:n("components.subscriptionManager.status.cancelled")});case m.PAST_DUE:return e(c,{variant:l.DESTRUCTIVE,children:n("components.subscriptionManager.status.pastDue")});case m.TRIALING:return e(c,{variant:l.SECONDARY,children:n("components.subscriptionManager.status.trialing")});default:return e(c,{variant:l.OUTLINE,children:r})}},S=r=>e(y,{className:v,children:e("p",{style:{color:"var(--muted-foreground)"},children:n(b?"components.subscriptionManager.noSubscription":"components.subscriptionManager.signInRequired")})});return e(x,{fallback:e(S,{}),children:e(V,{subscription:!0,fallback:S,children:e(y,{className:v,title:n("components.subscriptionManager.title"),children:t(s,{gap:"medium",children:[t("div",{children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.currentPlan")}),t(s,{direction:"row",align:"center",justify:"between",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)"},children:[t("div",{children:[e("p",{style:{fontWeight:600},children:i.tier}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:z(i.status)})]}),i.cancelAtPeriodEnd&&t(s,{direction:"row",align:"center",style:{color:"var(--warning)"},children:[e(k,{className:"dndev-size-md",style:{marginRight:"var(--gap-md)"}}),t("span",{style:{fontSize:"var(--font-size-sm)"},children:[n("components.subscriptionManager.ends")," ",new Date(i.subscriptionEnd).toLocaleDateString()]})]})]})]}),t(s,{gap:"large",children:[e(p,{variant:g.OUTLINE,className:"dndev-w-full",onClick:()=>M(),disabled:u,icon:I,children:n("components.subscriptionManager.managePaymentMethod")}),!i.cancelAtPeriodEnd&&e(p,{variant:g.DESTRUCTIVE,className:"dndev-w-full",onClick:()=>h(!0),disabled:u,icon:D,children:n("components.subscriptionManager.cancelSubscription")})]}),w&&t("div",{className:"dndev-surface","data-variant":"default",style:{padding:"var(--gap-md)",border:"1px solid var(--warning)",borderRadius:"var(--radius-lg)",backgroundColor:"var(--muted)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.cancelConfirm",{date:new Date(i.subscriptionEnd).toLocaleDateString()})}),t(s,{direction:"row",gap:"tight",children:[e(p,{variant:g.DESTRUCTIVE,onClick:N,disabled:u,children:n("components.subscriptionManager.yesCancel")}),e(p,{variant:g.OUTLINE,onClick:()=>h(!1),children:n("components.subscriptionManager.noKeep")})]})]}),E&&a.length>0&&t("div",{children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.changePlan")}),e(s,{gap:"tight",children:a.map(r=>e("button",{className:"dndev-w-full",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)",textAlign:"left",backgroundColor:"transparent",cursor:"pointer"},onMouseEnter:o=>{o.currentTarget.style.backgroundColor="var(--accent)"},onMouseLeave:o=>{o.currentTarget.style.backgroundColor="transparent"},onClick:()=>R(r.priceId,r.billingConfigKey),disabled:u||i.tier===r.id,children:t(s,{direction:"row",justify:"between",align:"center",children:[t("div",{children:[e("p",{style:{fontWeight:500},children:r.name}),t("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[r.currency==="EUR"?"\u20AC":"$",r.price,"/month"]})]}),i.tier===r.id&&e(c,{variant:l.SECONDARY,children:n("components.subscriptionManager.current")})]})},r.id))})]}),C&&e("div",{className:"dndev-surface","data-variant":"destructive",style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",border:"1px solid var(--destructive)",borderRadius:"var(--radius-lg)"},children:e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--destructive-foreground)"},children:C})})]})})})})}export{X as SubscriptionManager};
@@ -6,7 +6,6 @@
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
9
- export * from './PaymentRedirectOverlay';
10
9
  export * from './ProductCard';
11
10
  export * from './PurchaseButton';
12
11
  export * from './SecurityNotice';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
@@ -1 +1 @@
1
- export*from"./PaymentRedirectOverlay";export*from"./ProductCard";export*from"./PurchaseButton";export*from"./SecurityNotice";export*from"./StripeCheckoutButton";export*from"./SubscriptionButton";export*from"./SubscriptionManager";
1
+ export*from"./ProductCard";export*from"./PurchaseButton";export*from"./SecurityNotice";export*from"./StripeCheckoutButton";export*from"./SubscriptionButton";export*from"./SubscriptionManager";
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  * @author AMBROISE PARK Consulting
7
7
  */
8
8
  export { useStripeBilling, type BillingAuthState } from './useStripeBilling';
9
- export { PaymentRedirectOverlay, ProductCard, SecurityNotice, StripeCheckoutButton, SubscriptionManager, } from './components';
9
+ export { ProductCard, SecurityNotice, StripeCheckoutButton, SubscriptionManager, } from './components';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{useStripeBilling as t}from"./useStripeBilling";import{PaymentRedirectOverlay as a,ProductCard as e,SecurityNotice as r,StripeCheckoutButton as i,SubscriptionManager as o}from"./components";export{a as PaymentRedirectOverlay,e as ProductCard,r as SecurityNotice,i as StripeCheckoutButton,o as SubscriptionManager,t as useStripeBilling};
1
+ import{useStripeBilling as e}from"./useStripeBilling";import{ProductCard as i,SecurityNotice as u,StripeCheckoutButton as c,SubscriptionManager as p}from"./components";export{i as ProductCard,u as SecurityNotice,c as StripeCheckoutButton,p as SubscriptionManager,e as useStripeBilling};