@whop/elements 1.0.0-beta.4 → 1.0.0-beta.6

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.
@@ -0,0 +1,490 @@
1
+ /**
2
+ * Options for `whop.dashboard.create()`: the controller's props plus its `on<Event>` callbacks. In React, these are the `<Dashboard>` component's props.
3
+ * @example
4
+ * ```ts
5
+ * import { loadWhop } from "@whop/elements";
6
+ *
7
+ * const whop = (await loadWhop())({ locale: "en" });
8
+ * const dashboard = whop.dashboard.create({}); // options: props + on<Event> callbacks
9
+ * ```
10
+ * @see https://docs.whop.com/elements/latest/dashboard/overview
11
+ */
12
+ export interface DashboardOptions {
13
+ /**
14
+ * A scoped token every surface under this handle reads with. Mint one token for the whole handle on your server with `POST /api/v1/access_tokens`, and set a fresh one with `update({ accessToken })` before it expires. Reading payments needs `payment:basic:read`; buyer emails additionally need `member:email:read`, the customer journey `member:basic:read`, the tracking column `shipment:basic:read`, and the product and plan names on a payment `access_pass:basic:read` and `plan:basic:read`. The banners need `payout:account:read`, and starting verification from the action bar `identity:write`. Omitted, the reads carry the viewer's own session, which only answers same-origin.
15
+ */
16
+ accessToken?: string;
17
+ /**
18
+ * Account or user ID whose records these surfaces read. Account IDs are prefixed `biz_`; user IDs are prefixed `user_`, can read only the viewer's own outstanding actions, and have no payments.
19
+ */
20
+ accountId: string;
21
+ /**
22
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
23
+ */
24
+ onLoadingChange?: ((loading: boolean) => void);
25
+ /**
26
+ * Set `false` to turn off Whop's built-in usage analytics for this handle and its elements. The analytics identity is never threaded to its frames. A reserved option, not element data.
27
+ */
28
+ analytics?: false;
29
+ /**
30
+ * Visual customization for this group's elements. Overrides the global `WhopElements({ appearance })`. Change it live with `update({ appearance })`.
31
+ */
32
+ appearance?: import("./_framework.js").Appearance;
33
+ /**
34
+ * Locale for this group's element UI text. Set it to one of the app's built locales to override the global configuration. Any other value falls back to the default locale.
35
+ */
36
+ locale?: import("./_framework.js").WhopElementsLocale;
37
+ }
38
+
39
+ /**
40
+ * Consumer props for the "required-actions" element. Set at create (or as `<RequiredActionsElement />` JSX props), and updatable live via `update()`.
41
+ * @see https://docs.whop.com/elements/latest/dashboard/required-actions
42
+ */
43
+ export interface RequiredActionsElementProps {
44
+ /**
45
+ * Which verification the Verify button starts. `individual` (KYC) is what unlocks payouts and a Whop card. `business` (KYB) covers that and additionally unlocks financing and business cards — use it for a company that will need those.
46
+ * @default "individual"
47
+ */
48
+ kind?: "individual" | "business";
49
+ }
50
+
51
+ /**
52
+ * The live handle for a mounted "required-actions" element. Returned by `create("required-actions")`; in React, the component's `ref`.
53
+ * @see https://docs.whop.com/elements/latest/dashboard/required-actions
54
+ */
55
+ export interface RequiredActionsElementHandle {
56
+ /**
57
+ * Re-read the account. Call it when the viewer returns from verifying or depositing so the banners reflect the new state without waiting for the cache to expire.
58
+ */
59
+ refresh: () => Promise<void>;
60
+ /**
61
+ * Mounts the element in `target` and starts loading. React components mount themselves.
62
+ */
63
+ mount: (target: string | HTMLElement) => void;
64
+ /**
65
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
66
+ */
67
+ destroy: () => void;
68
+ /**
69
+ * Merges new props into the mounted element. In React, change the component props instead.
70
+ */
71
+ update: (options: Partial<RequiredActionsElementProps>) => void;
72
+ }
73
+
74
+ /**
75
+ * Options for `create("required-actions")`: the consumer props plus event callbacks and lifecycle hooks.
76
+ * @example
77
+ * ```ts
78
+ * const required_actions = dashboard.create("required-actions", {}); // this interface: props + on<Event> callbacks
79
+ * required_actions.mount("#dashboard-required-actions");
80
+ * ```
81
+ * @see https://docs.whop.com/elements/latest/dashboard/required-actions
82
+ */
83
+ export interface RequiredActionsElementCreateOptions {
84
+ /**
85
+ * Which verification the Verify button starts. `individual` (KYC) is what unlocks payouts and a Whop card. `business` (KYB) covers that and additionally unlocks financing and business cards — use it for a company that will need those.
86
+ * @default "individual"
87
+ */
88
+ kind?: "individual" | "business";
89
+ /**
90
+ * The viewer pressed a banner button. Fires for every action, including ones the element also handles itself.
91
+ */
92
+ onActionRequested?: ((payload: { action: "deposit_funds" | "review_held_payments" | "accept_airwallex_terms" | "submit_information_request" | "update_automatic_withdrawal_method" | "reauthorize_payout_methods" | "update_payout_profile" | "card_usage_review" | "verify_identity" | "verify_airwallex_account" | "sign_formation_documents" | "connect_fulfillment_tracker" | "setup_apple_pay_domains" | "configure_tax_remitter" | "add_vat_registration" | "enable_two_factor_authentication"; accountId: string; }) => void);
93
+ /**
94
+ * The viewer pressed Verify on a `verify_identity` action the element can start. The element opens identity verification itself — this fires alongside, so a host can record the trip.
95
+ */
96
+ onIdentityVerificationRequested?: ((payload: { accountId: string; }) => void);
97
+ /**
98
+ * The viewer pressed Add money. The element never opens a deposit flow itself — mount your own, such as the `wallet` controller’s `deposit` element, in answer to this.
99
+ */
100
+ onDepositRequested?: ((payload: Record<string, never>) => void);
101
+ /**
102
+ * Runs after the loading skeleton first paints and before `onReady`.
103
+ */
104
+ onLoaderStart?: (() => void);
105
+ /**
106
+ * Runs after the element's first complete paint.
107
+ */
108
+ onReady?: (() => void);
109
+ /**
110
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
111
+ */
112
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
113
+ }
114
+
115
+ /**
116
+ * Consumer props for the "verification" element. Set at create (or as `<VerificationElement />` JSX props), and updatable live via `update()`.
117
+ * @see https://docs.whop.com/elements/latest/dashboard/verification
118
+ */
119
+ export interface VerificationElementProps {
120
+ /**
121
+ * Which verification the button starts. `individual` (KYC) is what unlocks payouts and a Whop card. `business` (KYB) covers that and additionally unlocks financing and business cards — use it for a company that will need those.
122
+ * @default "individual"
123
+ */
124
+ kind?: "individual" | "business";
125
+ /**
126
+ * Show a compact inline prompt without the supporting description.
127
+ * @default false
128
+ */
129
+ compact?: boolean;
130
+ }
131
+
132
+ /**
133
+ * The live handle for a mounted "verification" element. Returned by `create("verification")`; in React, the component's `ref`.
134
+ * @see https://docs.whop.com/elements/latest/dashboard/verification
135
+ */
136
+ export interface VerificationElementHandle {
137
+ /**
138
+ * Re-read the account. Call it when the viewer returns from verifying so the banner reflects the new state without waiting for the cache to expire.
139
+ */
140
+ refresh: () => Promise<void>;
141
+ /**
142
+ * Mounts the element in `target` and starts loading. React components mount themselves.
143
+ */
144
+ mount: (target: string | HTMLElement) => void;
145
+ /**
146
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
147
+ */
148
+ destroy: () => void;
149
+ /**
150
+ * Merges new props into the mounted element. In React, change the component props instead.
151
+ */
152
+ update: (options: Partial<VerificationElementProps>) => void;
153
+ }
154
+
155
+ /**
156
+ * Options for `create("verification")`: the consumer props plus event callbacks and lifecycle hooks.
157
+ * @example
158
+ * ```ts
159
+ * const verification = dashboard.create("verification", {}); // this interface: props + on<Event> callbacks
160
+ * verification.mount("#dashboard-verification");
161
+ * ```
162
+ * @see https://docs.whop.com/elements/latest/dashboard/verification
163
+ */
164
+ export interface VerificationElementCreateOptions {
165
+ /**
166
+ * Which verification the button starts. `individual` (KYC) is what unlocks payouts and a Whop card. `business` (KYB) covers that and additionally unlocks financing and business cards — use it for a company that will need those.
167
+ * @default "individual"
168
+ */
169
+ kind?: "individual" | "business";
170
+ /**
171
+ * Show a compact inline prompt without the supporting description.
172
+ * @default false
173
+ */
174
+ compact?: boolean;
175
+ /**
176
+ * The viewer pressed the verify button. The element never navigates — mount your own verification, such as the `verifications` controller, in answer to this.
177
+ */
178
+ onVerificationRequested?: ((payload: { accountId: string; }) => void);
179
+ /**
180
+ * Runs after the loading skeleton first paints and before `onReady`.
181
+ */
182
+ onLoaderStart?: (() => void);
183
+ /**
184
+ * Runs after the element's first complete paint.
185
+ */
186
+ onReady?: (() => void);
187
+ /**
188
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
189
+ */
190
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
191
+ }
192
+
193
+ /**
194
+ * Consumer props for the "paymentsTable" element. Set at create (or as `<PaymentsTableElement />` JSX props), and updatable live via `update()`.
195
+ * @see https://docs.whop.com/elements/latest/dashboard/paymentsTable
196
+ */
197
+ export interface PaymentsTableElementProps {
198
+ /**
199
+ * Show the header action menu, Export button, and table settings button.
200
+ * @default true
201
+ */
202
+ showActions?: boolean;
203
+ /**
204
+ * Show the three-dot action menu on each payment row.
205
+ * @default true
206
+ */
207
+ showRowActions?: boolean;
208
+ /**
209
+ * Show the six payment status boxes above the filters.
210
+ * @default true
211
+ */
212
+ showStatusTabs?: boolean;
213
+ /**
214
+ * Show the tracking column and filter for physical-product accounts. Tracking data requires `shipment:basic:read`.
215
+ * @default true
216
+ */
217
+ showTracking?: boolean;
218
+ }
219
+
220
+ /**
221
+ * The live handle for a mounted "paymentsTable" element. Returned by `create("paymentsTable")`; in React, the component's `ref`.
222
+ * @see https://docs.whop.com/elements/latest/dashboard/paymentsTable
223
+ */
224
+ export interface PaymentsTableElementHandle {
225
+ /**
226
+ * Reload payments after a refund or another change.
227
+ */
228
+ refresh: () => Promise<void>;
229
+ /**
230
+ * Mounts the element in `target` and starts loading. React components mount themselves.
231
+ */
232
+ mount: (target: string | HTMLElement) => void;
233
+ /**
234
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
235
+ */
236
+ destroy: () => void;
237
+ /**
238
+ * Merges new props into the mounted element. In React, change the component props instead.
239
+ */
240
+ update: (options: Partial<PaymentsTableElementProps>) => void;
241
+ }
242
+
243
+ /**
244
+ * Options for `create("paymentsTable")`: the consumer props plus event callbacks and lifecycle hooks.
245
+ * @example
246
+ * ```ts
247
+ * const paymentsTable = dashboard.create("paymentsTable", {}); // this interface: props + on<Event> callbacks
248
+ * paymentsTable.mount("#dashboard-paymentsTable");
249
+ * ```
250
+ * @see https://docs.whop.com/elements/latest/dashboard/paymentsTable
251
+ */
252
+ export interface PaymentsTableElementCreateOptions {
253
+ /**
254
+ * Show the header action menu, Export button, and table settings button.
255
+ * @default true
256
+ */
257
+ showActions?: boolean;
258
+ /**
259
+ * Show the three-dot action menu on each payment row.
260
+ * @default true
261
+ */
262
+ showRowActions?: boolean;
263
+ /**
264
+ * Show the six payment status boxes above the filters.
265
+ * @default true
266
+ */
267
+ showStatusTabs?: boolean;
268
+ /**
269
+ * Show the tracking column and filter for physical-product accounts. Tracking data requires `shipment:basic:read`.
270
+ * @default true
271
+ */
272
+ showTracking?: boolean;
273
+ /**
274
+ * Open payment details in your application.
275
+ */
276
+ onPaymentSelected?: ((payload: { paymentId: string; }) => void);
277
+ /**
278
+ * Open the invoice in your application.
279
+ */
280
+ onInvoiceRequested?: ((payload: { paymentId: string; }) => void);
281
+ /**
282
+ * Open the buyer in your application.
283
+ */
284
+ onUserSelected?: ((payload: { userId: string; }) => void);
285
+ /**
286
+ * The viewer requested a refund. Your application must confirm and authorize it server-side. Refund controls are enabled only when this callback is provided.
287
+ */
288
+ onRefundRequested?: ((payload: { paymentIds: string[]; }) => void);
289
+ /**
290
+ * Open the account’s payment settings in your application.
291
+ */
292
+ onSettingsRequested?: ((payload: Record<string, never>) => void);
293
+ /**
294
+ * Runs after the loading skeleton first paints and before `onReady`.
295
+ */
296
+ onLoaderStart?: (() => void);
297
+ /**
298
+ * Runs after the element's first complete paint.
299
+ */
300
+ onReady?: (() => void);
301
+ /**
302
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
303
+ */
304
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
305
+ }
306
+
307
+ /**
308
+ * Consumer props for the "paymentDetail" element. Set at create (or as `<PaymentDetailElement />` JSX props), and updatable live via `update()`.
309
+ * @see https://docs.whop.com/elements/latest/dashboard/paymentDetail
310
+ */
311
+ export interface PaymentDetailElementProps {
312
+ /**
313
+ * Show the top-right Refund button and action menu. Mutating actions require event handlers.
314
+ * @default true
315
+ */
316
+ showActions?: boolean;
317
+ /**
318
+ * The payment to display, prefixed pay_. Required to load a payment.
319
+ * @default ""
320
+ */
321
+ paymentId?: string;
322
+ /**
323
+ * Show the payment amount, fees, and net amount.
324
+ * @default true
325
+ */
326
+ showBreakdown?: boolean;
327
+ /**
328
+ * Show the payment activity timeline.
329
+ * @default true
330
+ */
331
+ showActivity?: boolean;
332
+ /**
333
+ * Show customer name, username, email, phone, and billing address when permitted.
334
+ * @default true
335
+ */
336
+ showCustomer?: boolean;
337
+ /**
338
+ * Show product, plan, payment method, and payment identifiers.
339
+ * @default true
340
+ */
341
+ showDetails?: boolean;
342
+ /**
343
+ * Show the customer journey. Reads the account-scoped Events API only while visible.
344
+ * @default true
345
+ */
346
+ showJourney?: boolean;
347
+ }
348
+
349
+ /**
350
+ * The live handle for a mounted "paymentDetail" element. Returned by `create("paymentDetail")`; in React, the component's `ref`.
351
+ * @see https://docs.whop.com/elements/latest/dashboard/paymentDetail
352
+ */
353
+ export interface PaymentDetailElementHandle {
354
+ /**
355
+ * Reload the payment and its fees after a host action completes.
356
+ */
357
+ refresh: () => Promise<void>;
358
+ /**
359
+ * Mounts the element in `target` and starts loading. React components mount themselves.
360
+ */
361
+ mount: (target: string | HTMLElement) => void;
362
+ /**
363
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
364
+ */
365
+ destroy: () => void;
366
+ /**
367
+ * Merges new props into the mounted element. In React, change the component props instead.
368
+ */
369
+ update: (options: Partial<PaymentDetailElementProps>) => void;
370
+ }
371
+
372
+ /**
373
+ * Options for `create("paymentDetail")`: the consumer props plus event callbacks and lifecycle hooks.
374
+ * @example
375
+ * ```ts
376
+ * const paymentDetail = dashboard.create("paymentDetail", {}); // this interface: props + on<Event> callbacks
377
+ * paymentDetail.mount("#dashboard-paymentDetail");
378
+ * ```
379
+ * @see https://docs.whop.com/elements/latest/dashboard/paymentDetail
380
+ */
381
+ export interface PaymentDetailElementCreateOptions {
382
+ /**
383
+ * Show the top-right Refund button and action menu. Mutating actions require event handlers.
384
+ * @default true
385
+ */
386
+ showActions?: boolean;
387
+ /**
388
+ * The payment to display, prefixed pay_. Required to load a payment.
389
+ * @default ""
390
+ */
391
+ paymentId?: string;
392
+ /**
393
+ * Show the payment amount, fees, and net amount.
394
+ * @default true
395
+ */
396
+ showBreakdown?: boolean;
397
+ /**
398
+ * Show the payment activity timeline.
399
+ * @default true
400
+ */
401
+ showActivity?: boolean;
402
+ /**
403
+ * Show customer name, username, email, phone, and billing address when permitted.
404
+ * @default true
405
+ */
406
+ showCustomer?: boolean;
407
+ /**
408
+ * Show product, plan, payment method, and payment identifiers.
409
+ * @default true
410
+ */
411
+ showDetails?: boolean;
412
+ /**
413
+ * Show the customer journey. Reads the account-scoped Events API only while visible.
414
+ * @default true
415
+ */
416
+ showJourney?: boolean;
417
+ /**
418
+ * Confirm and authorize a refund in your application. Enabled only when refundable and a handler is provided.
419
+ */
420
+ onRefundRequested?: ((payload: { paymentId: string; }) => void);
421
+ /**
422
+ * Confirm and authorize another charge attempt in your application.
423
+ */
424
+ onRetryRequested?: ((payload: { paymentId: string; }) => void);
425
+ /**
426
+ * Confirm and authorize voiding this payment in your application.
427
+ */
428
+ onVoidRequested?: ((payload: { paymentId: string; }) => void);
429
+ /**
430
+ * View or download the invoice in your application.
431
+ */
432
+ onInvoiceRequested?: ((payload: { paymentId: string; }) => void);
433
+ /**
434
+ * Open the customer in your application.
435
+ */
436
+ onCustomerSelected?: ((payload: { userId: string; memberId: string | null; }) => void);
437
+ /**
438
+ * Open your customer messaging UI.
439
+ */
440
+ onMessageRequested?: ((payload: { userId: string; }) => void);
441
+ /**
442
+ * Runs after the loading skeleton first paints and before `onReady`.
443
+ */
444
+ onLoaderStart?: (() => void);
445
+ /**
446
+ * Runs after the element's first complete paint.
447
+ */
448
+ onReady?: (() => void);
449
+ /**
450
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
451
+ */
452
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
453
+ }
454
+
455
+ /**
456
+ * The Dashboard handle, returned by `whop.dashboard.create()` (React: `useDashboard()`). Mounts the elements and carries the controller's actions.
457
+ * @see https://docs.whop.com/elements/latest/dashboard/overview
458
+ */
459
+ export interface DashboardHandle {
460
+ /**
461
+ * The outstanding-action banners from Whop's balance dashboard — identity verification, deposits, tax, and the rest — in the same order the API returns them. An account with nothing outstanding renders nothing at all, so the element can sit permanently in a layout. Copy comes from the API. Pressing Verify starts a hosted identity session and leaves for it; Add money reports `depositRequested` and stays put, so the host mounts its own deposit flow — the `wallet` controller's `deposit` element, say; every other button follows the action's own link. Reads with the Dashboard handle's `accessToken`, which needs `payout:account:read`, plus `identity:write` to start verification. A failed read renders nothing rather than an error — a banner should never become the loudest thing on someone else's page.
462
+ */
463
+ create(name: "required-actions", options?: RequiredActionsElementCreateOptions): RequiredActionsElementHandle;
464
+ /**
465
+ * A banner asking the account holder to verify their identity, shown only while verification is outstanding — an account that has already verified renders nothing at all, so the element can sit permanently in a layout. The headline and status messages come from the API, with a shorter description when inviting the account holder to start verification, so they track the account's actual state: an unstarted account is invited to unlock cards and payouts, one under review reads as pending, and a failed or flagged one says so. Pressing the button reports `verificationRequested` and stays put, so the host mounts its own verification — the `verifications` controller's `kyc` element, say. Reads with the Dashboard handle's `accessToken`, which needs `payout:account:read`. A failed read renders nothing rather than an error — a nudge should never become the loudest thing on the page.
466
+ */
467
+ create(name: "verification", options?: VerificationElementCreateOptions): VerificationElementHandle;
468
+ /**
469
+ * The dashboard payments table with status cards, search, filters, sorting, row selection, CSV export, column settings, and pagination. Reads all payment pages to compute complete counts and filter locally; intended for accounts with modest payment histories. Customer details and refunds are handed to your application through events.
470
+ */
471
+ create(name: "paymentsTable", options?: PaymentsTableElementCreateOptions): PaymentsTableElementHandle;
472
+ /**
473
+ * A payment detail page with the dashboard breakdown, activity, customer, details, and customer journey. Each section can be hidden. Reads payment:basic:read; customer email needs member:email:read and journey needs member:basic:read. Action events let your application confirm and authorize changes; this element never refunds, retries, or voids a payment itself.
474
+ */
475
+ create(name: "paymentDetail", options?: PaymentDetailElementCreateOptions): PaymentDetailElementHandle;
476
+ /**
477
+ * Merges new handle options into every mounted element. In React, change the namespace props instead.
478
+ */
479
+ update(options: Partial<DashboardOptions>): void;
480
+ /**
481
+ * Destroys every element and sub-controller this handle created, removes the controller frame, and releases its subscriptions. You can call it more than once, but a destroyed handle refuses any other call — create a new handle to start over. React removes the group automatically when the provider unmounts.
482
+ */
483
+ destroy(): void;
484
+ }
485
+
486
+ /**
487
+ * Dashboard's static actions, callable with nothing mounted: `whop.dashboard.<method>()` (React: `useWhop().dashboard.<method>()`).
488
+ * @see https://docs.whop.com/elements/latest/dashboard/overview
489
+ */
490
+ export interface DashboardStatics {}