@solvapay/react 1.0.9-preview.1 → 1.0.9
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/CHANGELOG.md +209 -0
- package/CONTRIBUTING.md +117 -0
- package/README.md +426 -24
- package/dist/adapters/auth.d.cts +13 -0
- package/dist/adapters/auth.d.ts +13 -0
- package/dist/adapters/auth.js +1 -0
- package/dist/chunk-37R5NZGF.js +4824 -0
- package/dist/chunk-HWVJL5X6.js +429 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-R2ZPZ7VM.js +597 -0
- package/dist/chunk-ZAV7CQ4G.js +361 -0
- package/dist/index-WBjulQHf.d.cts +3656 -0
- package/dist/index-onWNU7iT.d.ts +3656 -0
- package/dist/index.cjs +5556 -1143
- package/dist/index.d.cts +618 -708
- package/dist/index.d.ts +618 -708
- package/dist/index.js +597 -1664
- package/dist/mcp/index.cjs +8096 -0
- package/dist/mcp/index.d.cts +1013 -0
- package/dist/mcp/index.d.ts +1013 -0
- package/dist/mcp/index.js +2724 -0
- package/dist/mcp/styles.css +1020 -0
- package/dist/primitives/index.cjs +5316 -0
- package/dist/primitives/index.d.cts +721 -0
- package/dist/primitives/index.d.ts +721 -0
- package/dist/primitives/index.js +232 -0
- package/dist/styles.css +1115 -0
- package/dist/useUsage-BmOYXxgG.d.cts +413 -0
- package/dist/useUsage-nD7zwSbG.d.ts +413 -0
- package/dist/webapi-K5XBCEO6.js +3775 -0
- package/package.json +37 -6
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PaymentElement, CardElement } from '@stripe/react-stripe-js';
|
|
3
|
+
import { b as Plan, P as PaymentFormProps, a as PrefillCustomer, A as ActivationResult, q as UseTopupAmountSelectorReturn } from './index-onWNU7iT.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default-tree shim over the `CheckoutSummary` primitive.
|
|
7
|
+
*
|
|
8
|
+
* Renders a product/plan/price line with optional trial + tax-note slots.
|
|
9
|
+
* Full control (ordering, custom elements, Tailwind variants) is available
|
|
10
|
+
* via the primitives at `@solvapay/react/primitives`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
type CheckoutSummaryProps = {
|
|
14
|
+
planRef?: string;
|
|
15
|
+
productRef?: string;
|
|
16
|
+
showTrial?: boolean;
|
|
17
|
+
showTaxNote?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
declare const CheckoutSummary: React.FC<CheckoutSummaryProps>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Checkout "shape" — drives the mandate variant, the submit-button CTA, and
|
|
24
|
+
* the button `aria-label` in lockstep so those three strings always agree.
|
|
25
|
+
*/
|
|
26
|
+
type CheckoutVariant = 'recurring' | 'oneTime' | 'topup' | 'usageMetered' | 'freeTier';
|
|
27
|
+
/**
|
|
28
|
+
* Derive the variant from the plan's type + billing model. Unknown or missing
|
|
29
|
+
* plans default to `'oneTime'`, which matches the canonical "Pay Now" UX.
|
|
30
|
+
*
|
|
31
|
+
* Free plans (`requiresPayment === false`) that are NOT usage-metered route
|
|
32
|
+
* to the `'freeTier'` variant. Metered free/usage plans stay on
|
|
33
|
+
* `'usageMetered'` because the mandate copy there already covers pay-as-you-go.
|
|
34
|
+
*/
|
|
35
|
+
declare function deriveVariant(plan: Plan | null | undefined, mode?: 'topup'): CheckoutVariant;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* MandateText leaf primitive.
|
|
39
|
+
*
|
|
40
|
+
* Renders SCA-compliant authorization copy derived from the resolved plan,
|
|
41
|
+
* product, and merchant identity. Variant is derived from the plan type +
|
|
42
|
+
* billing model and can be forced via the `variant` or `mode` props (use
|
|
43
|
+
* `mode="topup"` inside `<TopupForm>` where there is no plan). All strings
|
|
44
|
+
* resolve through the localized copy bundle so integrators can override
|
|
45
|
+
* text without forking the component.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
type MandateTextProps = {
|
|
49
|
+
planRef?: string;
|
|
50
|
+
productRef?: string;
|
|
51
|
+
variant?: CheckoutVariant;
|
|
52
|
+
mode?: 'topup';
|
|
53
|
+
amountMinor?: number;
|
|
54
|
+
currency?: string;
|
|
55
|
+
asChild?: boolean;
|
|
56
|
+
} & Omit<React.HTMLAttributes<HTMLParagraphElement>, 'children'> & {
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
};
|
|
59
|
+
declare const MandateText: React.ForwardRefExoticComponent<{
|
|
60
|
+
planRef?: string;
|
|
61
|
+
productRef?: string;
|
|
62
|
+
variant?: CheckoutVariant;
|
|
63
|
+
mode?: "topup";
|
|
64
|
+
amountMinor?: number;
|
|
65
|
+
currency?: string;
|
|
66
|
+
asChild?: boolean;
|
|
67
|
+
} & Omit<React.HTMLAttributes<HTMLParagraphElement>, "children"> & {
|
|
68
|
+
children?: React.ReactNode;
|
|
69
|
+
} & React.RefAttributes<HTMLParagraphElement>>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* PaymentForm compound primitive.
|
|
73
|
+
*
|
|
74
|
+
* Unstyled, accessible building blocks for running the paid OR free checkout
|
|
75
|
+
* step inside a <SolvaPayProvider>. `Root` detects paid vs free plans via
|
|
76
|
+
* `usePlan`, wires Stripe Elements for paid plans, or falls through to
|
|
77
|
+
* `useActivation` for free plans; both paths expose the same
|
|
78
|
+
* `PaymentFormContext` so the same subcomponents compose identically in
|
|
79
|
+
* either mode.
|
|
80
|
+
*
|
|
81
|
+
* Every leaf accepts `asChild` for Slot-style composition. The `SubmitButton`
|
|
82
|
+
* emits `data-state=idle|processing|disabled` + `data-variant=paid|free|topup|activate`.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
type SummaryProps = Omit<React.ComponentProps<typeof CheckoutSummary>, 'planRef' | 'productRef'>;
|
|
86
|
+
type MandateTextPrimitiveProps = Omit<React.ComponentProps<typeof MandateText>, 'planRef' | 'productRef'>;
|
|
87
|
+
type PaymentElementProps = {
|
|
88
|
+
options?: React.ComponentProps<typeof PaymentElement>['options'];
|
|
89
|
+
};
|
|
90
|
+
type CardElementProps = {
|
|
91
|
+
options?: React.ComponentProps<typeof CardElement>['options'];
|
|
92
|
+
};
|
|
93
|
+
declare const PaymentFormRoot: React.ForwardRefExoticComponent<PaymentFormProps & {
|
|
94
|
+
prefillCustomer?: PrefillCustomer;
|
|
95
|
+
requireTermsAcceptance?: boolean;
|
|
96
|
+
children?: React.ReactNode;
|
|
97
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
98
|
+
declare const PaymentFormSummary: React.FC<SummaryProps>;
|
|
99
|
+
declare const PaymentFormCustomerFields: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
100
|
+
asChild?: boolean;
|
|
101
|
+
readOnly?: boolean;
|
|
102
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
103
|
+
declare const PaymentFormPaymentElement: React.FC<PaymentElementProps>;
|
|
104
|
+
declare const PaymentFormCardElement: React.FC<CardElementProps>;
|
|
105
|
+
declare const PaymentFormMandateText: React.FC<MandateTextPrimitiveProps>;
|
|
106
|
+
declare const PaymentFormTermsCheckbox: React.ForwardRefExoticComponent<React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
107
|
+
asChild?: boolean;
|
|
108
|
+
label?: React.ReactNode;
|
|
109
|
+
} & React.RefAttributes<HTMLLabelElement>>;
|
|
110
|
+
declare const PaymentFormSubmitButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
111
|
+
asChild?: boolean;
|
|
112
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
113
|
+
declare const PaymentFormLoading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
114
|
+
asChild?: boolean;
|
|
115
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
116
|
+
declare const PaymentFormError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
117
|
+
asChild?: boolean;
|
|
118
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
119
|
+
declare const PaymentForm: {
|
|
120
|
+
readonly Root: React.ForwardRefExoticComponent<PaymentFormProps & {
|
|
121
|
+
prefillCustomer?: PrefillCustomer;
|
|
122
|
+
requireTermsAcceptance?: boolean;
|
|
123
|
+
children?: React.ReactNode;
|
|
124
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
125
|
+
readonly Summary: React.FC<SummaryProps>;
|
|
126
|
+
readonly CustomerFields: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
127
|
+
asChild?: boolean;
|
|
128
|
+
readOnly?: boolean;
|
|
129
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
130
|
+
readonly PaymentElement: React.FC<PaymentElementProps>;
|
|
131
|
+
readonly CardElement: React.FC<CardElementProps>;
|
|
132
|
+
readonly MandateText: React.FC<MandateTextPrimitiveProps>;
|
|
133
|
+
readonly TermsCheckbox: React.ForwardRefExoticComponent<React.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
134
|
+
asChild?: boolean;
|
|
135
|
+
label?: React.ReactNode;
|
|
136
|
+
} & React.RefAttributes<HTMLLabelElement>>;
|
|
137
|
+
readonly SubmitButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
138
|
+
asChild?: boolean;
|
|
139
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
140
|
+
readonly Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
141
|
+
asChild?: boolean;
|
|
142
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
143
|
+
readonly Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
144
|
+
asChild?: boolean;
|
|
145
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* ProductBadge compound primitive.
|
|
150
|
+
*
|
|
151
|
+
* Single leaf that renders the customer's current product name when an
|
|
152
|
+
* active purchase exists. Emits `data-has-purchase` + `data-has-paid-purchase`
|
|
153
|
+
* flags and forwards an `aria-label` derived from the copy bundle.
|
|
154
|
+
* `PlanBadge` is an alias retained for backwards compatibility with older
|
|
155
|
+
* integrations — both point at the same component.
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
declare const ProductBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
|
|
159
|
+
asChild?: boolean;
|
|
160
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
161
|
+
/** @deprecated Use `ProductBadge` instead. Kept as an alias for existing integrations. */
|
|
162
|
+
declare const PlanBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
|
|
163
|
+
asChild?: boolean;
|
|
164
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* PurchaseGate compound primitive.
|
|
168
|
+
*
|
|
169
|
+
* Controls access to gated content based on whether the customer has an
|
|
170
|
+
* active purchase (optionally scoped to a product). `Root` exposes
|
|
171
|
+
* `data-state=allowed|blocked|loading` and context-drives the
|
|
172
|
+
* `Allowed`, `Blocked`, `Loading`, and `Error` subcomponents.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
type GateState = 'allowed' | 'blocked' | 'loading';
|
|
176
|
+
type PurchaseGateContextValue = {
|
|
177
|
+
state: GateState;
|
|
178
|
+
loading: boolean;
|
|
179
|
+
hasAccess: boolean;
|
|
180
|
+
error: Error | null;
|
|
181
|
+
};
|
|
182
|
+
declare const PurchaseGateRoot: React.ForwardRefExoticComponent<{
|
|
183
|
+
/** @deprecated Use `requireProduct`. */
|
|
184
|
+
requirePlan?: string;
|
|
185
|
+
requireProduct?: string;
|
|
186
|
+
asChild?: boolean;
|
|
187
|
+
children?: React.ReactNode;
|
|
188
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
|
|
189
|
+
declare const PurchaseGateAllowed: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
190
|
+
asChild?: boolean;
|
|
191
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
192
|
+
declare const PurchaseGateBlocked: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
193
|
+
asChild?: boolean;
|
|
194
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
195
|
+
declare const PurchaseGateLoading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
196
|
+
asChild?: boolean;
|
|
197
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
198
|
+
declare const PurchaseGateError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
199
|
+
asChild?: boolean;
|
|
200
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
201
|
+
declare const PurchaseGate: {
|
|
202
|
+
readonly Root: React.ForwardRefExoticComponent<{
|
|
203
|
+
/** @deprecated Use `requireProduct`. */
|
|
204
|
+
requirePlan?: string;
|
|
205
|
+
requireProduct?: string;
|
|
206
|
+
asChild?: boolean;
|
|
207
|
+
children?: React.ReactNode;
|
|
208
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
|
|
209
|
+
readonly Allowed: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
210
|
+
asChild?: boolean;
|
|
211
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
212
|
+
readonly Blocked: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
213
|
+
asChild?: boolean;
|
|
214
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
215
|
+
readonly Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
216
|
+
asChild?: boolean;
|
|
217
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
218
|
+
readonly Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
219
|
+
asChild?: boolean;
|
|
220
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
221
|
+
};
|
|
222
|
+
declare function usePurchaseGate(): PurchaseGateContextValue;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* BalanceBadge leaf primitive.
|
|
226
|
+
*
|
|
227
|
+
* Renders the customer's credit balance with an optional currency-equivalent
|
|
228
|
+
* suffix. Emits `data-state=loading|zero|low|ok` plus a `data-credits`
|
|
229
|
+
* attribute for CSS targeting. Low-balance threshold is configurable via the
|
|
230
|
+
* `lowThreshold` prop (defaults to 10).
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
declare const BalanceBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
234
|
+
asChild?: boolean;
|
|
235
|
+
/** Hide the trailing " credits" label + currency equivalent. */
|
|
236
|
+
numberOnly?: boolean;
|
|
237
|
+
/** Balance threshold (inclusive) treated as `data-state="low"`. Defaults to 10. */
|
|
238
|
+
lowThreshold?: number;
|
|
239
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* ActivationFlow compound primitive.
|
|
243
|
+
*
|
|
244
|
+
* Drives the usage-based plan activation state machine:
|
|
245
|
+
* summary → activating → (topup_required → selectAmount → topupPayment →
|
|
246
|
+
* retrying) → activated | error.
|
|
247
|
+
*
|
|
248
|
+
* `Root` exposes `data-state` set to the current step and publishes the
|
|
249
|
+
* shared context consumed by leaves. Leaves render only during their
|
|
250
|
+
* matching step:
|
|
251
|
+
* - `Summary` — `summary` | `activating`
|
|
252
|
+
* - `ActivateButton` — `summary` | `activating`
|
|
253
|
+
* - `AmountPicker` — `selectAmount`
|
|
254
|
+
* - `ContinueButton` — `selectAmount`
|
|
255
|
+
* - `Retrying` — `retrying`
|
|
256
|
+
* - `Activated` — `activated`
|
|
257
|
+
* - `Loading` — renders when plan is not yet resolved
|
|
258
|
+
* - `Error` — `error`
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
type ActivationFlowStep = 'summary' | 'activating' | 'selectAmount' | 'topupPayment' | 'retrying' | 'activated' | 'error';
|
|
262
|
+
type ActivationFlowContextValue = {
|
|
263
|
+
step: ActivationFlowStep;
|
|
264
|
+
plan: Plan | null;
|
|
265
|
+
productRef: string;
|
|
266
|
+
planRef: string;
|
|
267
|
+
amountSelector: UseTopupAmountSelectorReturn;
|
|
268
|
+
/**
|
|
269
|
+
* Resolved top-up amount in the currency's minor units. Respects
|
|
270
|
+
* zero-decimal currencies (JPY → whole yen, USD → cents).
|
|
271
|
+
*/
|
|
272
|
+
amountMinor: number;
|
|
273
|
+
/**
|
|
274
|
+
* @deprecated Use `amountMinor`. Kept as an alias for back-compat; will
|
|
275
|
+
* be removed in the next major. For zero-decimal currencies this is the
|
|
276
|
+
* same value as `amountMinor` (not cents).
|
|
277
|
+
*/
|
|
278
|
+
amountCents: number;
|
|
279
|
+
currency: string;
|
|
280
|
+
activate: () => Promise<void>;
|
|
281
|
+
reset: () => void;
|
|
282
|
+
goToTopupPayment: () => void;
|
|
283
|
+
backToSelectAmount: () => void;
|
|
284
|
+
onTopupSuccess: () => Promise<void>;
|
|
285
|
+
error: string | null;
|
|
286
|
+
onError?: (error: Error) => void;
|
|
287
|
+
};
|
|
288
|
+
type AmountPickerMountProps = {
|
|
289
|
+
children?: React.ReactNode;
|
|
290
|
+
};
|
|
291
|
+
declare const ActivationFlowRoot: React.ForwardRefExoticComponent<{
|
|
292
|
+
productRef?: string;
|
|
293
|
+
/** Defaults to PlanSelectionContext selection when omitted. */
|
|
294
|
+
planRef?: string;
|
|
295
|
+
onSuccess?: (result: ActivationResult) => void;
|
|
296
|
+
onError?: (error: Error) => void;
|
|
297
|
+
retryDelayMs?: number;
|
|
298
|
+
retryBackoffMs?: number;
|
|
299
|
+
asChild?: boolean;
|
|
300
|
+
children?: React.ReactNode;
|
|
301
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
|
|
302
|
+
declare const ActivationFlowSummary: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
303
|
+
asChild?: boolean;
|
|
304
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
305
|
+
declare const ActivationFlowActivateButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
306
|
+
asChild?: boolean;
|
|
307
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
308
|
+
declare const ActivationFlowAmountPicker: React.FC<AmountPickerMountProps>;
|
|
309
|
+
declare const ActivationFlowContinueButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
310
|
+
asChild?: boolean;
|
|
311
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
312
|
+
declare const ActivationFlowRetrying: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
313
|
+
asChild?: boolean;
|
|
314
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
315
|
+
declare const ActivationFlowActivated: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
316
|
+
asChild?: boolean;
|
|
317
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
318
|
+
declare const ActivationFlowLoading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
319
|
+
asChild?: boolean;
|
|
320
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
321
|
+
declare const ActivationFlowError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
322
|
+
asChild?: boolean;
|
|
323
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
324
|
+
declare const ActivationFlow: {
|
|
325
|
+
readonly Root: React.ForwardRefExoticComponent<{
|
|
326
|
+
productRef?: string;
|
|
327
|
+
/** Defaults to PlanSelectionContext selection when omitted. */
|
|
328
|
+
planRef?: string;
|
|
329
|
+
onSuccess?: (result: ActivationResult) => void;
|
|
330
|
+
onError?: (error: Error) => void;
|
|
331
|
+
retryDelayMs?: number;
|
|
332
|
+
retryBackoffMs?: number;
|
|
333
|
+
asChild?: boolean;
|
|
334
|
+
children?: React.ReactNode;
|
|
335
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
|
|
336
|
+
readonly Summary: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
337
|
+
asChild?: boolean;
|
|
338
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
339
|
+
readonly ActivateButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
340
|
+
asChild?: boolean;
|
|
341
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
342
|
+
readonly AmountPicker: React.FC<AmountPickerMountProps>;
|
|
343
|
+
readonly ContinueButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
344
|
+
asChild?: boolean;
|
|
345
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
346
|
+
readonly Retrying: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
347
|
+
asChild?: boolean;
|
|
348
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
349
|
+
readonly Activated: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
350
|
+
asChild?: boolean;
|
|
351
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
352
|
+
readonly Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
353
|
+
asChild?: boolean;
|
|
354
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
355
|
+
readonly Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
356
|
+
asChild?: boolean;
|
|
357
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
358
|
+
};
|
|
359
|
+
declare function useActivationFlow(): ActivationFlowContextValue;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* CancelPlanButton leaf primitive.
|
|
363
|
+
*
|
|
364
|
+
* Cancels the active (or specified) purchase via `usePurchaseActions`.
|
|
365
|
+
* Emits `data-state=idle|cancelling` and auto-derives the confirm dialog
|
|
366
|
+
* copy from the plan type (`recurring` vs. `usage-based`) unless overridden
|
|
367
|
+
* via the `confirm` prop (`false` to skip, string to replace).
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
declare const CancelPlanButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
371
|
+
asChild?: boolean;
|
|
372
|
+
/** Defaults to the active purchase from `usePurchase()`. */
|
|
373
|
+
purchaseRef?: string;
|
|
374
|
+
reason?: string;
|
|
375
|
+
/**
|
|
376
|
+
* Built-in confirm dialog. `true` (default) uses plan-type-aware copy;
|
|
377
|
+
* a string replaces the copy; `false` skips confirmation.
|
|
378
|
+
*/
|
|
379
|
+
confirm?: boolean | string;
|
|
380
|
+
onCancelled?: () => void;
|
|
381
|
+
onError?: (error: Error) => void;
|
|
382
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
383
|
+
|
|
384
|
+
interface UseUsageReturn {
|
|
385
|
+
/** Raw usage snapshot (`null` when no usage-based plan is active). */
|
|
386
|
+
usage: UsageSnapshot | null;
|
|
387
|
+
loading: boolean;
|
|
388
|
+
error: Error | null;
|
|
389
|
+
refetch: () => Promise<void>;
|
|
390
|
+
/** 0-100, rounded to 2dp. `null` when total is unknown (unlimited/empty). */
|
|
391
|
+
percentUsed: number | null;
|
|
392
|
+
/** Plan is usage-based, `percentUsed >= 80`. */
|
|
393
|
+
isApproachingLimit: boolean;
|
|
394
|
+
/** Plan is usage-based, `percentUsed >= 100`. */
|
|
395
|
+
isAtLimit: boolean;
|
|
396
|
+
/** True when `usage.total === null` (no quota on this plan). */
|
|
397
|
+
isUnlimited: boolean;
|
|
398
|
+
/** The meter reference (e.g. `'tokens'`). `null` when not usage-based. */
|
|
399
|
+
meterRef: string | null;
|
|
400
|
+
}
|
|
401
|
+
interface UsageSnapshot {
|
|
402
|
+
meterRef: string | null;
|
|
403
|
+
total: number | null;
|
|
404
|
+
used: number;
|
|
405
|
+
remaining: number | null;
|
|
406
|
+
percentUsed: number | null;
|
|
407
|
+
periodStart?: string;
|
|
408
|
+
periodEnd?: string;
|
|
409
|
+
purchaseRef?: string;
|
|
410
|
+
}
|
|
411
|
+
declare function useUsage(): UseUsageReturn;
|
|
412
|
+
|
|
413
|
+
export { type ActivationFlowStep as A, BalanceBadge as B, type CheckoutVariant as C, ActivationFlowRoot as D, ActivationFlowSummary as E, PaymentForm as F, PaymentFormRoot as G, PurchaseGateAllowed as H, PurchaseGateBlocked as I, PurchaseGateError as J, PurchaseGateLoading as K, PurchaseGateRoot as L, MandateText as M, useActivationFlow as N, usePurchaseGate as O, PaymentFormSummary as P, type UsageSnapshot as U, PaymentFormCustomerFields as a, PaymentFormPaymentElement as b, PaymentFormCardElement as c, PaymentFormMandateText as d, PaymentFormTermsCheckbox as e, PaymentFormSubmitButton as f, PaymentFormLoading as g, PaymentFormError as h, CancelPlanButton as i, CheckoutSummary as j, type CheckoutSummaryProps as k, type MandateTextProps as l, PlanBadge as m, ProductBadge as n, PurchaseGate as o, type UseUsageReturn as p, deriveVariant as q, ActivationFlow as r, ActivationFlowActivateButton as s, ActivationFlowActivated as t, useUsage as u, ActivationFlowAmountPicker as v, ActivationFlowContinueButton as w, ActivationFlowError as x, ActivationFlowLoading as y, ActivationFlowRetrying as z };
|