@mmailaender/convex-creem 0.1.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/LICENSE +201 -0
- package/README.md +1176 -0
- package/dist/client/helpers.d.ts +17 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +43 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/index.d.ts +1041 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +1068 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/parsers.d.ts +45 -0
- package/dist/client/parsers.d.ts.map +1 -0
- package/dist/client/parsers.js +138 -0
- package/dist/client/parsers.js.map +1 -0
- package/dist/client/polyfill.d.ts +2 -0
- package/dist/client/polyfill.d.ts.map +1 -0
- package/dist/client/polyfill.js +3 -0
- package/dist/client/polyfill.js.map +1 -0
- package/dist/component/_generated/api.d.ts +36 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +542 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +3 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/lib.d.ts +1005 -0
- package/dist/component/lib.d.ts.map +1 -0
- package/dist/component/lib.js +647 -0
- package/dist/component/lib.js.map +1 -0
- package/dist/component/schema.d.ts +191 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +104 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/util.d.ts +61 -0
- package/dist/component/util.d.ts.map +1 -0
- package/dist/component/util.js +142 -0
- package/dist/component/util.js.map +1 -0
- package/dist/core/catalog.d.ts +18 -0
- package/dist/core/catalog.d.ts.map +1 -0
- package/dist/core/catalog.js +82 -0
- package/dist/core/catalog.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/markdown.d.ts +12 -0
- package/dist/core/markdown.d.ts.map +1 -0
- package/dist/core/markdown.js +26 -0
- package/dist/core/markdown.js.map +1 -0
- package/dist/core/payments.d.ts +11 -0
- package/dist/core/payments.d.ts.map +1 -0
- package/dist/core/payments.js +27 -0
- package/dist/core/payments.js.map +1 -0
- package/dist/core/pendingCheckout.d.ts +15 -0
- package/dist/core/pendingCheckout.d.ts.map +1 -0
- package/dist/core/pendingCheckout.js +40 -0
- package/dist/core/pendingCheckout.js.map +1 -0
- package/dist/core/resolver.d.ts +11 -0
- package/dist/core/resolver.d.ts.map +1 -0
- package/dist/core/resolver.js +106 -0
- package/dist/core/resolver.js.map +1 -0
- package/dist/core/selectors.d.ts +12 -0
- package/dist/core/selectors.d.ts.map +1 -0
- package/dist/core/selectors.js +18 -0
- package/dist/core/selectors.js.map +1 -0
- package/dist/core/subscriptionUpdate.d.ts +20 -0
- package/dist/core/subscriptionUpdate.d.ts.map +1 -0
- package/dist/core/subscriptionUpdate.js +64 -0
- package/dist/core/subscriptionUpdate.js.map +1 -0
- package/dist/core/types.d.ts +170 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +15 -0
- package/dist/core/types.js.map +1 -0
- package/dist/design-system/colors/color-utils.d.ts +10 -0
- package/dist/design-system/colors/color-utils.d.ts.map +1 -0
- package/dist/design-system/colors/color-utils.js +91 -0
- package/dist/design-system/colors/color-utils.js.map +1 -0
- package/dist/design-system/colors/config.d.ts +33 -0
- package/dist/design-system/colors/config.d.ts.map +1 -0
- package/dist/design-system/colors/config.js +224 -0
- package/dist/design-system/colors/config.js.map +1 -0
- package/dist/design-system/colors/index.d.ts +3 -0
- package/dist/design-system/colors/index.d.ts.map +1 -0
- package/dist/design-system/colors/index.js +3 -0
- package/dist/design-system/colors/index.js.map +1 -0
- package/dist/design-system/rounded/config.d.ts +31 -0
- package/dist/design-system/rounded/config.d.ts.map +1 -0
- package/dist/design-system/rounded/config.js +76 -0
- package/dist/design-system/rounded/config.js.map +1 -0
- package/dist/design-system/rounded/index.d.ts +2 -0
- package/dist/design-system/rounded/index.d.ts.map +1 -0
- package/dist/design-system/rounded/index.js +2 -0
- package/dist/design-system/rounded/index.js.map +1 -0
- package/dist/design-system/typography/config.d.ts +55 -0
- package/dist/design-system/typography/config.d.ts.map +1 -0
- package/dist/design-system/typography/config.js +308 -0
- package/dist/design-system/typography/config.js.map +1 -0
- package/dist/design-system/typography/index.d.ts +3 -0
- package/dist/design-system/typography/index.d.ts.map +1 -0
- package/dist/design-system/typography/index.js +3 -0
- package/dist/design-system/typography/index.js.map +1 -0
- package/dist/design-system/typography/tokens.d.ts +23 -0
- package/dist/design-system/typography/tokens.d.ts.map +1 -0
- package/dist/design-system/typography/tokens.js +99 -0
- package/dist/design-system/typography/tokens.js.map +1 -0
- package/dist/react/hooks/useCheckoutSuccessParams.d.ts +2 -0
- package/dist/react/hooks/useCheckoutSuccessParams.d.ts.map +1 -0
- package/dist/react/hooks/useCheckoutSuccessParams.js +5 -0
- package/dist/react/hooks/useCheckoutSuccessParams.js.map +1 -0
- package/dist/react/index.d.ts +25 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +22 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/primitives/BillingGate.d.ts +8 -0
- package/dist/react/primitives/BillingGate.d.ts.map +1 -0
- package/dist/react/primitives/BillingGate.js +13 -0
- package/dist/react/primitives/BillingGate.js.map +1 -0
- package/dist/react/primitives/BillingToggle.d.ts +8 -0
- package/dist/react/primitives/BillingToggle.d.ts.map +1 -0
- package/dist/react/primitives/BillingToggle.js +12 -0
- package/dist/react/primitives/BillingToggle.js.map +1 -0
- package/dist/react/primitives/CheckoutButton.d.ts +11 -0
- package/dist/react/primitives/CheckoutButton.d.ts.map +1 -0
- package/dist/react/primitives/CheckoutButton.js +21 -0
- package/dist/react/primitives/CheckoutButton.js.map +1 -0
- package/dist/react/primitives/CheckoutSuccessSummary.d.ts +7 -0
- package/dist/react/primitives/CheckoutSuccessSummary.d.ts.map +1 -0
- package/dist/react/primitives/CheckoutSuccessSummary.js +11 -0
- package/dist/react/primitives/CheckoutSuccessSummary.js.map +1 -0
- package/dist/react/primitives/CustomerPortalButton.d.ts +8 -0
- package/dist/react/primitives/CustomerPortalButton.d.ts.map +1 -0
- package/dist/react/primitives/CustomerPortalButton.js +21 -0
- package/dist/react/primitives/CustomerPortalButton.js.map +1 -0
- package/dist/react/primitives/NumberInput.d.ts +11 -0
- package/dist/react/primitives/NumberInput.d.ts.map +1 -0
- package/dist/react/primitives/NumberInput.js +18 -0
- package/dist/react/primitives/NumberInput.js.map +1 -0
- package/dist/react/primitives/OneTimeCheckoutButton.d.ts +11 -0
- package/dist/react/primitives/OneTimeCheckoutButton.d.ts.map +1 -0
- package/dist/react/primitives/OneTimeCheckoutButton.js +4 -0
- package/dist/react/primitives/OneTimeCheckoutButton.js.map +1 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.d.ts +6 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.d.ts.map +1 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.js +11 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.js.map +1 -0
- package/dist/react/primitives/PaymentWarningBanner.d.ts +7 -0
- package/dist/react/primitives/PaymentWarningBanner.d.ts.map +1 -0
- package/dist/react/primitives/PaymentWarningBanner.js +18 -0
- package/dist/react/primitives/PaymentWarningBanner.js.map +1 -0
- package/dist/react/primitives/PricingCard.d.ts +37 -0
- package/dist/react/primitives/PricingCard.d.ts.map +1 -0
- package/dist/react/primitives/PricingCard.js +125 -0
- package/dist/react/primitives/PricingCard.js.map +1 -0
- package/dist/react/primitives/PricingSection.d.ts +39 -0
- package/dist/react/primitives/PricingSection.d.ts.map +1 -0
- package/dist/react/primitives/PricingSection.js +24 -0
- package/dist/react/primitives/PricingSection.js.map +1 -0
- package/dist/react/primitives/ScheduledChangeBanner.d.ts +8 -0
- package/dist/react/primitives/ScheduledChangeBanner.d.ts.map +1 -0
- package/dist/react/primitives/ScheduledChangeBanner.js +13 -0
- package/dist/react/primitives/ScheduledChangeBanner.js.map +1 -0
- package/dist/react/primitives/SegmentControl.d.ts +11 -0
- package/dist/react/primitives/SegmentControl.d.ts.map +1 -0
- package/dist/react/primitives/SegmentControl.js +8 -0
- package/dist/react/primitives/SegmentControl.js.map +1 -0
- package/dist/react/primitives/SegmentGroup.d.ts +14 -0
- package/dist/react/primitives/SegmentGroup.d.ts.map +1 -0
- package/dist/react/primitives/SegmentGroup.js +11 -0
- package/dist/react/primitives/SegmentGroup.js.map +1 -0
- package/dist/react/primitives/TrialLimitBanner.d.ts +7 -0
- package/dist/react/primitives/TrialLimitBanner.d.ts.map +1 -0
- package/dist/react/primitives/TrialLimitBanner.js +14 -0
- package/dist/react/primitives/TrialLimitBanner.js.map +1 -0
- package/dist/react/shared.d.ts +28 -0
- package/dist/react/shared.d.ts.map +1 -0
- package/dist/react/shared.js +109 -0
- package/dist/react/shared.js.map +1 -0
- package/dist/react/widgets/BillingPortal.d.ts +9 -0
- package/dist/react/widgets/BillingPortal.d.ts.map +1 -0
- package/dist/react/widgets/BillingPortal.js +30 -0
- package/dist/react/widgets/BillingPortal.js.map +1 -0
- package/dist/react/widgets/ProductItem.d.ts +8 -0
- package/dist/react/widgets/ProductItem.d.ts.map +1 -0
- package/dist/react/widgets/ProductItem.js +14 -0
- package/dist/react/widgets/ProductItem.js.map +1 -0
- package/dist/react/widgets/ProductRoot.d.ts +16 -0
- package/dist/react/widgets/ProductRoot.d.ts.map +1 -0
- package/dist/react/widgets/ProductRoot.js +171 -0
- package/dist/react/widgets/ProductRoot.js.map +1 -0
- package/dist/react/widgets/SubscriptionItem.d.ts +27 -0
- package/dist/react/widgets/SubscriptionItem.d.ts.map +1 -0
- package/dist/react/widgets/SubscriptionItem.js +32 -0
- package/dist/react/widgets/SubscriptionItem.js.map +1 -0
- package/dist/react/widgets/SubscriptionRoot.d.ts +16 -0
- package/dist/react/widgets/SubscriptionRoot.d.ts.map +1 -0
- package/dist/react/widgets/SubscriptionRoot.js +405 -0
- package/dist/react/widgets/SubscriptionRoot.js.map +1 -0
- package/dist/react/widgets/index.d.ts +19 -0
- package/dist/react/widgets/index.d.ts.map +1 -0
- package/dist/react/widgets/index.js +16 -0
- package/dist/react/widgets/index.js.map +1 -0
- package/dist/react/widgets/productGroupContext.d.ts +6 -0
- package/dist/react/widgets/productGroupContext.d.ts.map +1 -0
- package/dist/react/widgets/productGroupContext.js +3 -0
- package/dist/react/widgets/productGroupContext.js.map +1 -0
- package/dist/react/widgets/subscriptionContext.d.ts +6 -0
- package/dist/react/widgets/subscriptionContext.d.ts.map +1 -0
- package/dist/react/widgets/subscriptionContext.js +3 -0
- package/dist/react/widgets/subscriptionContext.js.map +1 -0
- package/dist/react/widgets/types.d.ts +171 -0
- package/dist/react/widgets/types.d.ts.map +1 -0
- package/dist/react/widgets/types.js +2 -0
- package/dist/react/widgets/types.js.map +1 -0
- package/dist/svelte/index.d.ts +22 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +20 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/primitives/BillingGate.svelte +28 -0
- package/dist/svelte/primitives/BillingToggle.svelte +27 -0
- package/dist/svelte/primitives/CheckoutButton.svelte +60 -0
- package/dist/svelte/primitives/CheckoutSuccessSummary.svelte +34 -0
- package/dist/svelte/primitives/CustomerPortalButton.svelte +60 -0
- package/dist/svelte/primitives/NumberInput.svelte +71 -0
- package/dist/svelte/primitives/OneTimeCheckoutButton.svelte +37 -0
- package/dist/svelte/primitives/OneTimePaymentStatusBadge.svelte +20 -0
- package/dist/svelte/primitives/PaymentWarningBanner.svelte +30 -0
- package/dist/svelte/primitives/PricingCard.svelte +356 -0
- package/dist/svelte/primitives/PricingSection.svelte +121 -0
- package/dist/svelte/primitives/ScheduledChangeBanner.svelte +46 -0
- package/dist/svelte/primitives/SegmentControl.svelte +38 -0
- package/dist/svelte/primitives/SegmentGroup.svelte +52 -0
- package/dist/svelte/primitives/TrialLimitBanner.svelte +32 -0
- package/dist/svelte/primitives/shared.d.ts +13 -0
- package/dist/svelte/primitives/shared.d.ts.map +1 -0
- package/dist/svelte/primitives/shared.js +87 -0
- package/dist/svelte/primitives/shared.js.map +1 -0
- package/dist/svelte/widgets/BillingPortal.svelte +55 -0
- package/dist/svelte/widgets/Product.svelte +35 -0
- package/dist/svelte/widgets/ProductRoot.svelte +428 -0
- package/dist/svelte/widgets/Subscription.svelte +52 -0
- package/dist/svelte/widgets/SubscriptionRoot.svelte +690 -0
- package/dist/svelte/widgets/index.d.ts +19 -0
- package/dist/svelte/widgets/index.d.ts.map +1 -0
- package/dist/svelte/widgets/index.js +16 -0
- package/dist/svelte/widgets/index.js.map +1 -0
- package/dist/svelte/widgets/productGroupContext.d.ts +6 -0
- package/dist/svelte/widgets/productGroupContext.d.ts.map +1 -0
- package/dist/svelte/widgets/productGroupContext.js +2 -0
- package/dist/svelte/widgets/productGroupContext.js.map +1 -0
- package/dist/svelte/widgets/subscriptionContext.d.ts +6 -0
- package/dist/svelte/widgets/subscriptionContext.d.ts.map +1 -0
- package/dist/svelte/widgets/subscriptionContext.js +2 -0
- package/dist/svelte/widgets/subscriptionContext.js.map +1 -0
- package/dist/svelte/widgets/types.d.ts +171 -0
- package/dist/svelte/widgets/types.d.ts.map +1 -0
- package/dist/svelte/widgets/types.js +2 -0
- package/dist/svelte/widgets/types.js.map +1 -0
- package/package.json +182 -0
- package/src/client/helpers.test.ts +139 -0
- package/src/client/helpers.ts +51 -0
- package/src/client/index.test.ts +1554 -0
- package/src/client/index.ts +1504 -0
- package/src/client/parsers.test.ts +1017 -0
- package/src/client/parsers.ts +182 -0
- package/src/client/polyfill.ts +2 -0
- package/src/component/_generated/api.ts +52 -0
- package/src/component/_generated/component.ts +619 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +3 -0
- package/src/component/lib.test.ts +1359 -0
- package/src/component/lib.ts +726 -0
- package/src/component/schema.ts +112 -0
- package/src/component/util.test.ts +281 -0
- package/src/component/util.ts +228 -0
- package/src/core/catalog.test.ts +212 -0
- package/src/core/catalog.ts +119 -0
- package/src/core/index.ts +8 -0
- package/src/core/markdown.test.ts +43 -0
- package/src/core/markdown.ts +26 -0
- package/src/core/payments.test.ts +69 -0
- package/src/core/payments.ts +33 -0
- package/src/core/pendingCheckout.test.ts +44 -0
- package/src/core/pendingCheckout.ts +40 -0
- package/src/core/resolver.test.ts +283 -0
- package/src/core/resolver.ts +160 -0
- package/src/core/selectors.test.ts +119 -0
- package/src/core/selectors.ts +35 -0
- package/src/core/subscriptionUpdate.test.ts +164 -0
- package/src/core/subscriptionUpdate.ts +102 -0
- package/src/core/types.ts +220 -0
- package/src/design-system/README.md +40 -0
- package/src/design-system/base.css +27 -0
- package/src/design-system/colors/color-utils.ts +110 -0
- package/src/design-system/colors/config.ts +282 -0
- package/src/design-system/colors/index.ts +2 -0
- package/src/design-system/colors/utilities.css +2328 -0
- package/src/design-system/components/badges.css +65 -0
- package/src/design-system/components/buttons.css +256 -0
- package/src/design-system/components/dialog.css +218 -0
- package/src/design-system/components/icon-buttons.css +115 -0
- package/src/design-system/components/inputs.css +94 -0
- package/src/design-system/components/links.css +53 -0
- package/src/design-system/components/prose.css +67 -0
- package/src/design-system/components/segment-control.css +303 -0
- package/src/design-system/index.css +21 -0
- package/src/design-system/rounded/config.ts +91 -0
- package/src/design-system/rounded/index.ts +1 -0
- package/src/design-system/rounded/utilities.css +37 -0
- package/src/design-system/typography/config.ts +340 -0
- package/src/design-system/typography/index.ts +2 -0
- package/src/design-system/typography/tokens.ts +148 -0
- package/src/design-system/typography/utilities.css +728 -0
- package/src/library.css +20 -0
- package/src/react/hooks/useCheckoutSuccessParams.ts +7 -0
- package/src/react/index.tsx +47 -0
- package/src/react/primitives/BillingGate.tsx +26 -0
- package/src/react/primitives/BillingToggle.tsx +29 -0
- package/src/react/primitives/CheckoutButton.tsx +47 -0
- package/src/react/primitives/CheckoutSuccessSummary.tsx +36 -0
- package/src/react/primitives/CustomerPortalButton.tsx +50 -0
- package/src/react/primitives/NumberInput.tsx +83 -0
- package/src/react/primitives/OneTimeCheckoutButton.tsx +27 -0
- package/src/react/primitives/OneTimePaymentStatusBadge.tsx +18 -0
- package/src/react/primitives/PaymentWarningBanner.tsx +33 -0
- package/src/react/primitives/PricingCard.tsx +421 -0
- package/src/react/primitives/PricingSection.tsx +129 -0
- package/src/react/primitives/ScheduledChangeBanner.tsx +52 -0
- package/src/react/primitives/SegmentControl.tsx +32 -0
- package/src/react/primitives/SegmentGroup.tsx +53 -0
- package/src/react/primitives/TrialLimitBanner.tsx +32 -0
- package/src/react/shared.ts +138 -0
- package/src/react/widgets/BillingPortal.tsx +56 -0
- package/src/react/widgets/ProductItem.tsx +26 -0
- package/src/react/widgets/ProductRoot.tsx +441 -0
- package/src/react/widgets/SubscriptionItem.tsx +71 -0
- package/src/react/widgets/SubscriptionRoot.tsx +759 -0
- package/src/react/widgets/index.ts +36 -0
- package/src/react/widgets/productGroupContext.ts +10 -0
- package/src/react/widgets/subscriptionContext.ts +10 -0
- package/src/react/widgets/types.ts +179 -0
- package/src/svelte/index.ts +43 -0
- package/src/svelte/primitives/BillingGate.svelte +28 -0
- package/src/svelte/primitives/BillingToggle.svelte +27 -0
- package/src/svelte/primitives/CheckoutButton.svelte +60 -0
- package/src/svelte/primitives/CheckoutSuccessSummary.svelte +34 -0
- package/src/svelte/primitives/CustomerPortalButton.svelte +60 -0
- package/src/svelte/primitives/NumberInput.svelte +71 -0
- package/src/svelte/primitives/OneTimeCheckoutButton.svelte +37 -0
- package/src/svelte/primitives/OneTimePaymentStatusBadge.svelte +20 -0
- package/src/svelte/primitives/PaymentWarningBanner.svelte +30 -0
- package/src/svelte/primitives/PricingCard.svelte +356 -0
- package/src/svelte/primitives/PricingSection.svelte +121 -0
- package/src/svelte/primitives/ScheduledChangeBanner.svelte +46 -0
- package/src/svelte/primitives/SegmentControl.svelte +38 -0
- package/src/svelte/primitives/SegmentGroup.svelte +52 -0
- package/src/svelte/primitives/TrialLimitBanner.svelte +32 -0
- package/src/svelte/primitives/shared.ts +113 -0
- package/src/svelte/svelte.d.ts +6 -0
- package/src/svelte/widgets/BillingPortal.svelte +55 -0
- package/src/svelte/widgets/Product.svelte +35 -0
- package/src/svelte/widgets/ProductRoot.svelte +428 -0
- package/src/svelte/widgets/Subscription.svelte +52 -0
- package/src/svelte/widgets/SubscriptionRoot.svelte +690 -0
- package/src/svelte/widgets/index.ts +36 -0
- package/src/svelte/widgets/productGroupContext.ts +7 -0
- package/src/svelte/widgets/subscriptionContext.ts +7 -0
- package/src/svelte/widgets/types.ts +179 -0
- package/src/tailwind.css +6 -0
- package/src/test.ts +18 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CheckoutButton from "./CheckoutButton.svelte";
|
|
3
|
+
import NumberInput from "./NumberInput.svelte";
|
|
4
|
+
import type { UIPlanEntry, RecurringCycle } from "../../core/types.js";
|
|
5
|
+
import type { ConnectedProduct } from "../widgets/types.js";
|
|
6
|
+
import { resolveProductIdForPlan, formatPriceWithInterval, formatSeatPrice } from "./shared.js";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
plan: UIPlanEntry;
|
|
10
|
+
selectedCycle?: RecurringCycle;
|
|
11
|
+
activePlanId?: string | null;
|
|
12
|
+
subscriptionProductId?: string | null;
|
|
13
|
+
subscriptionStatus?: string | null;
|
|
14
|
+
subscriptionTrialEnd?: string | null;
|
|
15
|
+
products?: ConnectedProduct[];
|
|
16
|
+
units?: number;
|
|
17
|
+
showSeatPicker?: boolean;
|
|
18
|
+
subscribedSeats?: number | null;
|
|
19
|
+
isGroupSubscribed?: boolean;
|
|
20
|
+
disableCheckout?: boolean;
|
|
21
|
+
disableSwitch?: boolean;
|
|
22
|
+
disableSeats?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
onCheckout?: (payload: {
|
|
25
|
+
plan: UIPlanEntry;
|
|
26
|
+
productId: string;
|
|
27
|
+
units?: number;
|
|
28
|
+
}) => Promise<void> | void;
|
|
29
|
+
onSwitchPlan?: (payload: {
|
|
30
|
+
plan: UIPlanEntry;
|
|
31
|
+
productId: string;
|
|
32
|
+
units?: number;
|
|
33
|
+
}) => Promise<void> | void;
|
|
34
|
+
onUpdateSeats?: (payload: { units: number }) => Promise<void> | void;
|
|
35
|
+
onContactSales?: (payload: { plan: UIPlanEntry }) => Promise<void> | void;
|
|
36
|
+
onCancelSubscription?: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let {
|
|
40
|
+
plan,
|
|
41
|
+
selectedCycle = undefined,
|
|
42
|
+
activePlanId = undefined,
|
|
43
|
+
subscriptionProductId = null,
|
|
44
|
+
subscriptionStatus = null,
|
|
45
|
+
subscriptionTrialEnd = null,
|
|
46
|
+
products = [],
|
|
47
|
+
units = undefined,
|
|
48
|
+
showSeatPicker = false,
|
|
49
|
+
subscribedSeats = null,
|
|
50
|
+
isGroupSubscribed = false,
|
|
51
|
+
disableCheckout = false,
|
|
52
|
+
disableSwitch = false,
|
|
53
|
+
disableSeats = false,
|
|
54
|
+
className = "",
|
|
55
|
+
onCheckout,
|
|
56
|
+
onSwitchPlan,
|
|
57
|
+
onUpdateSeats,
|
|
58
|
+
onContactSales,
|
|
59
|
+
onCancelSubscription,
|
|
60
|
+
}: Props = $props();
|
|
61
|
+
|
|
62
|
+
const isSeatPlan = $derived(plan.pricingModel === "seat");
|
|
63
|
+
let seatCount = $derived(1);
|
|
64
|
+
let seatAdjustCount = $state(1);
|
|
65
|
+
let editingSeats = $state(false);
|
|
66
|
+
$effect(() => {
|
|
67
|
+
seatCount = units ?? 1;
|
|
68
|
+
});
|
|
69
|
+
$effect(() => {
|
|
70
|
+
seatAdjustCount = subscribedSeats ?? units ?? 1;
|
|
71
|
+
editingSeats = false;
|
|
72
|
+
});
|
|
73
|
+
const effectiveUnits = $derived(
|
|
74
|
+
isSeatPlan ? (showSeatPicker ? seatCount : units) : undefined,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const productId = $derived(resolveProductIdForPlan(plan, selectedCycle));
|
|
78
|
+
const priceLabel = $derived(formatPriceWithInterval(productId, products));
|
|
79
|
+
|
|
80
|
+
// Exact match: user is subscribed to THIS specific product (plan + cycle)
|
|
81
|
+
const isActiveProduct = $derived(
|
|
82
|
+
subscriptionProductId != null && productId != null && productId === subscriptionProductId,
|
|
83
|
+
);
|
|
84
|
+
const isTrialing = $derived(isActiveProduct && subscriptionStatus === "trialing");
|
|
85
|
+
const trialDaysLeft = $derived.by(() => {
|
|
86
|
+
if (!isTrialing || !subscriptionTrialEnd) return null;
|
|
87
|
+
const end = new Date(subscriptionTrialEnd).getTime();
|
|
88
|
+
const now = Date.now();
|
|
89
|
+
const days = Math.max(0, Math.ceil((end - now) / (1000 * 60 * 60 * 24)));
|
|
90
|
+
return days;
|
|
91
|
+
});
|
|
92
|
+
// Same plan but different billing cycle — offer to switch interval
|
|
93
|
+
const isActivePlanOtherCycle = $derived(
|
|
94
|
+
!isActiveProduct && activePlanId === plan.planId && productId != null,
|
|
95
|
+
);
|
|
96
|
+
// Free plan is active when activePlanId matches and the plan has no product (no subscription)
|
|
97
|
+
const isActiveFreePlan = $derived(
|
|
98
|
+
!isActiveProduct && plan.category === "free" && activePlanId === plan.planId,
|
|
99
|
+
);
|
|
100
|
+
// Sibling plan in the same <Subscription> group that already has a subscription
|
|
101
|
+
const isSiblingPlan = $derived(
|
|
102
|
+
!isActiveProduct && !isActivePlanOtherCycle && isGroupSubscribed && productId != null && plan.category !== "free" && plan.category !== "enterprise",
|
|
103
|
+
);
|
|
104
|
+
const showSeatCheckoutControls = $derived(
|
|
105
|
+
isSeatPlan && showSeatPicker && !isActiveProduct && !isSiblingPlan,
|
|
106
|
+
);
|
|
107
|
+
const reserveSeatActionHeight = $derived(
|
|
108
|
+
isSeatPlan && showSeatPicker && (isActiveProduct || isSiblingPlan || isActivePlanOtherCycle),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const seatPriceLabel = $derived(
|
|
112
|
+
isActiveProduct && isSeatPlan && subscribedSeats
|
|
113
|
+
? formatSeatPrice(productId, products, subscribedSeats)
|
|
114
|
+
: null,
|
|
115
|
+
);
|
|
116
|
+
const seatsChanged = $derived(
|
|
117
|
+
isActiveProduct && isSeatPlan && subscribedSeats != null && seatAdjustCount !== subscribedSeats,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const checkoutLabel = $derived(
|
|
121
|
+
isActivePlanOtherCycle
|
|
122
|
+
? "Switch interval"
|
|
123
|
+
: isSiblingPlan
|
|
124
|
+
? "Switch plan"
|
|
125
|
+
: plan.billingType === "onetime"
|
|
126
|
+
? "Buy now"
|
|
127
|
+
: "Subscribe",
|
|
128
|
+
);
|
|
129
|
+
const handleCheckout = (payload: { productId: string }) => {
|
|
130
|
+
if ((isSiblingPlan || isActivePlanOtherCycle) && onSwitchPlan) {
|
|
131
|
+
onSwitchPlan({ plan, productId: payload.productId, units: isSeatPlan ? (subscribedSeats ?? effectiveUnits) : effectiveUnits });
|
|
132
|
+
} else {
|
|
133
|
+
onCheckout?.({ plan, productId: payload.productId, units: effectiveUnits });
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const splitPriceLabel = (value: string | null): { main: string; suffix: string | null; tail: string } | null => {
|
|
138
|
+
if (!value) return null;
|
|
139
|
+
const match = value.match(/^(.*?)(\/[a-z0-9]+)(.*)$/i);
|
|
140
|
+
if (!match) return { main: value, suffix: null, tail: "" };
|
|
141
|
+
return {
|
|
142
|
+
main: match[1]?.trim() ?? value,
|
|
143
|
+
suffix: match[2] ?? null,
|
|
144
|
+
tail: match[3]?.trim() ?? "",
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const splitPrice = $derived(splitPriceLabel(seatPriceLabel ?? priceLabel));
|
|
149
|
+
|
|
150
|
+
const descriptionLines = $derived.by<string[]>(() => {
|
|
151
|
+
if (!plan.description) return [];
|
|
152
|
+
return plan.description
|
|
153
|
+
.split(/\r?\n/)
|
|
154
|
+
.map((line) => line.trim())
|
|
155
|
+
.filter(Boolean)
|
|
156
|
+
.map((line) => line.replace(/^(?:[-*]\s+|[✔✓]\s*)/, "").trim())
|
|
157
|
+
.filter(Boolean);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const featureLines = $derived.by<string[]>(() => {
|
|
161
|
+
if (descriptionLines.length < 3) return [];
|
|
162
|
+
return descriptionLines;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const leadDescription = $derived.by<string | null>(() => {
|
|
166
|
+
if (!descriptionLines.length || featureLines.length > 0) return null;
|
|
167
|
+
return descriptionLines[0] ?? null;
|
|
168
|
+
});
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
<section
|
|
172
|
+
class={`relative flex flex-col rounded-2xl bg-surface-base p-6 ${
|
|
173
|
+
plan.recommended ? "border-2 border-primary-border-default" : ""
|
|
174
|
+
} ${className}`}
|
|
175
|
+
>
|
|
176
|
+
<div class="mb-3 flex h-5 items-center justify-between gap-2">
|
|
177
|
+
<h3 class="title-s text-foreground-default">
|
|
178
|
+
{plan.title ?? plan.planId}
|
|
179
|
+
</h3>
|
|
180
|
+
{#if isActiveProduct || isActiveFreePlan}
|
|
181
|
+
<span class="badge-faded-sm">
|
|
182
|
+
{#if isTrialing}
|
|
183
|
+
Free trial{#if trialDaysLeft != null} · {trialDaysLeft} day{trialDaysLeft === 1 ? '' : 's'} left{/if}
|
|
184
|
+
{:else}
|
|
185
|
+
Current plan
|
|
186
|
+
{/if}
|
|
187
|
+
</span>
|
|
188
|
+
{:else if plan.recommended}
|
|
189
|
+
<span class="badge-filled-sm">
|
|
190
|
+
Recommended
|
|
191
|
+
</span>
|
|
192
|
+
{/if}
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div class="flex items-baseline gap-1">
|
|
196
|
+
{#if plan.category === "free"}
|
|
197
|
+
<span class="heading-s text-foreground-default">Free</span>
|
|
198
|
+
{:else if plan.category === "enterprise"}
|
|
199
|
+
<span class="heading-s text-foreground-default">Custom</span>
|
|
200
|
+
{:else if splitPrice}
|
|
201
|
+
<span class="heading-s text-foreground-default">{splitPrice.main}</span>
|
|
202
|
+
{#if splitPrice.suffix}
|
|
203
|
+
<span class="title-s text-foreground-placeholder">{splitPrice.suffix}</span>
|
|
204
|
+
{/if}
|
|
205
|
+
{#if splitPrice.tail}
|
|
206
|
+
<span class="title-s text-foreground-placeholder">{splitPrice.tail}</span>
|
|
207
|
+
{/if}
|
|
208
|
+
{/if}
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
{#if leadDescription}
|
|
212
|
+
<p class="mb-4 body-m text-foreground-muted">{leadDescription}</p>
|
|
213
|
+
{/if}
|
|
214
|
+
|
|
215
|
+
<div class={`mb-4 mt-6 ${showSeatCheckoutControls ? "flex flex-col gap-2" : "flex min-h-8 items-start"}`}>
|
|
216
|
+
{#if showSeatCheckoutControls}
|
|
217
|
+
<div class="flex w-full items-center justify-between rounded-xl bg-surface-subtle py-2 pl-4 pr-2">
|
|
218
|
+
<span class="label-m text-foreground-default">Seats:</span>
|
|
219
|
+
<NumberInput
|
|
220
|
+
value={seatCount}
|
|
221
|
+
min={1}
|
|
222
|
+
compact
|
|
223
|
+
disabled={disableSeats}
|
|
224
|
+
onValueChange={(next) => {
|
|
225
|
+
if (next > 0) seatCount = next;
|
|
226
|
+
}}
|
|
227
|
+
/>
|
|
228
|
+
</div>
|
|
229
|
+
{/if}
|
|
230
|
+
|
|
231
|
+
<div
|
|
232
|
+
class={`${showSeatCheckoutControls ? "w-full" : "flex min-h-8 items-start w-full"} ${
|
|
233
|
+
reserveSeatActionHeight ? "min-h-[4.5rem]" : ""
|
|
234
|
+
}`}
|
|
235
|
+
>
|
|
236
|
+
{#if isActiveProduct && isSeatPlan && showSeatPicker && onUpdateSeats}
|
|
237
|
+
<div class="flex w-full flex-col gap-2">
|
|
238
|
+
{#if editingSeats}
|
|
239
|
+
<div class="flex w-full items-center justify-between rounded-xl bg-surface-subtle py-2 pl-4 pr-2">
|
|
240
|
+
<span class="label-m text-foreground-default">Seats:</span>
|
|
241
|
+
<NumberInput
|
|
242
|
+
value={seatAdjustCount}
|
|
243
|
+
min={1}
|
|
244
|
+
compact
|
|
245
|
+
disabled={disableSeats}
|
|
246
|
+
onValueChange={(next) => {
|
|
247
|
+
if (next > 0) seatAdjustCount = next;
|
|
248
|
+
}}
|
|
249
|
+
/>
|
|
250
|
+
</div>
|
|
251
|
+
<div class="flex w-full items-center gap-2">
|
|
252
|
+
<button
|
|
253
|
+
type="button"
|
|
254
|
+
class="button-faded h-8 w-full"
|
|
255
|
+
onclick={() => { seatAdjustCount = subscribedSeats ?? 1; editingSeats = false; }}
|
|
256
|
+
>
|
|
257
|
+
Cancel
|
|
258
|
+
</button>
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
disabled={disableSeats || !seatsChanged}
|
|
262
|
+
class="button-filled h-8 w-full disabled:cursor-not-allowed disabled:opacity-50"
|
|
263
|
+
onclick={() => onUpdateSeats?.({ units: seatAdjustCount })}
|
|
264
|
+
>
|
|
265
|
+
Update
|
|
266
|
+
</button>
|
|
267
|
+
</div>
|
|
268
|
+
{:else}
|
|
269
|
+
<button type="button" class="button-faded w-full" onclick={() => editingSeats = true}>
|
|
270
|
+
Change seats
|
|
271
|
+
</button>
|
|
272
|
+
{#if onCancelSubscription}
|
|
273
|
+
<button type="button" class="button-outline w-full" onclick={onCancelSubscription}>
|
|
274
|
+
Cancel subscription
|
|
275
|
+
</button>
|
|
276
|
+
{/if}
|
|
277
|
+
{/if}
|
|
278
|
+
</div>
|
|
279
|
+
{:else if isActiveProduct && onCancelSubscription}
|
|
280
|
+
<button type="button" class="button-outline w-full" onclick={onCancelSubscription}>
|
|
281
|
+
Cancel subscription
|
|
282
|
+
</button>
|
|
283
|
+
{:else if isActiveProduct || isActiveFreePlan}
|
|
284
|
+
<!-- Keep CTA row height but intentionally empty when current plan has no action -->
|
|
285
|
+
{:else if (isSiblingPlan || isActivePlanOtherCycle) && productId}
|
|
286
|
+
<CheckoutButton
|
|
287
|
+
{productId}
|
|
288
|
+
disabled={disableSwitch}
|
|
289
|
+
onCheckout={handleCheckout}
|
|
290
|
+
className={`${plan.recommended ? "button-filled" : "button-faded"} w-full`}
|
|
291
|
+
>
|
|
292
|
+
{checkoutLabel}
|
|
293
|
+
</CheckoutButton>
|
|
294
|
+
{:else if plan.category === "enterprise"}
|
|
295
|
+
{#if plan.contactUrl}
|
|
296
|
+
<a
|
|
297
|
+
href={plan.contactUrl}
|
|
298
|
+
class="button-outline w-full"
|
|
299
|
+
>
|
|
300
|
+
Contact sales
|
|
301
|
+
</a>
|
|
302
|
+
{:else if onContactSales}
|
|
303
|
+
<button
|
|
304
|
+
type="button"
|
|
305
|
+
class="button-outline w-full"
|
|
306
|
+
onclick={() => onContactSales?.({ plan })}
|
|
307
|
+
>
|
|
308
|
+
Contact sales
|
|
309
|
+
</button>
|
|
310
|
+
{/if}
|
|
311
|
+
{:else if productId}
|
|
312
|
+
<CheckoutButton
|
|
313
|
+
{productId}
|
|
314
|
+
disabled={disableCheckout}
|
|
315
|
+
onCheckout={handleCheckout}
|
|
316
|
+
className={`${plan.recommended ? "button-filled" : "button-faded"} w-full`}
|
|
317
|
+
>
|
|
318
|
+
{checkoutLabel}
|
|
319
|
+
</CheckoutButton>
|
|
320
|
+
{:else if plan.category !== "free"}
|
|
321
|
+
<span class="body-m text-foreground-muted">
|
|
322
|
+
Configure a checkout handler to activate this plan.
|
|
323
|
+
</span>
|
|
324
|
+
{/if}
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
{#if featureLines.length > 0}
|
|
329
|
+
<div class="w-full pt-4">
|
|
330
|
+
<p class="label-m mb-4 font-semibold text-foreground-default">What's included:</p>
|
|
331
|
+
<ul class="space-y-2">
|
|
332
|
+
{#each featureLines as feature (feature)}
|
|
333
|
+
<li class="flex items-center gap-2">
|
|
334
|
+
<span class="inline-flex h-5 w-5 shrink-0 items-center justify-center text-foreground-muted">
|
|
335
|
+
<svg
|
|
336
|
+
aria-hidden="true"
|
|
337
|
+
viewBox="0 0 24 24"
|
|
338
|
+
fill="none"
|
|
339
|
+
class="h-4 w-4"
|
|
340
|
+
>
|
|
341
|
+
<path
|
|
342
|
+
d="M20 6L9 17L4 12"
|
|
343
|
+
stroke="currentColor"
|
|
344
|
+
stroke-width="2.5"
|
|
345
|
+
stroke-linecap="round"
|
|
346
|
+
stroke-linejoin="round"
|
|
347
|
+
/>
|
|
348
|
+
</svg>
|
|
349
|
+
</span>
|
|
350
|
+
<span class="body-m text-foreground-default">{feature}</span>
|
|
351
|
+
</li>
|
|
352
|
+
{/each}
|
|
353
|
+
</ul>
|
|
354
|
+
</div>
|
|
355
|
+
{/if}
|
|
356
|
+
</section>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import BillingToggle from "./BillingToggle.svelte";
|
|
3
|
+
import PricingCard from "./PricingCard.svelte";
|
|
4
|
+
import type { BillingSnapshot, UIPlanEntry, RecurringCycle } from "../../core/types.js";
|
|
5
|
+
import type { ConnectedProduct } from "../widgets/types.js";
|
|
6
|
+
import { SvelteSet } from "svelte/reactivity";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
plans?: UIPlanEntry[];
|
|
10
|
+
snapshot?: BillingSnapshot | null;
|
|
11
|
+
selectedCycle?: RecurringCycle;
|
|
12
|
+
products?: ConnectedProduct[];
|
|
13
|
+
subscriptionProductId?: string | null;
|
|
14
|
+
subscriptionStatus?: string | null;
|
|
15
|
+
subscriptionTrialEnd?: string | null;
|
|
16
|
+
units?: number;
|
|
17
|
+
showSeatPicker?: boolean;
|
|
18
|
+
twoColumnLayout?: boolean;
|
|
19
|
+
subscribedSeats?: number | null;
|
|
20
|
+
isGroupSubscribed?: boolean;
|
|
21
|
+
disableCheckout?: boolean;
|
|
22
|
+
disableSwitch?: boolean;
|
|
23
|
+
disableSeats?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
onCycleChange?: (cycle: RecurringCycle) => void;
|
|
26
|
+
onCheckout?: (payload: {
|
|
27
|
+
plan: UIPlanEntry;
|
|
28
|
+
productId: string;
|
|
29
|
+
units?: number;
|
|
30
|
+
}) => Promise<void> | void;
|
|
31
|
+
onSwitchPlan?: (payload: {
|
|
32
|
+
plan: UIPlanEntry;
|
|
33
|
+
productId: string;
|
|
34
|
+
units?: number;
|
|
35
|
+
}) => Promise<void> | void;
|
|
36
|
+
onUpdateSeats?: (payload: { units: number }) => Promise<void> | void;
|
|
37
|
+
onContactSales?: (payload: { plan: UIPlanEntry }) => Promise<void> | void;
|
|
38
|
+
onCancelSubscription?: () => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let {
|
|
42
|
+
plans = [],
|
|
43
|
+
snapshot = null,
|
|
44
|
+
selectedCycle = undefined,
|
|
45
|
+
products = [],
|
|
46
|
+
subscriptionProductId = null,
|
|
47
|
+
subscriptionStatus = null,
|
|
48
|
+
subscriptionTrialEnd = null,
|
|
49
|
+
units = undefined,
|
|
50
|
+
showSeatPicker = false,
|
|
51
|
+
twoColumnLayout = false,
|
|
52
|
+
subscribedSeats = null,
|
|
53
|
+
isGroupSubscribed = false,
|
|
54
|
+
disableCheckout = false,
|
|
55
|
+
disableSwitch = false,
|
|
56
|
+
disableSeats = false,
|
|
57
|
+
className = "",
|
|
58
|
+
onCycleChange,
|
|
59
|
+
onCheckout,
|
|
60
|
+
onSwitchPlan,
|
|
61
|
+
onUpdateSeats,
|
|
62
|
+
onContactSales,
|
|
63
|
+
onCancelSubscription,
|
|
64
|
+
}: Props = $props();
|
|
65
|
+
|
|
66
|
+
const toUniqueCycles = (entries: UIPlanEntry[]) => {
|
|
67
|
+
const set = new SvelteSet<RecurringCycle>();
|
|
68
|
+
for (const plan of entries) {
|
|
69
|
+
for (const cycle of plan.billingCycles ?? []) {
|
|
70
|
+
set.add(cycle);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return Array.from(set);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const availableCycles = $derived(toUniqueCycles(plans));
|
|
77
|
+
const hasEnterprisePlan = $derived(plans.some((plan) => plan.category === "enterprise"));
|
|
78
|
+
const effectiveCycle = $derived(
|
|
79
|
+
selectedCycle ?? snapshot?.recurringCycle ?? availableCycles[0],
|
|
80
|
+
);
|
|
81
|
+
const showToggle = $derived(availableCycles.length > 1);
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<section class={className}>
|
|
85
|
+
{#if showToggle}
|
|
86
|
+
<div class="mb-[6.5rem] flex justify-center">
|
|
87
|
+
<BillingToggle
|
|
88
|
+
cycles={availableCycles}
|
|
89
|
+
value={effectiveCycle}
|
|
90
|
+
onValueChange={onCycleChange}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
{/if}
|
|
94
|
+
|
|
95
|
+
<div class={`grid grid-cols-1 gap-1 ${showSeatPicker || twoColumnLayout ? "md:grid-cols-2" : hasEnterprisePlan ? "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4" : "sm:grid-cols-2 md:grid-cols-3"}`}>
|
|
96
|
+
{#each plans as plan (plan.planId)}
|
|
97
|
+
<PricingCard
|
|
98
|
+
{plan}
|
|
99
|
+
selectedCycle={effectiveCycle}
|
|
100
|
+
activePlanId={snapshot?.activePlanId}
|
|
101
|
+
{subscriptionProductId}
|
|
102
|
+
{subscriptionStatus}
|
|
103
|
+
{subscriptionTrialEnd}
|
|
104
|
+
{products}
|
|
105
|
+
{units}
|
|
106
|
+
{showSeatPicker}
|
|
107
|
+
{subscribedSeats}
|
|
108
|
+
{isGroupSubscribed}
|
|
109
|
+
{disableCheckout}
|
|
110
|
+
{disableSwitch}
|
|
111
|
+
{disableSeats}
|
|
112
|
+
{onCheckout}
|
|
113
|
+
{onSwitchPlan}
|
|
114
|
+
{onUpdateSeats}
|
|
115
|
+
{onContactSales}
|
|
116
|
+
{onCancelSubscription}
|
|
117
|
+
className=""
|
|
118
|
+
/>
|
|
119
|
+
{/each}
|
|
120
|
+
</div>
|
|
121
|
+
</section>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/* global $props, $derived */
|
|
3
|
+
import type { BillingSnapshot } from "../../core/types.js";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
snapshot?: BillingSnapshot | null;
|
|
7
|
+
className?: string;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
onResume?: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { snapshot = null, className = "", isLoading = false, onResume = undefined }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const show = $derived(snapshot?.metadata?.cancelAtPeriodEnd === true);
|
|
15
|
+
const currentPeriodEnd = $derived(
|
|
16
|
+
typeof snapshot?.metadata?.currentPeriodEnd === "string"
|
|
17
|
+
? snapshot.metadata.currentPeriodEnd
|
|
18
|
+
: undefined,
|
|
19
|
+
);
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
{#if show}
|
|
23
|
+
<div
|
|
24
|
+
class={`rounded-xl bg-surface-base p-6 ${className}`}
|
|
25
|
+
>
|
|
26
|
+
<div class="flex flex-col gap-6 md:flex-row md:items-start md:justify-between md:gap-4">
|
|
27
|
+
<div class="space-y-2">
|
|
28
|
+
<p class="title-s text-foreground-default">Cancellation scheduled</p>
|
|
29
|
+
<p class="body-m text-foreground-muted">
|
|
30
|
+
You will continue to have access until the end of your current billing period
|
|
31
|
+
{#if currentPeriodEnd} ({new Date(currentPeriodEnd).toLocaleDateString()}){/if}.
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
{#if onResume}
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
class="button-faded h-8 shrink-0 disabled:cursor-not-allowed disabled:opacity-50"
|
|
38
|
+
disabled={isLoading}
|
|
39
|
+
onclick={onResume}
|
|
40
|
+
>
|
|
41
|
+
{isLoading ? "Resuming…" : "Undo cancellation"}
|
|
42
|
+
</button>
|
|
43
|
+
{/if}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
{/if}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import SegmentGroup from "./SegmentGroup.svelte";
|
|
3
|
+
|
|
4
|
+
export type SegmentControlItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
items?: SegmentControlItem[];
|
|
12
|
+
value?: string | null;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
onValueChange?: (value: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
items = [],
|
|
21
|
+
value = undefined,
|
|
22
|
+
defaultValue = undefined,
|
|
23
|
+
disabled = false,
|
|
24
|
+
className = "",
|
|
25
|
+
onValueChange,
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
{#if items.length > 1}
|
|
30
|
+
<SegmentGroup
|
|
31
|
+
{items}
|
|
32
|
+
{value}
|
|
33
|
+
{defaultValue}
|
|
34
|
+
{disabled}
|
|
35
|
+
{onValueChange}
|
|
36
|
+
className={className}
|
|
37
|
+
/>
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SegmentGroup as ArkSegmentGroup } from "@ark-ui/svelte/segment-group";
|
|
3
|
+
|
|
4
|
+
export type SegmentGroupItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
items?: SegmentGroupItem[];
|
|
12
|
+
value?: string | null;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
onValueChange?: (value: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
items = [],
|
|
21
|
+
value = undefined,
|
|
22
|
+
defaultValue = undefined,
|
|
23
|
+
disabled = false,
|
|
24
|
+
className = "",
|
|
25
|
+
onValueChange,
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
{#if items.length > 1}
|
|
30
|
+
<ArkSegmentGroup.Root
|
|
31
|
+
{value}
|
|
32
|
+
{defaultValue}
|
|
33
|
+
{disabled}
|
|
34
|
+
class={`segment-group ${className}`}
|
|
35
|
+
onValueChange={(details: { value: string }) => onValueChange?.(details.value)}
|
|
36
|
+
>
|
|
37
|
+
<ArkSegmentGroup.Indicator class="segment-group-indicator" />
|
|
38
|
+
{#each items as item (item.value)}
|
|
39
|
+
<ArkSegmentGroup.Item
|
|
40
|
+
value={item.value}
|
|
41
|
+
disabled={item.disabled}
|
|
42
|
+
class="segment-group-item"
|
|
43
|
+
>
|
|
44
|
+
<ArkSegmentGroup.ItemText class="segment-group-item-text label-m">
|
|
45
|
+
{item.label}
|
|
46
|
+
</ArkSegmentGroup.ItemText>
|
|
47
|
+
<ArkSegmentGroup.ItemControl class="segment-group-item-control" />
|
|
48
|
+
<ArkSegmentGroup.ItemHiddenInput />
|
|
49
|
+
</ArkSegmentGroup.Item>
|
|
50
|
+
{/each}
|
|
51
|
+
</ArkSegmentGroup.Root>
|
|
52
|
+
{/if}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { BillingSnapshot } from "../../core/types.js";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
snapshot?: BillingSnapshot | null;
|
|
6
|
+
trialEndsAt?: string | null;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { snapshot, trialEndsAt = null, className = "" }: Props = $props();
|
|
11
|
+
|
|
12
|
+
const show = $derived(snapshot?.activeCategory === "trial");
|
|
13
|
+
const resolvedTrialEnd = $derived(
|
|
14
|
+
trialEndsAt ??
|
|
15
|
+
(typeof snapshot?.metadata?.trialEnd === "string"
|
|
16
|
+
? snapshot.metadata.trialEnd
|
|
17
|
+
: null),
|
|
18
|
+
);
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
{#if show}
|
|
22
|
+
<div
|
|
23
|
+
class={`rounded-lg border border-sky-300 bg-sky-50 px-4 py-3 text-sm text-sky-900 dark:border-sky-800 dark:bg-sky-950/40 dark:text-sky-200 ${className}`}
|
|
24
|
+
>
|
|
25
|
+
Trial plan active
|
|
26
|
+
{#if resolvedTrialEnd}
|
|
27
|
+
until {new Date(resolvedTrialEnd).toLocaleDateString()}.
|
|
28
|
+
{:else}
|
|
29
|
+
. Upgrade before your trial ends to avoid interruptions.
|
|
30
|
+
{/if}
|
|
31
|
+
</div>
|
|
32
|
+
{/if}
|