@openreceive/react 0.1.1 → 0.2.2
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 +40 -0
- package/dist/index.d.ts +230 -103
- package/dist/index.js +3128 -876
- package/dist/styles.css +3 -1
- package/package.json +47 -7
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @openreceive/react
|
|
2
|
+
|
|
3
|
+
React checkout components for OpenReceive (`<Checkout>`, `useCheckout`, `PaymentWizard`).
|
|
4
|
+
|
|
5
|
+
## Mount
|
|
6
|
+
|
|
7
|
+
Render `<Checkout>` and import the checkout styles once — without them the
|
|
8
|
+
components render unstyled.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { Checkout } from "@openreceive/react";
|
|
12
|
+
import "@openreceive/react/styles.css";
|
|
13
|
+
|
|
14
|
+
export function Pay() {
|
|
15
|
+
return <Checkout reference="order-123" onSettled={() => console.log("paid")} />;
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Pass `reference` to let the component create the checkout (create mode), or pass
|
|
20
|
+
a `checkout` snapshot to render one your server already created. Prop names,
|
|
21
|
+
defaults, and the full surface are shared across the wrappers — see
|
|
22
|
+
`docs/internal/wrapper-parity.md` in the repository.
|
|
23
|
+
|
|
24
|
+
Event handlers (`onCopy`, `onOpenWallet`, `onState`, `onSettled`,
|
|
25
|
+
`onProviderCopy`, `onStartOver`, `onError`) are ordinary props. React receives
|
|
26
|
+
framework values rather than DOM `CustomEvent`s — `onState` gets the
|
|
27
|
+
`CheckoutState`, `onError` the thrown value.
|
|
28
|
+
|
|
29
|
+
`useCheckout({ checkout })` is the headless half: it drives a concrete snapshot
|
|
30
|
+
and returns the view model plus the copy/open actions. Create mode belongs to
|
|
31
|
+
`<Checkout>`, so the hook takes no create options.
|
|
32
|
+
|
|
33
|
+
## Icon assets
|
|
34
|
+
|
|
35
|
+
The checkout loads its payment-method icons by URL at runtime; your app must
|
|
36
|
+
serve them where the resolution lands. See
|
|
37
|
+
[Icon assets in `@openreceive/browser`](https://github.com/openreceive/openreceive/blob/master/packages/js/browser/README.md#icon-assets)
|
|
38
|
+
for the per-bundler recipes.
|
|
39
|
+
|
|
40
|
+
Part of [OpenReceive](https://openreceive.org). Start with the [Node quickstart](https://github.com/openreceive/openreceive/blob/master/docs/guides/quickstart-node.md); the full API is in the [API reference](https://github.com/openreceive/openreceive/blob/master/docs/guides/api-reference.md).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,57 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CheckoutComponentProps, CheckoutState, QrEncoder, BrowserLoggerOption, CheckoutStatusRefresh, Status, CheckoutSnapshot, BrowserLogContext, CheckoutInvoiceSnapshot, ThemePreference, ResolvedTheme, ThemeModel, PaymentDataSource, CheckoutPhase, CheckoutStatusModel, UnixSeconds, BrowserLogger, TransactionDetailsSource } from '@openreceive/browser/headless';
|
|
3
|
+
export { TransactionDetailsSource, resolveTransactionDetailRows } from '@openreceive/browser/headless';
|
|
4
|
+
|
|
5
|
+
interface CheckoutData {
|
|
6
|
+
readonly checkout: CheckoutSnapshot;
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly amountLabel?: string;
|
|
16
|
-
readonly fiatLabel?: string;
|
|
17
|
-
readonly paymentHashLabel?: string;
|
|
8
|
+
/**
|
|
9
|
+
* What React renders a checkout from: the shared {@link CheckoutState} plus the
|
|
10
|
+
* coarse public {@link Status} the component's four terminal branches read.
|
|
11
|
+
*
|
|
12
|
+
* It used to restate eleven of CheckoutState's fields — the same flattening
|
|
13
|
+
* rule, written a second time in a second package. It now extends the state, so
|
|
14
|
+
* there is exactly one derivation and one place a display field can come from.
|
|
15
|
+
*/
|
|
16
|
+
interface CheckoutViewModel extends CheckoutState {
|
|
18
17
|
readonly status: Status;
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Event handlers every OpenReceive wrapper exposes (docs/internal/wrapper-parity.md).
|
|
21
|
+
* React hands each one its framework-native payload; the element wrappers hand the
|
|
22
|
+
* matching DOM CustomEvent.
|
|
23
|
+
*/
|
|
24
|
+
interface CheckoutEventHandlers {
|
|
25
|
+
readonly onCopy?: () => void;
|
|
26
|
+
readonly onOpenWallet?: (uri: string) => void;
|
|
27
|
+
readonly onState?: (state: CheckoutState) => void;
|
|
28
|
+
readonly onSettled?: () => void;
|
|
29
|
+
readonly onProviderCopy?: (providerId: string) => void;
|
|
30
|
+
readonly onStartOver?: () => void;
|
|
31
|
+
readonly onError?: (error: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Hook inputs. The hook drives a concrete snapshot, so `checkout` is REQUIRED:
|
|
35
|
+
* create mode belongs to `<Checkout>`, and both `useCheckout({ reference })`
|
|
36
|
+
* and `useCheckout({})` used to type-check and then always throw.
|
|
37
|
+
*/
|
|
38
|
+
interface UseCheckoutOptions extends CheckoutData, Omit<CheckoutEventHandlers, "onProviderCopy" | "onStartOver"> {
|
|
21
39
|
readonly clipboard?: Pick<Clipboard, "writeText">;
|
|
22
40
|
readonly open?: (uri: string) => void;
|
|
23
|
-
readonly logger?:
|
|
24
|
-
readonly
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly
|
|
31
|
-
readonly refreshReason?: string | ((state: CheckoutState) => string);
|
|
32
|
-
readonly onState?: (state: CheckoutState) => void;
|
|
33
|
-
readonly onPaid?: () => void;
|
|
41
|
+
readonly logger?: BrowserLoggerOption;
|
|
42
|
+
readonly refreshStatus?: CheckoutStatusRefresh;
|
|
43
|
+
/**
|
|
44
|
+
* Base path the shipped router is mounted at; the hook polls
|
|
45
|
+
* `${prefix}/payments/check`. Omitted, the hook renders the snapshot without
|
|
46
|
+
* polling — there is nowhere to poll.
|
|
47
|
+
*/
|
|
48
|
+
readonly prefix?: string;
|
|
34
49
|
readonly polling?: boolean;
|
|
35
50
|
readonly pollIntervalMs?: number;
|
|
36
51
|
}
|
|
37
|
-
|
|
52
|
+
interface UseCheckoutResult extends CheckoutViewModel {
|
|
53
|
+
readonly checkout: CheckoutSnapshot;
|
|
38
54
|
readonly copied: boolean;
|
|
39
|
-
readonly expiresInSeconds?: number;
|
|
40
55
|
readonly countdownLabel?: string;
|
|
41
56
|
readonly countdownPrefix?: string;
|
|
42
57
|
readonly statusTitle: string;
|
|
@@ -44,50 +59,49 @@ export interface UseCheckoutResult extends CheckoutViewModel {
|
|
|
44
59
|
readonly waiting: boolean;
|
|
45
60
|
reloadState(): Promise<void>;
|
|
46
61
|
retry(): Promise<void>;
|
|
47
|
-
refreshExpiredInvoice(): Promise<void>;
|
|
48
62
|
cancel(): void;
|
|
49
63
|
copyInvoice(): Promise<void>;
|
|
50
64
|
openWallet(): string;
|
|
51
65
|
}
|
|
52
|
-
|
|
66
|
+
interface CheckoutProviderProps extends UseCheckoutOptions {
|
|
53
67
|
readonly children?: React.ReactNode | ((checkout: UseCheckoutResult) => React.ReactNode);
|
|
54
68
|
}
|
|
55
|
-
|
|
69
|
+
interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
56
70
|
readonly invoice: string;
|
|
57
|
-
readonly encoder?:
|
|
71
|
+
readonly encoder?: QrEncoder;
|
|
58
72
|
readonly width?: number;
|
|
59
73
|
readonly onError?: (error: unknown) => void;
|
|
60
74
|
}
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
type ButtonComponent = React.ElementType<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
76
|
+
interface CopyInvoiceButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
63
77
|
readonly invoice: string;
|
|
64
78
|
readonly copyInvoice?: () => Promise<void>;
|
|
65
79
|
readonly clipboard?: Pick<Clipboard, "writeText">;
|
|
66
|
-
readonly logger?:
|
|
80
|
+
readonly logger?: BrowserLoggerOption;
|
|
67
81
|
readonly onCopied?: () => void;
|
|
68
82
|
readonly onError?: (error: unknown) => void;
|
|
69
83
|
readonly copiedLabel?: React.ReactNode;
|
|
70
84
|
readonly ButtonComponent?: ButtonComponent;
|
|
71
85
|
}
|
|
72
|
-
|
|
86
|
+
interface OpenWalletButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
73
87
|
readonly invoice: string;
|
|
74
88
|
readonly openWallet?: () => string;
|
|
75
89
|
readonly open?: (uri: string) => void;
|
|
76
|
-
readonly logger?:
|
|
90
|
+
readonly logger?: BrowserLoggerOption;
|
|
77
91
|
readonly onOpened?: (uri: string) => void;
|
|
78
92
|
readonly onError?: (error: unknown) => void;
|
|
79
93
|
readonly ButtonComponent?: ButtonComponent;
|
|
80
94
|
}
|
|
81
|
-
|
|
95
|
+
interface PaymentStateProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
82
96
|
readonly state?: string;
|
|
83
97
|
}
|
|
84
|
-
|
|
98
|
+
interface InvoiceSummaryClassNames {
|
|
85
99
|
readonly amount?: string;
|
|
86
100
|
readonly fiat?: string;
|
|
87
101
|
readonly paymentHash?: string;
|
|
88
102
|
readonly paymentState?: string;
|
|
89
103
|
}
|
|
90
|
-
|
|
104
|
+
interface InvoiceSummaryProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
91
105
|
readonly amountLabel?: string;
|
|
92
106
|
readonly fiatLabel?: string;
|
|
93
107
|
readonly paymentHashLabel?: string;
|
|
@@ -95,21 +109,25 @@ export interface InvoiceSummaryProps extends React.HTMLAttributes<HTMLDivElement
|
|
|
95
109
|
readonly PaymentStateComponent?: React.ComponentType<PaymentStateProps>;
|
|
96
110
|
readonly classNames?: InvoiceSummaryClassNames;
|
|
97
111
|
}
|
|
98
|
-
|
|
112
|
+
interface CheckoutClassNames extends InvoiceSummaryClassNames {
|
|
99
113
|
readonly root?: string;
|
|
100
114
|
readonly qr?: string;
|
|
115
|
+
readonly satsDetail?: string;
|
|
116
|
+
readonly lightningPane?: string;
|
|
117
|
+
readonly invoiceTitle?: string;
|
|
118
|
+
/** Applied to the settled payment-data disclosure. */
|
|
101
119
|
readonly details?: string;
|
|
102
120
|
readonly waiting?: string;
|
|
103
121
|
readonly countdown?: string;
|
|
104
122
|
readonly summary?: string;
|
|
105
|
-
readonly invoice?: string;
|
|
106
123
|
readonly actions?: string;
|
|
107
124
|
readonly copyButton?: string;
|
|
125
|
+
/** Applied to the `components.OpenWalletButton` slot, which renders only when supplied. */
|
|
108
126
|
readonly openWalletButton?: string;
|
|
109
127
|
readonly wizard?: string;
|
|
110
128
|
readonly themeToggle?: string;
|
|
111
129
|
}
|
|
112
|
-
|
|
130
|
+
interface CheckoutComponents {
|
|
113
131
|
readonly Button?: ButtonComponent;
|
|
114
132
|
readonly QRCode?: React.ComponentType<QRCodeProps>;
|
|
115
133
|
readonly InvoiceSummary?: React.ComponentType<InvoiceSummaryProps>;
|
|
@@ -117,58 +135,54 @@ export interface CheckoutComponents {
|
|
|
117
135
|
readonly OpenWalletButton?: React.ComponentType<OpenWalletButtonProps>;
|
|
118
136
|
readonly PaymentState?: React.ComponentType<PaymentStateProps>;
|
|
119
137
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
readonly
|
|
129
|
-
|
|
130
|
-
readonly refreshIdempotencyKey?: string | ((state: CheckoutState) => string);
|
|
131
|
-
readonly refreshReason?: string | ((state: CheckoutState) => string);
|
|
132
|
-
readonly onState?: (state: CheckoutState) => void;
|
|
133
|
-
readonly onPaid?: () => void;
|
|
134
|
-
readonly onStartOver?: () => void;
|
|
138
|
+
type CheckoutChildren = React.ReactNode | ((model: UseCheckoutResult) => React.ReactNode);
|
|
139
|
+
interface CheckoutProps extends CheckoutComponentProps, CheckoutEventHandlers, Omit<React.HTMLAttributes<HTMLElement>, "children" | "prefix" | "onCopy" | "onError"> {
|
|
140
|
+
/**
|
|
141
|
+
* Create mode (`reference`, no `checkout`): the component creates the checkout against
|
|
142
|
+
* `${prefix}/checkouts`, then polls `${prefix}/payments/check`. Later requests carry
|
|
143
|
+
* `reference` and the displayed `payment_hash`; the host remains responsible for
|
|
144
|
+
* authorization, order display, and routing. This fetch makes those create calls.
|
|
145
|
+
*/
|
|
146
|
+
readonly createFetch?: typeof globalThis.fetch;
|
|
147
|
+
/** `false` turns status polling off entirely. */
|
|
135
148
|
readonly polling?: boolean;
|
|
136
|
-
readonly
|
|
137
|
-
readonly
|
|
138
|
-
readonly
|
|
139
|
-
readonly
|
|
140
|
-
readonly countryStorageKey?: string;
|
|
149
|
+
readonly pollIntervalMs?: number;
|
|
150
|
+
readonly qrEncoder?: QrEncoder;
|
|
151
|
+
readonly logger?: BrowserLoggerOption;
|
|
152
|
+
readonly refreshStatus?: CheckoutStatusRefresh;
|
|
141
153
|
readonly components?: CheckoutComponents;
|
|
142
154
|
readonly classNames?: CheckoutClassNames;
|
|
143
155
|
readonly children?: CheckoutChildren;
|
|
144
156
|
}
|
|
145
|
-
|
|
146
|
-
readonly defaultTheme?:
|
|
157
|
+
interface UseThemeOptions {
|
|
158
|
+
readonly defaultTheme?: ThemePreference;
|
|
147
159
|
readonly storageKey?: string;
|
|
148
160
|
readonly storage?: Storage;
|
|
149
161
|
}
|
|
150
|
-
|
|
151
|
-
readonly theme:
|
|
152
|
-
readonly resolvedTheme:
|
|
153
|
-
readonly model:
|
|
154
|
-
readonly nextTheme:
|
|
162
|
+
interface UseThemeResult {
|
|
163
|
+
readonly theme: ThemePreference;
|
|
164
|
+
readonly resolvedTheme: ResolvedTheme;
|
|
165
|
+
readonly model: ThemeModel;
|
|
166
|
+
readonly nextTheme: ThemePreference;
|
|
155
167
|
readonly toggleLabel: string;
|
|
156
|
-
readonly attributes:
|
|
157
|
-
readonly checkoutElementAttributes:
|
|
158
|
-
|
|
168
|
+
readonly attributes: ThemeModel["attributes"];
|
|
169
|
+
readonly checkoutElementAttributes: ThemeModel["checkoutElementAttributes"];
|
|
170
|
+
/** True when this result comes from an ancestor ThemeScope (inherit, don't re-stamp). */
|
|
171
|
+
readonly fromScope: boolean;
|
|
172
|
+
setTheme(theme: ThemePreference): void;
|
|
159
173
|
toggleTheme(): void;
|
|
160
174
|
}
|
|
161
|
-
|
|
162
|
-
readonly theme?:
|
|
163
|
-
readonly resolvedTheme?:
|
|
164
|
-
readonly onThemeChange?: (theme:
|
|
175
|
+
interface ThemeToggleProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
176
|
+
readonly theme?: ThemePreference;
|
|
177
|
+
readonly resolvedTheme?: ResolvedTheme;
|
|
178
|
+
readonly onThemeChange?: (theme: ThemePreference) => void;
|
|
165
179
|
readonly ButtonComponent?: ButtonComponent;
|
|
166
180
|
}
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
type ThemeScopeChildren = React.ReactNode | ((theme: UseThemeResult) => React.ReactNode);
|
|
182
|
+
interface ThemeScopeProps extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {
|
|
169
183
|
readonly as?: keyof React.JSX.IntrinsicElements;
|
|
170
|
-
readonly defaultTheme?:
|
|
171
|
-
readonly
|
|
184
|
+
readonly defaultTheme?: ThemePreference;
|
|
185
|
+
readonly storageKey?: string;
|
|
172
186
|
readonly storage?: Storage;
|
|
173
187
|
readonly themeToggle?: boolean;
|
|
174
188
|
readonly topbarClassName?: string;
|
|
@@ -176,33 +190,146 @@ export interface ThemeScopeProps extends Omit<React.HTMLAttributes<HTMLElement>,
|
|
|
176
190
|
readonly ButtonComponent?: ButtonComponent;
|
|
177
191
|
readonly children?: ThemeScopeChildren;
|
|
178
192
|
}
|
|
179
|
-
|
|
180
|
-
|
|
193
|
+
interface PaymentWizardProps {
|
|
194
|
+
/**
|
|
195
|
+
* The active Lightning bolt11 invoice. Optional: omit (or pass `undefined`) in
|
|
196
|
+
* create-mode deferred flows where the Lightning invoice has not been minted yet.
|
|
197
|
+
* The wizard will disable invoice-copy actions until a non-empty invoice is provided.
|
|
198
|
+
*/
|
|
199
|
+
readonly invoice?: string;
|
|
200
|
+
readonly checkout?: CheckoutSnapshot;
|
|
181
201
|
readonly className?: string;
|
|
182
|
-
readonly logger?:
|
|
183
|
-
readonly logContext?:
|
|
184
|
-
|
|
202
|
+
readonly logger?: BrowserLoggerOption;
|
|
203
|
+
readonly logContext?: BrowserLogContext;
|
|
204
|
+
/**
|
|
205
|
+
* Base path the shipped router is mounted at; the swap quote, start and refund
|
|
206
|
+
* routes are derived from it. Omitted, the wizard has no swap backend and
|
|
207
|
+
* shows the method grid only — which is what a standalone wizard wants.
|
|
208
|
+
*/
|
|
209
|
+
readonly prefix?: string;
|
|
210
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
211
|
+
readonly clipboard?: Pick<Clipboard, "writeText">;
|
|
212
|
+
readonly qrEncoder?: QrEncoder;
|
|
213
|
+
/** Base URL of an external bolt11 decoder; omitted, no "Decode" link is rendered. */
|
|
214
|
+
readonly decodeLinkUrl?: string;
|
|
185
215
|
readonly onError?: (error: unknown) => void;
|
|
216
|
+
/**
|
|
217
|
+
* Called when the payer enters or leaves the focused swap flow (a pay-in coin is
|
|
218
|
+
* selected). The default `Checkout` uses this to hide its Lightning payment section
|
|
219
|
+
* so the swap deposit panel fully replaces it.
|
|
220
|
+
*/
|
|
221
|
+
readonly onSwapFocusChange?: (focused: boolean) => void;
|
|
222
|
+
/**
|
|
223
|
+
* Called when the wizard needs a Lightning invoice to be ready — e.g. when the payer
|
|
224
|
+
* selects Bitcoin from the method grid or navigates back from a swap to the Lightning
|
|
225
|
+
* pane. The host should mint (or reuse) a bolt11 and update the checkout snapshot.
|
|
226
|
+
* Used by the create-mode deferred flow; safe to omit in snapshot mode.
|
|
227
|
+
*/
|
|
228
|
+
readonly onRequestLightning?: () => void | Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Called after a swap deposit attempt is created or reused so create-mode can poll
|
|
231
|
+
* the shadow Lightning payment_hash for settlement.
|
|
232
|
+
*/
|
|
233
|
+
readonly onSwapStarted?: (invoice: CheckoutInvoiceSnapshot) => void;
|
|
234
|
+
/** Called with the provider id after the payer copies the invoice from a provider tutorial. */
|
|
235
|
+
readonly onProviderCopy?: (providerId: string) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Called for the same tutorial copy, without the provider id — the plain
|
|
238
|
+
* "the invoice was copied" signal. Both fire, matching the element, which
|
|
239
|
+
* dispatches `openreceive-provider-copy` and `openreceive-copy` together.
|
|
240
|
+
*/
|
|
241
|
+
readonly onCopy?: () => void;
|
|
186
242
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
243
|
+
interface SatsDetailProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
244
|
+
readonly amountLabel?: string;
|
|
245
|
+
readonly fiatLabel?: string;
|
|
246
|
+
readonly fiatCurrency?: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Self-contained checkout. Two modes:
|
|
251
|
+
*
|
|
252
|
+
* - Snapshot mode (`checkout` prop): renders that snapshot directly. `prefix` (default
|
|
253
|
+
* `/openreceive`) is the mount every route is derived from, so status polling works
|
|
254
|
+
* with just a prefix — or with nothing at all.
|
|
255
|
+
* - Create mode (`reference` prop, no `checkout`): the component owns the whole lifecycle — on
|
|
256
|
+
* mount it prepares amount + payment methods against `${prefix}/checkouts/prepare` (no
|
|
257
|
+
* Lightning mint). Bitcoin selection mints via `${prefix}/checkouts`. Poll/swap send
|
|
258
|
+
* `reference` and are authorized by the host.
|
|
259
|
+
* - Opt into `/checkout/:reference` History API sync with `syncUrl` (skipped when
|
|
260
|
+
* `routeReference` is set — e.g. Next.js already owns the route). Order resume data
|
|
261
|
+
* remains owned by the host application.
|
|
262
|
+
*/
|
|
263
|
+
declare function Checkout(props: CheckoutProps): React.ReactElement;
|
|
264
|
+
|
|
265
|
+
declare function QRCode(props: QRCodeProps): React.ReactElement;
|
|
266
|
+
declare function CopyInvoiceButton(props: CopyInvoiceButtonProps): React.ReactElement;
|
|
267
|
+
declare function OpenWalletButton(props: OpenWalletButtonProps): React.ReactElement;
|
|
268
|
+
declare function PaymentState(props: PaymentStateProps): React.ReactElement;
|
|
269
|
+
/** Collapsible "everything the client knows about this payment" panel, shown once settled. */
|
|
270
|
+
declare function PaymentData(props: {
|
|
271
|
+
readonly source: PaymentDataSource;
|
|
272
|
+
readonly className?: string;
|
|
273
|
+
}): React.ReactElement | null;
|
|
274
|
+
declare function WaitingState(props: {
|
|
199
275
|
readonly waiting?: boolean;
|
|
200
276
|
readonly phase?: CheckoutPhase;
|
|
201
277
|
readonly status?: CheckoutStatusModel;
|
|
202
278
|
readonly statusTitle?: string;
|
|
203
279
|
readonly statusDetail?: string;
|
|
280
|
+
readonly countdownLabel?: string;
|
|
281
|
+
readonly settled?: boolean;
|
|
204
282
|
readonly className?: string;
|
|
205
283
|
}): React.ReactElement;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
284
|
+
declare function InvoiceSummary(props: InvoiceSummaryProps): React.ReactElement;
|
|
285
|
+
declare function SatsDetail(props: SatsDetailProps): React.ReactElement | null;
|
|
286
|
+
|
|
287
|
+
declare function renderSwapDepositPanel(options: {
|
|
288
|
+
readonly invoice: CheckoutInvoiceSnapshot;
|
|
289
|
+
readonly checkout?: CheckoutSnapshot;
|
|
290
|
+
/** Unix **seconds** ({@link UnixSeconds}), not `Date.now()` milliseconds. */
|
|
291
|
+
readonly now?: UnixSeconds;
|
|
292
|
+
readonly encoder?: QrEncoder;
|
|
293
|
+
readonly clipboard?: Pick<Clipboard, "writeText">;
|
|
294
|
+
readonly logger?: BrowserLogger | false;
|
|
295
|
+
readonly onError?: (error: unknown) => void;
|
|
296
|
+
readonly onRefund: (attemptId: string, refundAddress: string, confirm: boolean) => Promise<void>;
|
|
297
|
+
readonly onBackToLightning: () => void;
|
|
298
|
+
}): React.ReactElement | null;
|
|
299
|
+
|
|
300
|
+
declare function useTheme(options?: UseThemeOptions): UseThemeResult;
|
|
301
|
+
declare function ThemeToggle(props: ThemeToggleProps): React.ReactElement;
|
|
302
|
+
declare function ThemeScope(props: ThemeScopeProps): React.ReactElement;
|
|
303
|
+
|
|
304
|
+
interface TransactionDetailsProps {
|
|
305
|
+
readonly state?: TransactionDetailsSource;
|
|
306
|
+
readonly open?: boolean;
|
|
307
|
+
readonly className?: string;
|
|
308
|
+
readonly clipboard?: Pick<Clipboard, "writeText">;
|
|
309
|
+
readonly onError?: (error: unknown) => void;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Collapsible post-settlement transaction details panel with copy (and optional
|
|
313
|
+
* explorer) buttons. Builds rows from {@link CheckoutState} / detail input, or
|
|
314
|
+
* accepts pre-built rows from `createTransactionDetails*`.
|
|
315
|
+
*/
|
|
316
|
+
declare function TransactionDetails(props: TransactionDetailsProps): React.ReactElement | null;
|
|
317
|
+
|
|
318
|
+
declare function useCheckout(options: UseCheckoutOptions): UseCheckoutResult;
|
|
319
|
+
declare function useCheckoutContext(): UseCheckoutResult;
|
|
320
|
+
declare function CheckoutProvider(props: CheckoutProviderProps): React.ReactElement;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Snapshot -> everything React needs to render it, in one hop.
|
|
324
|
+
*
|
|
325
|
+
* This used to be three: toCheckoutDisplayData -> createCheckoutDisplayModel ->
|
|
326
|
+
* toCheckoutViewModel, a second copy of the flattening rule that
|
|
327
|
+
* `createCheckoutState` already owned. Logging is off because this is a pure
|
|
328
|
+
* projection a host may call as often as it renders; `useCheckout` builds its
|
|
329
|
+
* state through the controller, which does the logging exactly once.
|
|
330
|
+
*/
|
|
331
|
+
declare function createCheckoutViewModel(data: CheckoutData): CheckoutViewModel;
|
|
332
|
+
|
|
333
|
+
declare function PaymentWizard(props: PaymentWizardProps): React.ReactElement;
|
|
334
|
+
|
|
335
|
+
export { type ButtonComponent, Checkout, type CheckoutChildren, type CheckoutClassNames, type CheckoutComponents, type CheckoutData, type CheckoutProps, CheckoutProvider, type CheckoutProviderProps, type CheckoutViewModel, CopyInvoiceButton, type CopyInvoiceButtonProps, InvoiceSummary, type InvoiceSummaryClassNames, type InvoiceSummaryProps, OpenWalletButton, type OpenWalletButtonProps, PaymentData, PaymentState, type PaymentStateProps, PaymentWizard, type PaymentWizardProps, QRCode, type QRCodeProps, SatsDetail, type SatsDetailProps, ThemeScope, type ThemeScopeChildren, type ThemeScopeProps, ThemeToggle, type ThemeToggleProps, TransactionDetails, type TransactionDetailsProps, type UseCheckoutOptions, type UseCheckoutResult, type UseThemeOptions, type UseThemeResult, WaitingState, createCheckoutViewModel, renderSwapDepositPanel, useCheckout, useCheckoutContext, useTheme };
|