@sudobility/subscription-components 1.0.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/README.md +122 -0
- package/dist/__tests__/setup.d.ts +1 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +3191 -0
- package/dist/index.umd.js +1 -0
- package/dist/lib/cn.d.ts +6 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/subscription-layout.d.ts +105 -0
- package/dist/subscription-layout.d.ts.map +1 -0
- package/dist/subscription-provider.d.ts +40 -0
- package/dist/subscription-provider.d.ts.map +1 -0
- package/dist/subscription-tile.d.ts +61 -0
- package/dist/subscription-tile.d.ts.map +1 -0
- package/dist/types.d.ts +119 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +91 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @sudobility/subscription-components
|
|
2
|
+
|
|
3
|
+
Subscription UI components for React with RevenueCat integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sudobility/subscription-components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
- `react` (^18.0.0 || ^19.0.0)
|
|
14
|
+
- `react-dom` (^18.0.0 || ^19.0.0)
|
|
15
|
+
- `@sudobility/components` (^4.0.0)
|
|
16
|
+
- `@sudobility/design` (^1.0.0)
|
|
17
|
+
- `@revenuecat/purchases-js` (^1.0.0) - optional, only needed for RevenueCat integration
|
|
18
|
+
|
|
19
|
+
## Components
|
|
20
|
+
|
|
21
|
+
### SubscriptionTile
|
|
22
|
+
|
|
23
|
+
A customizable subscription plan tile component that displays pricing, features, and promotional information.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { SubscriptionTile } from '@sudobility/subscription-components';
|
|
27
|
+
|
|
28
|
+
<SubscriptionTile
|
|
29
|
+
id="yearly"
|
|
30
|
+
title="Annual Plan"
|
|
31
|
+
price="$99.99"
|
|
32
|
+
periodLabel="/year"
|
|
33
|
+
features={['Unlimited access', 'Priority support', 'Early features']}
|
|
34
|
+
isSelected={selected === 'yearly'}
|
|
35
|
+
onSelect={() => setSelected('yearly')}
|
|
36
|
+
topBadge={{ text: 'Best Value', color: 'purple' }}
|
|
37
|
+
discountBadge={{ text: 'Save 40%', isBestValue: true }}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### SubscriptionLayout
|
|
42
|
+
|
|
43
|
+
A container component for subscription selection UI with status display and action buttons.
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { SubscriptionLayout, SubscriptionTile } from '@sudobility/subscription-components';
|
|
47
|
+
|
|
48
|
+
<SubscriptionLayout
|
|
49
|
+
title="Choose Your Plan"
|
|
50
|
+
currentStatus={{
|
|
51
|
+
isActive: true,
|
|
52
|
+
activeContent: {
|
|
53
|
+
title: 'Active Subscription',
|
|
54
|
+
fields: [
|
|
55
|
+
{ label: 'Plan', value: 'Annual' },
|
|
56
|
+
{ label: 'Expires', value: 'Dec 31, 2025' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
}}
|
|
60
|
+
primaryAction={{
|
|
61
|
+
label: 'Subscribe Now',
|
|
62
|
+
onClick: handleSubscribe,
|
|
63
|
+
}}
|
|
64
|
+
secondaryAction={{
|
|
65
|
+
label: 'Restore Purchase',
|
|
66
|
+
onClick: handleRestore,
|
|
67
|
+
}}
|
|
68
|
+
error={error}
|
|
69
|
+
>
|
|
70
|
+
{plans.map(plan => (
|
|
71
|
+
<SubscriptionTile key={plan.id} {...plan} />
|
|
72
|
+
))}
|
|
73
|
+
</SubscriptionLayout>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### SubscriptionProvider
|
|
77
|
+
|
|
78
|
+
A context provider for RevenueCat subscription management.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { SubscriptionProvider, useSubscriptionContext } from '@sudobility/subscription-components';
|
|
82
|
+
|
|
83
|
+
// Wrap your app
|
|
84
|
+
<SubscriptionProvider
|
|
85
|
+
apiKey="your_revenuecat_api_key"
|
|
86
|
+
entitlementId="premium"
|
|
87
|
+
onError={(error) => console.error(error)}
|
|
88
|
+
>
|
|
89
|
+
<App />
|
|
90
|
+
</SubscriptionProvider>
|
|
91
|
+
|
|
92
|
+
// Use in components
|
|
93
|
+
function PricingPage() {
|
|
94
|
+
const {
|
|
95
|
+
products,
|
|
96
|
+
currentSubscription,
|
|
97
|
+
isLoading,
|
|
98
|
+
purchase,
|
|
99
|
+
restore,
|
|
100
|
+
} = useSubscriptionContext();
|
|
101
|
+
|
|
102
|
+
// ...
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Localization
|
|
107
|
+
|
|
108
|
+
All text labels are passed through callbacks, allowing full control over localization:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<SubscriptionTile
|
|
112
|
+
title={t('plans.annual.title')}
|
|
113
|
+
price={formatCurrency(99.99)}
|
|
114
|
+
periodLabel={t('periods.year')}
|
|
115
|
+
features={t('plans.annual.features', { returnObjects: true })}
|
|
116
|
+
// ...
|
|
117
|
+
/>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sudobility/subscription-components
|
|
3
|
+
*
|
|
4
|
+
* Subscription UI components for React with RevenueCat integration.
|
|
5
|
+
* All components support full localization - text labels are passed by the consumer.
|
|
6
|
+
*/
|
|
7
|
+
export { SubscriptionTile, type SubscriptionTileProps } from './subscription-tile';
|
|
8
|
+
export { SubscriptionLayout, type SubscriptionLayoutProps, type SubscriptionStatusConfig, type ActionButtonConfig, } from './subscription-layout';
|
|
9
|
+
export { SubscriptionProvider, useSubscriptionContext, clearRevenueCatCheckoutSessions, closeRevenueCatInstance, type SubscriptionProviderProps, } from './subscription-provider';
|
|
10
|
+
export type { SubscriptionProduct, SubscriptionStatus, SubscriptionContextValue, SubscriptionProviderConfig, BadgeConfig, DiscountBadgeConfig, PremiumCalloutConfig, } from './types';
|
|
11
|
+
export { cn } from './lib/cn';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,uBAAuB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC"}
|