@openreceive/react 0.1.0 → 0.2.1

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 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 "react";
2
- import { type OpenReceiveQrEncoder, type OpenReceiveBrowserLogContext, type OpenReceiveBrowserLogger, type CheckoutPhase, type CheckoutSnapshot, type CheckoutState, type CheckoutStatusModel, type OpenReceiveRefreshInvoiceResult, type OpenReceiveResolvedTheme, type OpenReceiveThemeModel, type OpenReceiveThemePreference, type Status } from "@openreceive/browser/internal";
3
- export interface CheckoutData {
4
- readonly invoice: CheckoutSnapshot;
1
+ import * as React from 'react';
2
+ import { CheckoutComponentProps, CheckoutState, QrEncoder, BrowserLoggerOption, CheckoutStatusRefresh, Status, CheckoutSnapshot, BrowserLogContext, CheckoutInvoiceSnapshot, ThemePreference, ResolvedTheme, ThemeModel, PaymentDataSource, CheckoutPhase, CheckoutStatusModel, 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
- export interface CheckoutViewModel {
7
- readonly invoice_id?: string;
8
- readonly invoice: string;
9
- readonly payment_hash?: string;
10
- readonly amount_msats?: number;
11
- readonly fiat_quote?: CheckoutSnapshot["fiat_quote"];
12
- readonly expires_at?: number;
13
- readonly settled_at?: number;
14
- readonly lightningUri: string;
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
- export interface UseCheckoutOptions extends CheckoutData {
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?: OpenReceiveBrowserLogger;
24
- readonly onError?: (error: unknown) => void;
25
- readonly lookupInvoice?: (state: CheckoutState) => Promise<Partial<CheckoutSnapshot>>;
26
- readonly lookupUrl?: string | false;
27
- readonly refreshInvoice?: (state: CheckoutState) => Promise<CheckoutSnapshot | OpenReceiveRefreshInvoiceResult>;
28
- readonly refreshUrl?: string | ((state: CheckoutState) => string);
29
- readonly refreshHeaders?: Readonly<Record<string, string>>;
30
- readonly refreshIdempotencyKey?: string | ((state: CheckoutState) => string);
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
- export interface UseCheckoutResult extends CheckoutViewModel {
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
- export interface CheckoutProviderProps extends UseCheckoutOptions {
66
+ interface CheckoutProviderProps extends UseCheckoutOptions {
53
67
  readonly children?: React.ReactNode | ((checkout: UseCheckoutResult) => React.ReactNode);
54
68
  }
55
- export interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
69
+ interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
56
70
  readonly invoice: string;
57
- readonly encoder?: OpenReceiveQrEncoder;
71
+ readonly encoder?: QrEncoder;
58
72
  readonly width?: number;
59
73
  readonly onError?: (error: unknown) => void;
60
74
  }
61
- export type ButtonComponent = React.ElementType<React.ButtonHTMLAttributes<HTMLButtonElement>>;
62
- export interface CopyInvoiceButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
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?: OpenReceiveBrowserLogger;
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
- export interface OpenWalletButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
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?: OpenReceiveBrowserLogger;
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
- export interface PaymentStateProps extends React.HTMLAttributes<HTMLSpanElement> {
95
+ interface PaymentStateProps extends React.HTMLAttributes<HTMLSpanElement> {
82
96
  readonly state?: string;
83
97
  }
84
- export interface InvoiceSummaryClassNames {
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
- export interface InvoiceSummaryProps extends React.HTMLAttributes<HTMLDivElement> {
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
- export interface CheckoutClassNames extends InvoiceSummaryClassNames {
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
- export interface CheckoutComponents {
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
- export type CheckoutChildren = React.ReactNode | ((model: UseCheckoutResult) => React.ReactNode);
121
- export interface CheckoutProps extends CheckoutData, Omit<React.HTMLAttributes<HTMLElement>, "children"> {
122
- readonly qrEncoder?: OpenReceiveQrEncoder;
123
- readonly logger?: OpenReceiveBrowserLogger;
124
- readonly onError?: (error: unknown) => void;
125
- readonly lookupInvoice?: (state: CheckoutState) => Promise<Partial<CheckoutSnapshot>>;
126
- readonly lookupUrl?: string | false;
127
- readonly refreshInvoice?: (state: CheckoutState) => Promise<CheckoutSnapshot | OpenReceiveRefreshInvoiceResult>;
128
- readonly refreshUrl?: string | ((state: CheckoutState) => string);
129
- readonly refreshHeaders?: Readonly<Record<string, string>>;
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 paymentWizard?: boolean;
137
- readonly themeSwitcher?: boolean;
138
- readonly defaultTheme?: OpenReceiveThemePreference;
139
- readonly themeStorageKey?: string;
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
- export interface UseThemeOptions {
146
- readonly defaultTheme?: OpenReceiveThemePreference;
157
+ interface UseThemeOptions {
158
+ readonly defaultTheme?: ThemePreference;
147
159
  readonly storageKey?: string;
148
160
  readonly storage?: Storage;
149
161
  }
150
- export interface UseThemeResult {
151
- readonly theme: OpenReceiveThemePreference;
152
- readonly resolvedTheme: OpenReceiveResolvedTheme;
153
- readonly model: OpenReceiveThemeModel;
154
- readonly nextTheme: OpenReceiveThemePreference;
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: OpenReceiveThemeModel["attributes"];
157
- readonly checkoutElementAttributes: OpenReceiveThemeModel["checkoutElementAttributes"];
158
- setTheme(theme: OpenReceiveThemePreference): void;
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
- export interface ThemeToggleProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
162
- readonly theme?: OpenReceiveThemePreference;
163
- readonly resolvedTheme?: OpenReceiveResolvedTheme;
164
- readonly onThemeChange?: (theme: OpenReceiveThemePreference) => void;
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
- export type ThemeScopeChildren = React.ReactNode | ((theme: UseThemeResult) => React.ReactNode);
168
- export interface ThemeScopeProps extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {
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?: OpenReceiveThemePreference;
171
- readonly themeStorageKey?: string;
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,145 @@ export interface ThemeScopeProps extends Omit<React.HTMLAttributes<HTMLElement>,
176
190
  readonly ButtonComponent?: ButtonComponent;
177
191
  readonly children?: ThemeScopeChildren;
178
192
  }
179
- export interface PaymentWizardProps {
180
- readonly invoice: string;
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?: OpenReceiveBrowserLogger;
183
- readonly logContext?: OpenReceiveBrowserLogContext;
184
- readonly countryStorageKey?: string;
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
- export declare function createCheckoutViewModel(data: CheckoutData): CheckoutViewModel;
188
- export declare function useCheckout(options: UseCheckoutOptions): UseCheckoutResult;
189
- export declare function useCheckoutContext(): UseCheckoutResult;
190
- export declare function CheckoutProvider(props: CheckoutProviderProps): React.ReactElement;
191
- export declare function QRCode(props: QRCodeProps): React.ReactElement;
192
- export declare function CopyInvoiceButton(props: CopyInvoiceButtonProps): React.ReactElement;
193
- export declare function OpenWalletButton(props: OpenWalletButtonProps): React.ReactElement;
194
- export declare function PaymentState(props: PaymentStateProps): React.ReactElement;
195
- export declare function useTheme(options?: UseThemeOptions): UseThemeResult;
196
- export declare function ThemeToggle(props: ThemeToggleProps): React.ReactElement;
197
- export declare function ThemeScope(props: ThemeScopeProps): React.ReactElement;
198
- export declare function WaitingState(props: {
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
- export declare function PaymentWizard(props: PaymentWizardProps): React.ReactElement;
207
- export declare function InvoiceSummary(props: InvoiceSummaryProps): React.ReactElement;
208
- export declare function Checkout(props: CheckoutProps): React.ReactElement;
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
+ readonly now?: number;
291
+ readonly encoder?: QrEncoder;
292
+ readonly clipboard?: Pick<Clipboard, "writeText">;
293
+ readonly logger?: BrowserLogger | false;
294
+ readonly onError?: (error: unknown) => void;
295
+ readonly onRefund: (attemptId: string, refundAddress: string, confirm: boolean) => Promise<void>;
296
+ readonly onBackToLightning: () => void;
297
+ }): React.ReactElement | null;
298
+
299
+ declare function useTheme(options?: UseThemeOptions): UseThemeResult;
300
+ declare function ThemeToggle(props: ThemeToggleProps): React.ReactElement;
301
+ declare function ThemeScope(props: ThemeScopeProps): React.ReactElement;
302
+
303
+ interface TransactionDetailsProps {
304
+ readonly state?: TransactionDetailsSource;
305
+ readonly open?: boolean;
306
+ readonly className?: string;
307
+ readonly clipboard?: Pick<Clipboard, "writeText">;
308
+ readonly onError?: (error: unknown) => void;
309
+ }
310
+ /**
311
+ * Collapsible post-settlement transaction details panel with copy (and optional
312
+ * explorer) buttons. Builds rows from {@link CheckoutState} / detail input, or
313
+ * accepts pre-built rows from `createTransactionDetails*`.
314
+ */
315
+ declare function TransactionDetails(props: TransactionDetailsProps): React.ReactElement | null;
316
+
317
+ declare function useCheckout(options: UseCheckoutOptions): UseCheckoutResult;
318
+ declare function useCheckoutContext(): UseCheckoutResult;
319
+ declare function CheckoutProvider(props: CheckoutProviderProps): React.ReactElement;
320
+
321
+ /**
322
+ * Snapshot -> everything React needs to render it, in one hop.
323
+ *
324
+ * This used to be three: toCheckoutDisplayData -> createCheckoutDisplayModel ->
325
+ * toCheckoutViewModel, a second copy of the flattening rule that
326
+ * `createCheckoutState` already owned. Logging is off because this is a pure
327
+ * projection a host may call as often as it renders; `useCheckout` builds its
328
+ * state through the controller, which does the logging exactly once.
329
+ */
330
+ declare function createCheckoutViewModel(data: CheckoutData): CheckoutViewModel;
331
+
332
+ declare function PaymentWizard(props: PaymentWizardProps): React.ReactElement;
333
+
334
+ 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 };