@solvapay/react 1.0.8-preview.5 → 1.0.8-preview.7
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 +12 -95
- package/dist/CancelPlanButton-Bb7cvym9.d.cts +1105 -0
- package/dist/CancelPlanButton-CieT9swn.d.cts +1102 -0
- package/dist/CancelPlanButton-Cq117t7h.d.ts +1105 -0
- package/dist/CancelPlanButton-f56UlQN-.d.ts +1102 -0
- package/dist/PaymentForm-B5dw0i1X.d.ts +934 -0
- package/dist/PaymentForm-CesoRQWu.d.cts +934 -0
- package/dist/chunk-5FZBOPIW.js +4763 -0
- package/dist/chunk-C7SKOENW.js +1889 -0
- package/dist/chunk-ISYAH4ZL.js +1889 -0
- package/dist/chunk-MOP3ZBGC.js +4749 -0
- package/dist/chunk-TP4JPKE2.js +3126 -0
- package/dist/chunk-VTGIXJQU.js +4755 -0
- package/dist/chunk-XMQ4GBWQ.js +4752 -0
- package/dist/index-DLl3UwO3.d.ts +798 -0
- package/dist/index-Sj2lHLl8.d.cts +798 -0
- package/dist/index.cjs +11 -10
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/primitives/index.cjs +4 -6
- package/dist/primitives/index.d.cts +2 -2
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +1 -1
- package/dist/src/PaymentForm.d.ts +56 -0
- package/dist/src/PaymentForm.d.ts.map +1 -0
- package/dist/src/PaymentForm.js +212 -0
- package/dist/src/PaymentForm.js.map +1 -0
- package/dist/src/SolvaPayProvider.d.ts +84 -0
- package/dist/src/SolvaPayProvider.d.ts.map +1 -0
- package/dist/src/SolvaPayProvider.js +537 -0
- package/dist/src/SolvaPayProvider.js.map +1 -0
- package/dist/src/adapters/auth.d.ts +43 -0
- package/dist/src/adapters/auth.d.ts.map +1 -0
- package/dist/src/adapters/auth.js +38 -0
- package/dist/src/adapters/auth.js.map +1 -0
- package/dist/src/components/PlanBadge.d.ts +31 -0
- package/dist/src/components/PlanBadge.d.ts.map +1 -0
- package/dist/src/components/PlanBadge.js +119 -0
- package/dist/src/components/PlanBadge.js.map +1 -0
- package/dist/src/components/PlanSelector.d.ts +49 -0
- package/dist/src/components/PlanSelector.d.ts.map +1 -0
- package/dist/src/components/PlanSelector.js +82 -0
- package/dist/src/components/PlanSelector.js.map +1 -0
- package/dist/src/components/Spinner.d.ts +10 -0
- package/dist/src/components/Spinner.d.ts.map +1 -0
- package/dist/src/components/Spinner.js +14 -0
- package/dist/src/components/Spinner.js.map +1 -0
- package/dist/src/components/StripePaymentFormWrapper.d.ts +17 -0
- package/dist/src/components/StripePaymentFormWrapper.d.ts.map +1 -0
- package/dist/src/components/StripePaymentFormWrapper.js +158 -0
- package/dist/src/components/StripePaymentFormWrapper.js.map +1 -0
- package/dist/src/components/SubscriptionGate.d.ts +21 -0
- package/dist/src/components/SubscriptionGate.d.ts.map +1 -0
- package/dist/src/components/SubscriptionGate.js +32 -0
- package/dist/src/components/SubscriptionGate.js.map +1 -0
- package/dist/src/hooks/__tests__/useSubscription.test.d.ts +2 -0
- package/dist/src/hooks/__tests__/useSubscription.test.d.ts.map +1 -0
- package/dist/src/hooks/__tests__/useSubscription.test.js +554 -0
- package/dist/src/hooks/__tests__/useSubscription.test.js.map +1 -0
- package/dist/src/hooks/__tests__/useSubscriptionStatus.test.d.ts +2 -0
- package/dist/src/hooks/__tests__/useSubscriptionStatus.test.d.ts.map +1 -0
- package/dist/src/hooks/__tests__/useSubscriptionStatus.test.js +719 -0
- package/dist/src/hooks/__tests__/useSubscriptionStatus.test.js.map +1 -0
- package/dist/src/hooks/useCheckout.d.ts +59 -0
- package/dist/src/hooks/useCheckout.d.ts.map +1 -0
- package/dist/src/hooks/useCheckout.js +138 -0
- package/dist/src/hooks/useCheckout.js.map +1 -0
- package/dist/src/hooks/useCustomer.d.ts +43 -0
- package/dist/src/hooks/useCustomer.d.ts.map +1 -0
- package/dist/src/hooks/useCustomer.js +31 -0
- package/dist/src/hooks/useCustomer.js.map +1 -0
- package/dist/src/hooks/usePlans.d.ts +28 -0
- package/dist/src/hooks/usePlans.d.ts.map +1 -0
- package/dist/src/hooks/usePlans.js +181 -0
- package/dist/src/hooks/usePlans.js.map +1 -0
- package/dist/src/hooks/useSolvaPay.d.ts +44 -0
- package/dist/src/hooks/useSolvaPay.d.ts.map +1 -0
- package/dist/src/hooks/useSolvaPay.js +52 -0
- package/dist/src/hooks/useSolvaPay.js.map +1 -0
- package/dist/src/hooks/useSubscription.d.ts +46 -0
- package/dist/src/hooks/useSubscription.d.ts.map +1 -0
- package/dist/src/hooks/useSubscription.js +50 -0
- package/dist/src/hooks/useSubscription.js.map +1 -0
- package/dist/src/hooks/useSubscriptionStatus.d.ts +19 -0
- package/dist/src/hooks/useSubscriptionStatus.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionStatus.js +68 -0
- package/dist/src/hooks/useSubscriptionStatus.js.map +1 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +26 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types/index.d.ts +339 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +5 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/__tests__/subscriptions.test.d.ts +2 -0
- package/dist/src/utils/__tests__/subscriptions.test.d.ts.map +1 -0
- package/dist/src/utils/__tests__/subscriptions.test.js +121 -0
- package/dist/src/utils/__tests__/subscriptions.test.js.map +1 -0
- package/dist/src/utils/subscriptions.d.ts +57 -0
- package/dist/src/utils/subscriptions.d.ts.map +1 -0
- package/dist/src/utils/subscriptions.js +85 -0
- package/dist/src/utils/subscriptions.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,57 +13,6 @@ pnpm add @solvapay/react
|
|
|
13
13
|
- `react` ^18.2.0 || ^19.0.0
|
|
14
14
|
- `react-dom` ^18.2.0 || ^19.0.0
|
|
15
15
|
|
|
16
|
-
## Tailwind setup
|
|
17
|
-
|
|
18
|
-
SolvaPay primitives ship plain CSS. They work with Tailwind v3 and v4
|
|
19
|
-
identically. Import `@solvapay/react/styles.css` **after** your Tailwind
|
|
20
|
-
entry so the SolvaPay rules resolve above preflight.
|
|
21
|
-
|
|
22
|
-
### Tailwind v4 (recommended for new projects)
|
|
23
|
-
|
|
24
|
-
`src/index.css`:
|
|
25
|
-
|
|
26
|
-
```css
|
|
27
|
-
@import "tailwindcss";
|
|
28
|
-
@import "@solvapay/react/styles.css";
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
No `tailwind.config.ts` needed. Theme via `@theme` block if desired.
|
|
32
|
-
|
|
33
|
-
### Tailwind v3 (Lovable, older projects)
|
|
34
|
-
|
|
35
|
-
`tailwind.config.ts`:
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import type { Config } from 'tailwindcss'
|
|
39
|
-
|
|
40
|
-
export default {
|
|
41
|
-
content: ['./src/**/*.{ts,tsx}'],
|
|
42
|
-
theme: { extend: {} },
|
|
43
|
-
plugins: [],
|
|
44
|
-
} satisfies Config
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
`src/index.css`:
|
|
48
|
-
|
|
49
|
-
```css
|
|
50
|
-
@tailwind base;
|
|
51
|
-
@tailwind components;
|
|
52
|
-
@tailwind utilities;
|
|
53
|
-
@import "@solvapay/react/styles.css";
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
No `content[]` entry for `@solvapay/react` is needed — primitives don't ship
|
|
57
|
-
utility classes. `data-[state=*]:` variants work natively in v3.3+.
|
|
58
|
-
|
|
59
|
-
### CSS loading order
|
|
60
|
-
|
|
61
|
-
Always import `@solvapay/react/styles.css` **after** `@tailwind utilities`
|
|
62
|
-
(v3) or `@import "tailwindcss"` (v4). SolvaPay rules are unlayered; they beat
|
|
63
|
-
Tailwind's preflight when loaded last. See
|
|
64
|
-
[`examples/spa-checkout/src/index.css`](../../examples/spa-checkout/src/index.css)
|
|
65
|
-
for the canonical demonstration.
|
|
66
|
-
|
|
67
16
|
## Quick Start
|
|
68
17
|
|
|
69
18
|
### Zero-Config Usage (Recommended)
|
|
@@ -395,48 +344,23 @@ Displays current product subscription with render props or className pattern.
|
|
|
395
344
|
|
|
396
345
|
### PurchaseGate
|
|
397
346
|
|
|
398
|
-
Controls access to content based on purchase status.
|
|
399
|
-
primitive API (`PurchaseGate.Root`, `.Allowed`, `.Blocked`, `.Loading`,
|
|
400
|
-
`.Error`). Matching is by stable reference — `productRef` (`prd_*`) and/or
|
|
401
|
-
`planRef` (`pln_*`) — never by product or plan name.
|
|
402
|
-
|
|
403
|
-
**Root props:**
|
|
404
|
-
|
|
405
|
-
- `productRef?: string` - Require an active purchase for this product
|
|
406
|
-
- `planRef?: string` - Require an active purchase for this specific plan
|
|
407
|
-
- `asChild?: boolean` - Merge onto the consumer element via `Slot`
|
|
408
|
-
|
|
409
|
-
Matching precedence:
|
|
347
|
+
Controls access to content based on purchase status.
|
|
410
348
|
|
|
411
|
-
|
|
412
|
-
- If only one is set, that field must match on an active purchase
|
|
413
|
-
- If both are set, both must match on the **same** active purchase (AND)
|
|
414
|
-
|
|
415
|
-
**Example — product-level gating:**
|
|
349
|
+
**Props:**
|
|
416
350
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
<PurchaseGate.Loading>Loading…</PurchaseGate.Loading>
|
|
420
|
-
<PurchaseGate.Allowed>
|
|
421
|
-
<PremiumContent />
|
|
422
|
-
</PurchaseGate.Allowed>
|
|
423
|
-
<PurchaseGate.Blocked>
|
|
424
|
-
<Paywall />
|
|
425
|
-
</PurchaseGate.Blocked>
|
|
426
|
-
</PurchaseGate.Root>
|
|
427
|
-
```
|
|
351
|
+
- `requireProduct?: string` - Optional product name to check for an active purchase
|
|
352
|
+
- `children: (props) => React.ReactNode` - Render prop function
|
|
428
353
|
|
|
429
|
-
**Example
|
|
354
|
+
**Example:**
|
|
430
355
|
|
|
431
356
|
```tsx
|
|
432
|
-
<PurchaseGate
|
|
433
|
-
|
|
434
|
-
<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
</PurchaseGate.Root>
|
|
357
|
+
<PurchaseGate requireProduct="Pro Plan">
|
|
358
|
+
{({ hasAccess, loading, purchases }) => {
|
|
359
|
+
if (loading) return <Loading />
|
|
360
|
+
if (!hasAccess) return <Paywall />
|
|
361
|
+
return <PremiumContent />
|
|
362
|
+
}}
|
|
363
|
+
</PurchaseGate>
|
|
440
364
|
```
|
|
441
365
|
|
|
442
366
|
## Hooks
|
|
@@ -451,15 +375,8 @@ const {
|
|
|
451
375
|
loading, // Loading state
|
|
452
376
|
hasPaidPurchase, // Boolean: has any paid purchase
|
|
453
377
|
activePurchase, // Most recent active purchase
|
|
454
|
-
hasPurchase, // (criteria?: { productRef?, planRef? }) => boolean — predicate matching the PurchaseGate.Root shape
|
|
455
378
|
refetch, // Function to refetch purchases
|
|
456
379
|
} = usePurchase()
|
|
457
|
-
|
|
458
|
-
// Examples — criteria-based checks:
|
|
459
|
-
hasPurchase() // any active purchase
|
|
460
|
-
hasPurchase({ productRef: 'prd_widget' }) // any active purchase for this product
|
|
461
|
-
hasPurchase({ planRef: 'pln_premium' }) // any active purchase for this specific plan
|
|
462
|
-
hasPurchase({ productRef: 'prd_widget', planRef: 'pln_premium' }) // both must match the same active purchase
|
|
463
380
|
```
|
|
464
381
|
|
|
465
382
|
### usePlans
|