@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
package/src/library.css
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* @mmailaender/convex-creem — importable design-system + component CSS.
|
|
2
|
+
Consumers import this alongside Tailwind to get full design-system support:
|
|
3
|
+
|
|
4
|
+
@import "tailwindcss";
|
|
5
|
+
@import "@mmailaender/convex-creem/styles";
|
|
6
|
+
|
|
7
|
+
This file bundles:
|
|
8
|
+
1. Design-system tokens, base styles, and @utility definitions
|
|
9
|
+
2. @source directives so Tailwind scans the library's own component files
|
|
10
|
+
|
|
11
|
+
The @source globs below resolve relative to THIS file (src/), keeping them
|
|
12
|
+
inside the same directory tree as the components. This is the Tailwind v4
|
|
13
|
+
recommended pattern for libraries — it works in both dev (HMR) and
|
|
14
|
+
production builds, unlike @source paths that traverse above the consumer's
|
|
15
|
+
project root with ../../. */
|
|
16
|
+
|
|
17
|
+
@import "./design-system/index.css";
|
|
18
|
+
|
|
19
|
+
@source "./svelte/**/*.{svelte,ts}";
|
|
20
|
+
@source "./react/**/*.{tsx,ts}";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
export {
|
|
3
|
+
parseCheckoutSuccessParams,
|
|
4
|
+
hasCheckoutSuccessParams,
|
|
5
|
+
} from "../core/payments.js";
|
|
6
|
+
export { pendingCheckout } from "../core/pendingCheckout.js";
|
|
7
|
+
export { useCheckoutSuccessParams } from "./hooks/useCheckoutSuccessParams.js";
|
|
8
|
+
export { BillingToggle } from "./primitives/BillingToggle.js";
|
|
9
|
+
export { SegmentGroup } from "./primitives/SegmentGroup.js";
|
|
10
|
+
export type { SegmentGroupItem } from "./primitives/SegmentGroup.js";
|
|
11
|
+
export { SegmentControl } from "./primitives/SegmentControl.js";
|
|
12
|
+
export type { SegmentControlItem } from "./primitives/SegmentControl.js";
|
|
13
|
+
export { NumberInput } from "./primitives/NumberInput.js";
|
|
14
|
+
export { CheckoutButton } from "./primitives/CheckoutButton.js";
|
|
15
|
+
export { CustomerPortalButton } from "./primitives/CustomerPortalButton.js";
|
|
16
|
+
export { PricingCard } from "./primitives/PricingCard.js";
|
|
17
|
+
export { PricingSection } from "./primitives/PricingSection.js";
|
|
18
|
+
export { BillingGate } from "./primitives/BillingGate.js";
|
|
19
|
+
export { ScheduledChangeBanner } from "./primitives/ScheduledChangeBanner.js";
|
|
20
|
+
export { PaymentWarningBanner } from "./primitives/PaymentWarningBanner.js";
|
|
21
|
+
export { TrialLimitBanner } from "./primitives/TrialLimitBanner.js";
|
|
22
|
+
export { OneTimeCheckoutButton } from "./primitives/OneTimeCheckoutButton.js";
|
|
23
|
+
export { OneTimePaymentStatusBadge } from "./primitives/OneTimePaymentStatusBadge.js";
|
|
24
|
+
export { CheckoutSuccessSummary } from "./primitives/CheckoutSuccessSummary.js";
|
|
25
|
+
export { Subscription, Product, BillingPortal } from "./widgets/index.js";
|
|
26
|
+
export type {
|
|
27
|
+
BillingSnapshot,
|
|
28
|
+
CheckoutSuccessParams,
|
|
29
|
+
OneTimePaymentStatus,
|
|
30
|
+
RecurringCycle,
|
|
31
|
+
} from "../core/types.js";
|
|
32
|
+
export {
|
|
33
|
+
hasBillingAction,
|
|
34
|
+
isEnterpriseBilling,
|
|
35
|
+
isOneTimeBilling,
|
|
36
|
+
isTerminalPaymentStatus,
|
|
37
|
+
shouldShowBillingCycleToggle,
|
|
38
|
+
} from "../core/selectors.js";
|
|
39
|
+
export type {
|
|
40
|
+
BillingPermissions,
|
|
41
|
+
CheckoutIntent,
|
|
42
|
+
ConnectedBillingApi,
|
|
43
|
+
ConnectedBillingModel,
|
|
44
|
+
ProductType,
|
|
45
|
+
SubscriptionPlanType,
|
|
46
|
+
Transition,
|
|
47
|
+
} from "./widgets/types.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
import type { AvailableAction, BillingSnapshot } from "../../core/types.js";
|
|
3
|
+
import { hasBillingActionLocal } from "../shared.js";
|
|
4
|
+
|
|
5
|
+
export const BillingGate = ({
|
|
6
|
+
snapshot,
|
|
7
|
+
requiredActions,
|
|
8
|
+
fallback = null,
|
|
9
|
+
children,
|
|
10
|
+
}: PropsWithChildren<{
|
|
11
|
+
snapshot?: BillingSnapshot | null;
|
|
12
|
+
requiredActions: AvailableAction | AvailableAction[];
|
|
13
|
+
fallback?: ReactNode;
|
|
14
|
+
}>) => {
|
|
15
|
+
if (!snapshot) {
|
|
16
|
+
return <>{fallback}</>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const actions = Array.isArray(requiredActions)
|
|
20
|
+
? requiredActions
|
|
21
|
+
: [requiredActions];
|
|
22
|
+
const canRender = actions.every((action) =>
|
|
23
|
+
hasBillingActionLocal(snapshot, action),
|
|
24
|
+
);
|
|
25
|
+
return <>{canRender ? children : fallback}</>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { RecurringCycle } from "../../core/types.js";
|
|
2
|
+
import { formatRecurringCycle } from "../shared.js";
|
|
3
|
+
import { SegmentGroup } from "./SegmentGroup.js";
|
|
4
|
+
|
|
5
|
+
export const BillingToggle = ({
|
|
6
|
+
cycles = [],
|
|
7
|
+
value,
|
|
8
|
+
onValueChange,
|
|
9
|
+
className = "",
|
|
10
|
+
}: {
|
|
11
|
+
cycles?: RecurringCycle[];
|
|
12
|
+
value?: RecurringCycle;
|
|
13
|
+
onValueChange?: (cycle: RecurringCycle) => void;
|
|
14
|
+
className?: string;
|
|
15
|
+
}) => {
|
|
16
|
+
if (cycles.length < 2) return null;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<SegmentGroup
|
|
20
|
+
items={cycles.map((cycle) => ({
|
|
21
|
+
value: cycle,
|
|
22
|
+
label: formatRecurringCycle(cycle),
|
|
23
|
+
}))}
|
|
24
|
+
value={value}
|
|
25
|
+
onValueChange={(segment) => onValueChange?.(segment as RecurringCycle)}
|
|
26
|
+
className={className}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useState, type PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
export const CheckoutButton = ({
|
|
4
|
+
productId,
|
|
5
|
+
href,
|
|
6
|
+
disabled = false,
|
|
7
|
+
className = "",
|
|
8
|
+
onCheckout,
|
|
9
|
+
children,
|
|
10
|
+
}: PropsWithChildren<{
|
|
11
|
+
productId: string;
|
|
12
|
+
href?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
onCheckout?: (payload: { productId: string }) => Promise<void> | void;
|
|
16
|
+
}>) => {
|
|
17
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
18
|
+
|
|
19
|
+
const handleClick = async () => {
|
|
20
|
+
if (disabled || isLoading || !onCheckout) return;
|
|
21
|
+
setIsLoading(true);
|
|
22
|
+
try {
|
|
23
|
+
await onCheckout({ productId });
|
|
24
|
+
} finally {
|
|
25
|
+
setIsLoading(false);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (onCheckout) {
|
|
30
|
+
return (
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
className={`button-filled disabled:cursor-not-allowed disabled:opacity-60 ${className}`}
|
|
34
|
+
disabled={disabled}
|
|
35
|
+
onClick={handleClick}
|
|
36
|
+
>
|
|
37
|
+
{children ?? (isLoading ? "Loading..." : "Checkout")}
|
|
38
|
+
</button>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<a href={href} className={`button-filled ${className}`}>
|
|
44
|
+
{children ?? "Checkout"}
|
|
45
|
+
</a>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasCheckoutSuccessParams,
|
|
3
|
+
parseCheckoutSuccessParams,
|
|
4
|
+
} from "../../core/payments.js";
|
|
5
|
+
import type { CheckoutSuccessParams } from "../../core/types.js";
|
|
6
|
+
|
|
7
|
+
export const CheckoutSuccessSummary = ({
|
|
8
|
+
params,
|
|
9
|
+
search = "",
|
|
10
|
+
className = "",
|
|
11
|
+
}: {
|
|
12
|
+
params?: CheckoutSuccessParams;
|
|
13
|
+
search?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}) => {
|
|
16
|
+
const fromSearch = parseCheckoutSuccessParams(search);
|
|
17
|
+
const parsed = params ?? fromSearch;
|
|
18
|
+
if (!hasCheckoutSuccessParams(parsed)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
className={`rounded-lg border border-emerald-300 bg-emerald-50 px-4 py-3 text-sm text-emerald-900 dark:border-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200 ${className}`}
|
|
25
|
+
>
|
|
26
|
+
<p className="font-medium">Checkout completed successfully.</p>
|
|
27
|
+
<ul className="mt-2 space-y-1">
|
|
28
|
+
{parsed.checkoutId && <li>Checkout: {parsed.checkoutId}</li>}
|
|
29
|
+
{parsed.orderId && <li>Order: {parsed.orderId}</li>}
|
|
30
|
+
{parsed.customerId && <li>Customer: {parsed.customerId}</li>}
|
|
31
|
+
{parsed.productId && <li>Product: {parsed.productId}</li>}
|
|
32
|
+
{parsed.requestId && <li>Request: {parsed.requestId}</li>}
|
|
33
|
+
</ul>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState, type PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
export const CustomerPortalButton = ({
|
|
4
|
+
href,
|
|
5
|
+
disabled = false,
|
|
6
|
+
className = "",
|
|
7
|
+
onOpenPortal,
|
|
8
|
+
children,
|
|
9
|
+
}: PropsWithChildren<{
|
|
10
|
+
href?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
onOpenPortal?: () => Promise<void> | void;
|
|
14
|
+
}>) => {
|
|
15
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
16
|
+
|
|
17
|
+
const handleClick = async () => {
|
|
18
|
+
if (disabled || isLoading || !onOpenPortal) return;
|
|
19
|
+
setIsLoading(true);
|
|
20
|
+
try {
|
|
21
|
+
await onOpenPortal();
|
|
22
|
+
} finally {
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (onOpenPortal) {
|
|
28
|
+
return (
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
className={`${className || "button-outline"} disabled:cursor-not-allowed disabled:opacity-60 cursor-pointer`}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
onClick={handleClick}
|
|
34
|
+
>
|
|
35
|
+
{children ?? (isLoading ? "Loading..." : "Manage billing")}
|
|
36
|
+
</button>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<a
|
|
42
|
+
href={href}
|
|
43
|
+
target="_blank"
|
|
44
|
+
rel="noopener noreferrer"
|
|
45
|
+
className={className || "button-outline"}
|
|
46
|
+
>
|
|
47
|
+
{children ?? "Manage billing"}
|
|
48
|
+
</a>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ChangeEvent } from "react";
|
|
2
|
+
|
|
3
|
+
export const NumberInput = ({
|
|
4
|
+
value = 1,
|
|
5
|
+
min = Number.NEGATIVE_INFINITY,
|
|
6
|
+
max = Number.POSITIVE_INFINITY,
|
|
7
|
+
step = 1,
|
|
8
|
+
compact = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
className = "",
|
|
11
|
+
onValueChange,
|
|
12
|
+
}: {
|
|
13
|
+
value?: number;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
step?: number;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
onValueChange?: (value: number) => void;
|
|
21
|
+
}) => {
|
|
22
|
+
const clamp = (candidate: number) => Math.min(max, Math.max(min, candidate));
|
|
23
|
+
|
|
24
|
+
const setValue = (candidate: number) => {
|
|
25
|
+
const next = clamp(candidate);
|
|
26
|
+
onValueChange?.(next);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const decrement = () => setValue((value ?? 0) - step);
|
|
30
|
+
const increment = () => setValue((value ?? 0) + step);
|
|
31
|
+
|
|
32
|
+
const handleInput = (e: ChangeEvent<HTMLInputElement>) => {
|
|
33
|
+
const parsed = Number(e.currentTarget.value);
|
|
34
|
+
if (!Number.isFinite(parsed)) return;
|
|
35
|
+
setValue(parsed);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className={`number-input ${className}`}>
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
aria-label="Decrease value"
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
className="icon-button-sm"
|
|
45
|
+
onClick={decrement}
|
|
46
|
+
>
|
|
47
|
+
<svg
|
|
48
|
+
aria-hidden="true"
|
|
49
|
+
viewBox="0 0 256 256"
|
|
50
|
+
fill="currentColor"
|
|
51
|
+
className="h-4 w-4 text-foreground-on-tonal"
|
|
52
|
+
>
|
|
53
|
+
<path d="M216,128a12,12,0,0,1-12,12H52a12,12,0,0,1,0-24H204A12,12,0,0,1,216,128Z" />
|
|
54
|
+
</svg>
|
|
55
|
+
</button>
|
|
56
|
+
|
|
57
|
+
<input
|
|
58
|
+
type="number"
|
|
59
|
+
className={`input-ghost ${compact ? "number-input-value-compact" : "number-input-value"} max-w-12 input-no-spinner`}
|
|
60
|
+
value={value}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
onChange={handleInput}
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
aria-label="Increase value"
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
className="icon-button-sm"
|
|
70
|
+
onClick={increment}
|
|
71
|
+
>
|
|
72
|
+
<svg
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
viewBox="0 0 256 256"
|
|
75
|
+
fill="currentColor"
|
|
76
|
+
className="h-4 w-4 text-foreground-on-tonal"
|
|
77
|
+
>
|
|
78
|
+
<path d="M216,128a12,12,0,0,1-12,12H140v64a12,12,0,0,1-24,0V140H52a12,12,0,0,1,0-24h64V52a12,12,0,0,1,24,0v64h64A12,12,0,0,1,216,128Z" />
|
|
79
|
+
</svg>
|
|
80
|
+
</button>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
2
|
+
import { CheckoutButton } from "./CheckoutButton.js";
|
|
3
|
+
|
|
4
|
+
export const OneTimeCheckoutButton = ({
|
|
5
|
+
productId,
|
|
6
|
+
href,
|
|
7
|
+
disabled = false,
|
|
8
|
+
className = "",
|
|
9
|
+
onCheckout,
|
|
10
|
+
children,
|
|
11
|
+
}: PropsWithChildren<{
|
|
12
|
+
productId: string;
|
|
13
|
+
href?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
onCheckout?: (payload: { productId: string }) => Promise<void> | void;
|
|
17
|
+
}>) => (
|
|
18
|
+
<CheckoutButton
|
|
19
|
+
productId={productId}
|
|
20
|
+
href={href}
|
|
21
|
+
disabled={disabled}
|
|
22
|
+
className={className}
|
|
23
|
+
onCheckout={onCheckout}
|
|
24
|
+
>
|
|
25
|
+
{children ?? "Buy now"}
|
|
26
|
+
</CheckoutButton>
|
|
27
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OneTimePaymentStatus } from "../../core/types.js";
|
|
2
|
+
|
|
3
|
+
const labels: Record<OneTimePaymentStatus, string> = {
|
|
4
|
+
pending: "Pending",
|
|
5
|
+
paid: "Paid",
|
|
6
|
+
refunded: "Refunded",
|
|
7
|
+
partially_refunded: "Partially refunded",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const OneTimePaymentStatusBadge = ({
|
|
11
|
+
status,
|
|
12
|
+
className = "",
|
|
13
|
+
}: {
|
|
14
|
+
status: OneTimePaymentStatus;
|
|
15
|
+
className?: string;
|
|
16
|
+
}) => {
|
|
17
|
+
return <span className={className}>{labels[status]}</span>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import type { BillingSnapshot, PaymentSnapshot } from "../../core/types.js";
|
|
3
|
+
|
|
4
|
+
export const PaymentWarningBanner = ({
|
|
5
|
+
snapshot,
|
|
6
|
+
payment,
|
|
7
|
+
className = "",
|
|
8
|
+
}: {
|
|
9
|
+
snapshot?: BillingSnapshot | null;
|
|
10
|
+
payment?: PaymentSnapshot | null;
|
|
11
|
+
className?: string;
|
|
12
|
+
}) => {
|
|
13
|
+
const activePayment = payment ?? snapshot?.payment ?? null;
|
|
14
|
+
|
|
15
|
+
const message = useMemo(() => {
|
|
16
|
+
if (!activePayment || activePayment.status === "paid") return null;
|
|
17
|
+
if (activePayment.status === "pending")
|
|
18
|
+
return "Your payment is pending confirmation. Wait for webhook confirmation before granting permanent access.";
|
|
19
|
+
if (activePayment.status === "partially_refunded")
|
|
20
|
+
return "This payment was partially refunded. Review entitlements that depend on purchase amount.";
|
|
21
|
+
return "This payment was refunded. Access should generally be revoked or downgraded.";
|
|
22
|
+
}, [activePayment]);
|
|
23
|
+
|
|
24
|
+
if (!message) return null;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className={`rounded-lg border border-rose-300 bg-rose-50 px-4 py-3 text-sm text-rose-900 dark:border-rose-800 dark:bg-rose-950/40 dark:text-rose-200 ${className}`}
|
|
29
|
+
>
|
|
30
|
+
{message}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|