@tesouro/embedded-components-react 0.3.47 → 0.3.49

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,1347 @@
1
+ import * as React from 'react';
2
+ import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } from 'react';
3
+ import { FallbackProps } from 'react-error-boundary';
4
+
5
+ type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
6
+ children?: ReactNode;
7
+ };
8
+ type LinkComponent = ComponentType<LinkComponentProps>;
9
+ /**
10
+ * The UI frameworks a widget's UI layer can render with.
11
+ *
12
+ * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
13
+ * implicit fallback, so existing consumers that select nothing keep rendering
14
+ * shadcn.
15
+ * - `tecton` — the Tecton implementation.
16
+ *
17
+ * Declared as an `as const` object (not a TypeScript `enum`) per repo
18
+ * convention.
19
+ */
20
+ declare const UIFramework: {
21
+ readonly Shadcn: "shadcn";
22
+ readonly Tecton: "tecton";
23
+ };
24
+ type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
25
+
26
+ interface PaginationFooterLabels {
27
+ rowsPerPageLabel: string;
28
+ previousPageButton: string;
29
+ nextPageButton: string;
30
+ }
31
+
32
+ /**
33
+ * Every key of `T` optional, recursively, so a consumer can override one nested
34
+ * label without restating its siblings. Defined locally because the repo has no
35
+ * shared deep-partial type and does not depend on `type-fest`.
36
+ */
37
+ type PartialDeep$3<T> = {
38
+ [K in keyof T]?: T[K] extends object ? PartialDeep$3<T[K]> : T[K];
39
+ };
40
+ interface CardsListColumnHeaderLabels {
41
+ cardName: string;
42
+ fundingAccount: string;
43
+ cardholder: string;
44
+ status: string;
45
+ limit: string;
46
+ }
47
+ /**
48
+ * Screen-reader-only copy naming the details sheet a row click opens.
49
+ *
50
+ * Both strings are invisible by design: the sheet's visible header belongs to
51
+ * whatever the owner slots into it (`CardDetailsPanel`, via `CardsWidget`), and a
52
+ * second visible title would duplicate it. They exist because the sheet is a
53
+ * dialog, and a dialog without an accessible name is announced as nothing.
54
+ */
55
+ interface CardsListDetailsSheetLabels {
56
+ /** Accessible name for the sheet. */
57
+ title: string;
58
+ /** Accessible description, announced after the name. */
59
+ description: string;
60
+ }
61
+ /**
62
+ * Every user-facing string the cards list renders, including screen-reader-only
63
+ * copy and the decorative separators.
64
+ *
65
+ * There is intentionally **no** card-type or card-status map here: the row
66
+ * arrives with `typeLabel` and `statusLabel` already resolved, so the
67
+ * `DIGITAL`/`PHYSICAL` and `PENDING_ACTIVATION`/`ACTIVE`/`LOCKED`/`CLOSED` maps
68
+ * live in `shared/feature` keyed on the generated types (EMBD-4404 amendment;
69
+ * see `statusBadge.ts`). That is also where the "label keys carry the code term,
70
+ * values carry the copy" rule applies — `digital`, never `virtual`, so a later
71
+ * wording change is not a breaking rename.
72
+ */
73
+ interface CardsListLabels {
74
+ title: string;
75
+ /** Accessible name for the list region. */
76
+ regionLabel: string;
77
+ columnHeaders: CardsListColumnHeaderLabels;
78
+ /** Screen-reader name for the unheaded trailing row-actions column. */
79
+ rowActionsColumn: string;
80
+ showMyCardsToggle: string;
81
+ createCardButton: string;
82
+ activateButton: string;
83
+ /** Accessible name for a row's Activate button; the card name is appended. */
84
+ activateButtonForCard: string;
85
+ /** Accessible name for a row's open-details control; card name appended. */
86
+ selectCardButton: string;
87
+ /** Separator between a card's nickname and its last four digits. */
88
+ cardNameSeparator: string;
89
+ /** Stands in for the limit when a card has none set. */
90
+ noLimit: string;
91
+ /** Announced while a page of cards is loading. */
92
+ loadingLabel: string;
93
+ emptyTitle: string;
94
+ emptyDescription: string;
95
+ errorTitle: string;
96
+ errorDescription: string;
97
+ retryButton: string;
98
+ pagination: PaginationFooterLabels;
99
+ /**
100
+ * Copy for the details sheet a row click opens. Rendered by
101
+ * `CardsListDetailsSheet` rather than by the table, but part of this surface
102
+ * because it is one screen and one `labels` prop — the same reason `pagination`
103
+ * sits here for a footer that lives in `shared/ui`.
104
+ */
105
+ detailsSheet: CardsListDetailsSheetLabels;
106
+ /**
107
+ * Screen-reader copy for the same sheet when Create card is slotted in, rather
108
+ * than a selected card's details. Same chrome, different accessible name.
109
+ */
110
+ createSheet: CardsListDetailsSheetLabels;
111
+ }
112
+
113
+ type AuthToken = string | undefined;
114
+ interface Auth {
115
+ /**
116
+ * Which part of the request do we use to send the auth?
117
+ *
118
+ * @default 'header'
119
+ */
120
+ in?: 'header' | 'query' | 'cookie';
121
+ /**
122
+ * A unique identifier for the security scheme.
123
+ *
124
+ * Defined only when there are multiple security schemes whose `Auth`
125
+ * shape would otherwise be identical.
126
+ */
127
+ key?: string;
128
+ /**
129
+ * Header or query parameter name.
130
+ *
131
+ * @default 'Authorization'
132
+ */
133
+ name?: string;
134
+ scheme?: 'basic' | 'bearer';
135
+ type: 'apiKey' | 'http';
136
+ }
137
+
138
+ interface SerializerOptions<T> {
139
+ /**
140
+ * @default true
141
+ */
142
+ explode: boolean;
143
+ style: T;
144
+ }
145
+ type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
146
+ type ObjectStyle = 'form' | 'deepObject';
147
+
148
+ type QuerySerializer = (query: Record<string, unknown>) => string;
149
+ type BodySerializer = (body: unknown) => unknown;
150
+ type QuerySerializerOptionsObject = {
151
+ allowReserved?: boolean;
152
+ array?: Partial<SerializerOptions<ArrayStyle>>;
153
+ object?: Partial<SerializerOptions<ObjectStyle>>;
154
+ };
155
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
156
+ /**
157
+ * Per-parameter serialization overrides. When provided, these settings
158
+ * override the global array/object settings for specific parameter names.
159
+ */
160
+ parameters?: Record<string, QuerySerializerOptionsObject>;
161
+ };
162
+
163
+ type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
164
+ type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
165
+ /**
166
+ * Returns the final request URL.
167
+ */
168
+ buildUrl: BuildUrlFn;
169
+ getConfig: () => Config;
170
+ request: RequestFn;
171
+ setConfig: (config: Config) => Config;
172
+ } & {
173
+ [K in HttpMethod]: MethodFn;
174
+ } & ([SseFn] extends [never] ? {
175
+ sse?: never;
176
+ } : {
177
+ sse: {
178
+ [K in HttpMethod]: SseFn;
179
+ };
180
+ });
181
+ interface Config$1 {
182
+ /**
183
+ * Auth token or a function returning auth token. The resolved value will be
184
+ * added to the request payload as defined by its `security` array.
185
+ */
186
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
187
+ /**
188
+ * A function for serializing request body parameter. By default,
189
+ * {@link JSON.stringify()} will be used.
190
+ */
191
+ bodySerializer?: BodySerializer | null;
192
+ /**
193
+ * An object containing any HTTP headers that you want to pre-populate your
194
+ * `Headers` object with.
195
+ *
196
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
197
+ */
198
+ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
199
+ /**
200
+ * The request method.
201
+ *
202
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
203
+ */
204
+ method?: Uppercase<HttpMethod>;
205
+ /**
206
+ * A function for serializing request query parameters. By default, arrays
207
+ * will be exploded in form style, objects will be exploded in deepObject
208
+ * style, and reserved characters are percent-encoded.
209
+ *
210
+ * This method will have no effect if the native `paramsSerializer()` Axios
211
+ * API function is used.
212
+ *
213
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
214
+ */
215
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
216
+ /**
217
+ * A function validating request data. This is useful if you want to ensure
218
+ * the request conforms to the desired shape, so it can be safely sent to
219
+ * the server.
220
+ */
221
+ requestValidator?: (data: unknown) => Promise<unknown>;
222
+ /**
223
+ * A function transforming response data before it's returned. This is useful
224
+ * for post-processing data, e.g., converting ISO strings into Date objects.
225
+ */
226
+ responseTransformer?: (data: unknown) => Promise<unknown>;
227
+ /**
228
+ * A function validating response data. This is useful if you want to ensure
229
+ * the response conforms to the desired shape, so it can be safely passed to
230
+ * the transformers and returned to the user.
231
+ */
232
+ responseValidator?: (data: unknown) => Promise<unknown>;
233
+ }
234
+
235
+ type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
236
+ /**
237
+ * Fetch API implementation. You can use this option to provide a custom
238
+ * fetch instance.
239
+ *
240
+ * @default globalThis.fetch
241
+ */
242
+ fetch?: typeof fetch;
243
+ /**
244
+ * Implementing clients can call request interceptors inside this hook.
245
+ */
246
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
247
+ /**
248
+ * Callback invoked when a network or parsing error occurs during streaming.
249
+ *
250
+ * This option applies only if the endpoint returns a stream of events.
251
+ *
252
+ * @param error The error that occurred.
253
+ */
254
+ onSseError?: (error: unknown) => void;
255
+ /**
256
+ * Callback invoked when an event is streamed from the server.
257
+ *
258
+ * This option applies only if the endpoint returns a stream of events.
259
+ *
260
+ * @param event Event streamed from the server.
261
+ * @returns Nothing (void).
262
+ */
263
+ onSseEvent?: (event: StreamEvent<TData>) => void;
264
+ serializedBody?: RequestInit['body'];
265
+ /**
266
+ * Default retry delay in milliseconds.
267
+ *
268
+ * This option applies only if the endpoint returns a stream of events.
269
+ *
270
+ * @default 3000
271
+ */
272
+ sseDefaultRetryDelay?: number;
273
+ /**
274
+ * Maximum number of retry attempts before giving up.
275
+ */
276
+ sseMaxRetryAttempts?: number;
277
+ /**
278
+ * Maximum retry delay in milliseconds.
279
+ *
280
+ * Applies only when exponential backoff is used.
281
+ *
282
+ * This option applies only if the endpoint returns a stream of events.
283
+ *
284
+ * @default 30000
285
+ */
286
+ sseMaxRetryDelay?: number;
287
+ /**
288
+ * Optional sleep function for retry backoff.
289
+ *
290
+ * Defaults to using `setTimeout`.
291
+ */
292
+ sseSleepFn?: (ms: number) => Promise<void>;
293
+ url: string;
294
+ };
295
+ interface StreamEvent<TData = unknown> {
296
+ data: TData;
297
+ event?: string;
298
+ id?: string;
299
+ retry?: number;
300
+ }
301
+ type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
302
+ stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
303
+ };
304
+
305
+ type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
306
+ /** response may be undefined due to a network error where no response object is produced */
307
+ response: Res | undefined,
308
+ /** request may be undefined, because error may be from building the request object itself */
309
+ request: Req | undefined, options: Options) => Err | Promise<Err>;
310
+ type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
311
+ type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
312
+ declare class Interceptors<Interceptor> {
313
+ fns: Array<Interceptor | null>;
314
+ clear(): void;
315
+ eject(id: number | Interceptor): void;
316
+ exists(id: number | Interceptor): boolean;
317
+ getInterceptorIndex(id: number | Interceptor): number;
318
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
319
+ use(fn: Interceptor): number;
320
+ }
321
+ interface Middleware<Req, Res, Err, Options> {
322
+ error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
323
+ request: Interceptors<ReqInterceptor<Req, Options>>;
324
+ response: Interceptors<ResInterceptor<Res, Req, Options>>;
325
+ }
326
+
327
+ type ResponseStyle = 'data' | 'fields';
328
+ interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
329
+ /**
330
+ * Base URL for all requests made by this client.
331
+ */
332
+ baseUrl?: T['baseUrl'];
333
+ /**
334
+ * Fetch API implementation. You can use this option to provide a custom
335
+ * fetch instance.
336
+ *
337
+ * @default globalThis.fetch
338
+ */
339
+ fetch?: typeof fetch;
340
+ /**
341
+ * Please don't use the Fetch client for Next.js applications. The `next`
342
+ * options won't have any effect.
343
+ *
344
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
345
+ */
346
+ next?: never;
347
+ /**
348
+ * Return the response data parsed in a specified format. By default, `auto`
349
+ * will infer the appropriate method from the `Content-Type` response header.
350
+ * You can override this behavior with any of the {@link Body} methods.
351
+ * Select `stream` if you don't want to parse response data at all.
352
+ *
353
+ * @default 'auto'
354
+ */
355
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
356
+ /**
357
+ * Should we return only data or multiple fields (data, error, response, etc.)?
358
+ *
359
+ * @default 'fields'
360
+ */
361
+ responseStyle?: ResponseStyle;
362
+ /**
363
+ * Throw an error instead of returning it in the response?
364
+ *
365
+ * @default false
366
+ */
367
+ throwOnError?: T['throwOnError'];
368
+ }
369
+ interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
370
+ responseStyle: TResponseStyle;
371
+ throwOnError: ThrowOnError;
372
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
373
+ /**
374
+ * Any body that you want to add to your request.
375
+ *
376
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
377
+ */
378
+ body?: unknown;
379
+ path?: Record<string, unknown>;
380
+ query?: Record<string, unknown>;
381
+ /**
382
+ * Security mechanism(s) to use for the request.
383
+ */
384
+ security?: ReadonlyArray<Auth>;
385
+ url: Url;
386
+ }
387
+ interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
388
+ headers: Headers;
389
+ serializedBody?: string;
390
+ }
391
+ type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
392
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
393
+ request: Request;
394
+ response: Response;
395
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
396
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
397
+ error: undefined;
398
+ } | {
399
+ data: undefined;
400
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
401
+ }) & {
402
+ /** request may be undefined, because error may be from building the request object itself */
403
+ request?: Request;
404
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
405
+ response?: Response;
406
+ }>;
407
+ interface ClientOptions$1 {
408
+ baseUrl?: string;
409
+ responseStyle?: ResponseStyle;
410
+ throwOnError?: boolean;
411
+ }
412
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
413
+ type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
414
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
415
+ type BuildUrlFn = <TData extends {
416
+ body?: unknown;
417
+ path?: Record<string, unknown>;
418
+ query?: Record<string, unknown>;
419
+ url: string;
420
+ }>(options: TData & Options<TData>) => string;
421
+ type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
422
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
423
+ };
424
+ interface TDataShape {
425
+ body?: unknown;
426
+ headers?: unknown;
427
+ path?: unknown;
428
+ query?: unknown;
429
+ url: string;
430
+ }
431
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
432
+ type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
433
+
434
+ type ClientOptions = {
435
+ baseUrl: 'https://api.stage.tesouro.com' | 'https://api.sandbox.stage.tesouro.com' | 'https://api.stage.business-banking.app' | 'https://api.tesouro.com' | 'https://api.sandbox.tesouro.com' | 'https://api.business-banking.app' | (string & {});
436
+ };
437
+ type CreditCardStatus = 'PENDING_ACTIVATION' | 'ACTIVE' | 'LOCKED' | 'CLOSED';
438
+ type CreditCardType = 'DIGITAL' | 'PHYSICAL';
439
+ /**
440
+ * The rolling period a velocity control's amount and usage limits are evaluated over.
441
+ * `TRANSACTION` applies the limit per-transaction and therefore carries no usage limit.
442
+ */
443
+ type VelocityWindow = 'DAY' | 'LIFETIME' | 'MONTH' | 'TRANSACTION' | 'WEEK';
444
+
445
+ type EmbeddedClient = Client;
446
+ type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
447
+ type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
448
+
449
+ /**
450
+ * The implementation a widget renders with.
451
+ *
452
+ * - `native` — the Tesouro-native implementation. This is the default and the
453
+ * implicit fallback, so consumers that select nothing keep rendering native.
454
+ * - `monite` — the Monite SDK implementation.
455
+ *
456
+ * Declared as an `as const` object (not a TypeScript `enum`) per repo
457
+ * convention.
458
+ */
459
+ declare const Implementation: {
460
+ readonly Native: "native";
461
+ readonly Monite: "monite";
462
+ };
463
+ type Implementation = (typeof Implementation)[keyof typeof Implementation];
464
+ /**
465
+ * The settable fields of the widget config cascade.
466
+ *
467
+ * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
468
+ * It intentionally excludes `initResponse`, which is populated automatically by the
469
+ * provider after a successful fetch and must never be set manually.
470
+ *
471
+ * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
472
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
473
+ * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
474
+ * (e.g. after logout or deliberate de-scoping).
475
+ *
476
+ * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
477
+ * @see {@link RootWidgetProvider}
478
+ * @see {@link WidgetProvider}
479
+ * @see {@link setGlobalWidgetConfig}
480
+ */
481
+ interface WidgetConfigInput {
482
+ /**
483
+ * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
484
+ *
485
+ * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
486
+ * Changing this recreates the underlying HTTP client so all subsequent requests
487
+ * go to the new host.
488
+ */
489
+ baseUrl?: BaseUrl;
490
+ /**
491
+ * Bearer token used to authenticate widget requests.
492
+ *
493
+ * Injected as `Authorization: Bearer <token>` on every outgoing request via an
494
+ * interceptor on the scoped HTTP client. Token updates are picked up immediately
495
+ * without recreating the client.
496
+ *
497
+ * - `string` — send this token on all requests from this level downward.
498
+ * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
499
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
500
+ */
501
+ widgetToken?: string | null;
502
+ /**
503
+ * Organization ID forwarded as the `x-organization-id` request header.
504
+ *
505
+ * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
506
+ * so individual data-access hooks can opt in per-request.
507
+ *
508
+ * - `string` — use this organization for downstream data requests.
509
+ * - `null` — explicitly cleared; queries that require an org ID will be disabled.
510
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
511
+ *
512
+ * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
513
+ * value), the resolved org defaults to the loaded `initResponse.organizationId`
514
+ * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
515
+ * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
516
+ * level wins, and an explicit `null` is preserved and never falls back.
517
+ *
518
+ * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
519
+ * default does not propagate into a descendant that owns its own fetch (its own
520
+ * `baseUrl`/`widgetToken`); such a descendant defaults to its own
521
+ * `initResponse.organizationId` instead, so it never sends an ancestor's org with
522
+ * its own token.
523
+ */
524
+ organizationId?: string | null;
525
+ /**
526
+ * Optional post-creation hook for the scoped HTTP client.
527
+ *
528
+ * Called once after the provider creates its scoped {@link EmbeddedClient} and
529
+ * applies the built-in `Authorization: Bearer` interceptor. Receives the
530
+ * fully-configured client and must return the client to be used for the lifetime of
531
+ * this provider level — either the same instance (with additional interceptors
532
+ * attached) or a new client entirely.
533
+ *
534
+ * **Order:** The built-in auth interceptor is always applied first. `configClient`
535
+ * is called on top of it, so any interceptors you add here run after auth is set.
536
+ *
537
+ * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
538
+ * scoped client whenever any prop is set — including `configClient` alone, without
539
+ * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
540
+ * client creation and never calls this function.
541
+ *
542
+ * **Stability:** The function reference is included in the client creation memo's
543
+ * dependency array. Passing an unstable (inline) function recreates the client on
544
+ * every render. Stabilize with `useCallback` or define the function outside the
545
+ * component.
546
+ *
547
+ * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
548
+ * {@link WidgetProvider} that creates its own scoped client will use the resolved
549
+ * `configClient` from the cascade unless it provides its own override.
550
+ *
551
+ * @example
552
+ * ```tsx
553
+ * const addLogging = useCallback(
554
+ * (client: EmbeddedClient) => {
555
+ * client.interceptors.request.use((req) => {
556
+ * console.log('[widget]', req.method, req.url);
557
+ * return req;
558
+ * });
559
+ * return client;
560
+ * },
561
+ * [],
562
+ * );
563
+ *
564
+ * <RootWidgetProvider
565
+ * baseUrl="https://api.tesouro.com"
566
+ * widgetToken={token}
567
+ * configClient={addLogging}
568
+ * >
569
+ * <App />
570
+ * </RootWidgetProvider>
571
+ * ```
572
+ */
573
+ configClient?: (client: EmbeddedClient) => EmbeddedClient;
574
+ /**
575
+ * Overrides the widget-gateway routing decision for the scoped HTTP client.
576
+ *
577
+ * Any caller reaching the Tesouro API with a widget token must route data
578
+ * requests through the widget gateway: prefix the path with
579
+ * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
580
+ * provider applies both automatically per request when the request origin is
581
+ * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
582
+ * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
583
+ * init round-trip) always pass through untouched.
584
+ *
585
+ * - `undefined` — decide from the request origin, as above. Inherits from
586
+ * the nearest ancestor or global store like every other config field.
587
+ * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
588
+ * custom domain in front of the gateway).
589
+ * - `false` — never apply it. For hosts that route widget requests their own
590
+ * way, such as a same-origin BFF whose `configClient` retargets every
591
+ * request.
592
+ *
593
+ * Independent of {@link configClient}: a host that only adds a header keeps
594
+ * the built-in routing, and the built-in interceptor runs before any
595
+ * `configClient` interceptor.
596
+ */
597
+ gatewayRouting?: boolean;
598
+ /**
599
+ * Component the embedded widgets should render in place of plain `<a>` tags.
600
+ *
601
+ * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
602
+ * Cascades like other config: provider prop > nearest ancestor > global store.
603
+ * When no value is set anywhere, widgets fall back to a plain `<a>` element.
604
+ */
605
+ linkComponent?: LinkComponent;
606
+ /**
607
+ * Which UI framework the widget UI layer should render with.
608
+ *
609
+ * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
610
+ * Tecton implementation behind the same outward-facing API. The selection is
611
+ * a presentation concern only — it cascades through the provider tree exactly
612
+ * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
613
+ * it never appears in any widget's feature-library or component props.
614
+ *
615
+ * - `'shadcn'` — the shadcn/Tailwind implementation.
616
+ * - `'tecton'` — the Tecton implementation.
617
+ * - `null` / `undefined` — not set at this level; inherit from the nearest
618
+ * ancestor or global store, falling back to `shadcn` when unset everywhere.
619
+ * `shadcn` is the implicit default, so existing consumers need no changes.
620
+ */
621
+ uiFramework?: UIFramework | null;
622
+ /**
623
+ * Which implementation a widget renders with.
624
+ *
625
+ * Lets a consuming context bind widgets to either the Tesouro-native or the
626
+ * Monite SDK implementation behind the same outward-facing API. It cascades
627
+ * through the provider tree exactly like {@link linkComponent} and
628
+ * {@link uiFramework} — provider prop > nearest ancestor > global store — and
629
+ * is read via `useImplementation`.
630
+ *
631
+ * - `'native'` — the Tesouro-native implementation.
632
+ * - `'monite'` — the Monite SDK implementation.
633
+ * - `null` / `undefined` — not set at this level; inherit from the nearest
634
+ * ancestor or global store, falling back to `native` when unset everywhere.
635
+ * `native` is the implicit default, so existing consumers need no changes.
636
+ */
637
+ implementation?: Implementation | null;
638
+ }
639
+ /**
640
+ * Props shared by every analytics-owner-capable widget provider.
641
+ *
642
+ * Combines the full settable cascade ({@link WidgetConfigInput}) with the
643
+ * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
644
+ * and {@link WidgetProvider} build their public props on top of this; the latter
645
+ * adds error-boundary props of its own.
646
+ *
647
+ * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
648
+ */
649
+ interface WidgetProviderBaseProps extends WidgetConfigInput {
650
+ /**
651
+ * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
652
+ *
653
+ * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
654
+ * standalone {@link WidgetProvider} with no parent provider. When `false`,
655
+ * owner-bound `track` calls in this subtree become no-ops and the PostHog
656
+ * installer is never dynamically imported for this owner's environment.
657
+ * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
658
+ * `console.warn` is emitted to make the no-op discoverable).
659
+ */
660
+ analytics?: boolean;
661
+ }
662
+
663
+ /**
664
+ * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
665
+ * the error-boundary fallback and the disclosures gate. A host overrides any
666
+ * subset through the `providerLabels` prop, which cascades like
667
+ * `disclosuresAcceptance`.
668
+ *
669
+ * Not named `Labels` on the public surface: a widget's own `labels` prop is a
670
+ * different thing, and these two travel together on every widget's props type.
671
+ */
672
+ interface WidgetProviderLabels {
673
+ /** Default copy for the built-in error boundary fallback. */
674
+ errorBoundaryFallback: string;
675
+ /** Heading when init reports disclosures are required and not yet accepted. */
676
+ disclosuresRequiredTitle: string;
677
+ /** Heading while a token-only refresh leaves init stale for the live token. */
678
+ disclosuresRefreshingTitle: string;
679
+ /** Supporting copy while the accept action is withheld for a stale init. */
680
+ disclosuresRefreshingDescription: string;
681
+ }
682
+
683
+ /**
684
+ * Props for {@link WidgetProvider}.
685
+ *
686
+ * All fields are optional. When **all** are omitted the provider is a transparent
687
+ * pass-through: no fetch is issued and all resolved values cascade unchanged from
688
+ * the nearest ancestor.
689
+ */
690
+ interface WidgetProviderProps extends WidgetProviderBaseProps {
691
+ /**
692
+ * Fallback rendered when a render-time exception is caught inside this
693
+ * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
694
+ * render-prop receiving `{ error, resetErrorBoundary }` from
695
+ * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
696
+ * comes from `providerLabels.errorBoundaryFallback`.
697
+ */
698
+ errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
699
+ /**
700
+ * Called once when the boundary catches an error, before the fallback
701
+ * renders. Use for telemetry / Sentry / partner logging. Exceptions
702
+ * thrown from `onError` propagate per `react-error-boundary` semantics.
703
+ */
704
+ onError?: (error: unknown, info: ErrorInfo) => void;
705
+ /**
706
+ * Accept surface shown when the caller owes disclosures — an INVITED
707
+ * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
708
+ * activate) or an ACTIVE user who owes a new version. Pass
709
+ * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
710
+ * WidgetProvider cannot import the widget itself (cycle).
711
+ */
712
+ disclosuresAcceptance?: ReactNode;
713
+ /**
714
+ * Overrides for the copy this provider renders in place of the widget: the
715
+ * built-in error-boundary fallback and the disclosures gate. Any subset;
716
+ * unlisted keys keep their defaults. Cascades like `linkComponent`.
717
+ *
718
+ * Named `providerLabels` rather than `labels` because a widget's own
719
+ * `labels` prop sits alongside this one on the same props type.
720
+ */
721
+ providerLabels?: Partial<WidgetProviderLabels>;
722
+ }
723
+
724
+ /**
725
+ * Which issuing product a card belongs to. A card list shows exactly one
726
+ * program at a time, and the value selects the endpoint the data-access layer
727
+ * calls: `credit` → `/embedded-banking/v1/credit-cards`, `debit` →
728
+ * `/embedded-banking/v1/debit-cards`.
729
+ *
730
+ * Defined here rather than in either widget because `CardsWidget` and
731
+ * `CardDetailsWidget` both publish it as a required public prop. Declared
732
+ * inline in each, the literal would become public API twice with no single
733
+ * definition — and `cards-widget/ui` ↔ `card-details-widget/ui` imports are
734
+ * lint-banned while the reverse feature import would be an Nx cycle, so
735
+ * `shared/feature` is the only home that serves both without duplication.
736
+ *
737
+ * Deliberately **not** the generated `CardTypeEnum` (`credit | debit | prepaid
738
+ * | unknown`), which greps as an exact match for this concept but belongs to
739
+ * the unrelated snake_case third-party schema family (its sibling fields are
740
+ * `card_type`, `last4`, `background_color`) and carries two members neither
741
+ * widget supports. In this codebase "card type" is the DIGITAL/PHYSICAL form
742
+ * factor instead — see `CardType` in `./cardPresentation`.
743
+ *
744
+ * Const-object-plus-type rather than a bare union, mirroring `UIFramework` in
745
+ * `shared/ui` — the other two-member literal that ships as a public prop type.
746
+ */
747
+ declare const CardProgram: {
748
+ readonly Credit: "credit";
749
+ readonly Debit: "debit";
750
+ };
751
+ type CardProgram = (typeof CardProgram)[keyof typeof CardProgram];
752
+
753
+ /**
754
+ * A card's lifecycle status, program-agnostic. Aliases the credit union because
755
+ * one of the two has to be the base; the parity assertions below are what keep
756
+ * that choice arbitrary.
757
+ */
758
+ type CardStatus = CreditCardStatus;
759
+ /**
760
+ * A card's physical form factor — the codebase's meaning of "card type". The
761
+ * credit/debit axis is `CardProgram`, not this.
762
+ */
763
+ type CardType = CreditCardType;
764
+
765
+ /** Accessible copy for the panel header's controls. */
766
+ interface CardDetailsHeaderLabels {
767
+ /** Fallback title when the card has no nickname. */
768
+ untitledCard: string;
769
+ /** Accessible name for the kebab that opens the card actions menu. */
770
+ menuTriggerAriaLabel: string;
771
+ /** Accessible name for the close (X) control. */
772
+ closeAriaLabel: string;
773
+ }
774
+ /** Accessible copy for the simplified card face. */
775
+ interface CardDetailsCardFaceLabels {
776
+ /** Alt text for the bank logo when the caller supplies no `bankLogoAlt`. */
777
+ bankLogoAlt: string;
778
+ }
779
+ /** Row headings and per-row copy affordance names for the details table. */
780
+ interface CardDetailsFieldLabels {
781
+ cardholder: string;
782
+ nickname: string;
783
+ billingAddress: string;
784
+ /** Sub-header over the merchant categories / velocity control rows. */
785
+ cardControlsHeading: string;
786
+ allowedCategories: string;
787
+ spendLimit: string;
788
+ perTransactionMax: string;
789
+ /** Stands in for a row whose value the card does not carry. */
790
+ emptyValue: string;
791
+ copyCardholderAriaLabel: string;
792
+ copyNicknameAriaLabel: string;
793
+ copyBillingAddressAriaLabel: string;
794
+ }
795
+ /** Copy for the controls the owner can switch on alongside the details. */
796
+ interface CardDetailsActionLabels {
797
+ /** Primary control that opens the Activate Card form. */
798
+ activateCard: string;
799
+ /** Secondary control that asks the owner to reveal the card's credentials. */
800
+ viewCard: string;
801
+ /** The same control, once the credentials are on screen. */
802
+ hideCard: string;
803
+ }
804
+ /**
805
+ * Copy for the revealed card credentials. The values themselves never have a
806
+ * default here — the panel is handed them or renders the field blank.
807
+ */
808
+ interface CardDetailsCredentialsLabels {
809
+ cardNumber: string;
810
+ expirationDate: string;
811
+ securityCode: string;
812
+ copyCardNumberAriaLabel: string;
813
+ copyExpirationDateAriaLabel: string;
814
+ copySecurityCodeAriaLabel: string;
815
+ /** Shown next to the control when the reveal failed. */
816
+ errorDescription: string;
817
+ }
818
+ /** Copy for the three non-loaded screens. */
819
+ interface CardDetailsStatusScreenLabels {
820
+ /** Accessible name announced while the panel is loading. */
821
+ loadingAriaLabel: string;
822
+ errorTitle: string;
823
+ errorDescription: string;
824
+ errorRetry: string;
825
+ notFoundTitle: string;
826
+ notFoundDescription: string;
827
+ }
828
+ interface CardDetailsPanelLabels {
829
+ header: CardDetailsHeaderLabels;
830
+ cardFace: CardDetailsCardFaceLabels;
831
+ fields: CardDetailsFieldLabels;
832
+ actions: CardDetailsActionLabels;
833
+ credentials: CardDetailsCredentialsLabels;
834
+ status: CardDetailsStatusScreenLabels;
835
+ }
836
+
837
+ /**
838
+ * Deep partial for label overrides.
839
+ *
840
+ * Both label surfaces this widget exposes have nested groups, and a shallow
841
+ * `Partial` would let a consumer who overrides one nested string drop the rest
842
+ * of that group. The repo has no shared `PartialDeep` and does not depend on
843
+ * `type-fest`, so each labels module defines its own — `card-details-widget/ui`
844
+ * has an identical one for the panel's labels, and this declaration also types
845
+ * that prop here so the widget carries one such helper rather than two.
846
+ */
847
+ type PartialDeep$2<T> = {
848
+ [K in keyof T]?: T[K] extends object ? PartialDeep$2<T[K]> : T[K];
849
+ };
850
+ /**
851
+ * Copy the **feature** layer owns, as opposed to the panel's own
852
+ * `CardDetailsPanelLabels`.
853
+ *
854
+ * The split follows where the string is resolved, not where it is painted. A
855
+ * status badge word is chosen by mapping a generated `cardStatus` enum member,
856
+ * which is a data-access-typed decision the presentational layer is not allowed
857
+ * to make — so it is overridable here even though the panel renders it. The
858
+ * panel's own labels stay with the panel.
859
+ */
860
+ interface CardDetailsFeatureLabels {
861
+ /** Confirmation toast after a copy affordance writes to the clipboard. */
862
+ copySuccessToast: string;
863
+ /**
864
+ * Replaces the panel's generic reveal error when the credentials call was
865
+ * refused (HTTP 403).
866
+ *
867
+ * It lives here rather than on the panel because deciding that a failure was a
868
+ * refusal means reading the error, which is this layer's job — the panel is
869
+ * handed one already-chosen sentence either way, and its own
870
+ * `credentials.errorDescription` still covers every other failure.
871
+ *
872
+ * The wording deliberately does not tell the reader to ask for a permission.
873
+ * Reading a debit card and reading its credentials take the same scope, so a
874
+ * reader looking at this panel already holds it; a 403 here means the call was
875
+ * refused for this session, which asking an admin for a role will not fix.
876
+ */
877
+ revealNotPermittedDescription: string;
878
+ /** Program wording on the card face, keyed on the widget's `cardProgram`. */
879
+ programLabels: Record<CardProgram, string>;
880
+ /** Status badge wording, keyed on the generated card status. */
881
+ statusLabels: Record<CardStatus, string>;
882
+ /** Form-factor subtitle wording, keyed on the generated card type. */
883
+ formFactorLabels: Record<CardType, string>;
884
+ /**
885
+ * A velocity control's reset-period wording, keyed on the generated
886
+ * `velocityWindow`. Used to build the spend limit row, e.g. "$500 / month".
887
+ * `TRANSACTION` is unused there (it drives the separate per-transaction max
888
+ * row instead) but is still a real enum member, so it stays in the map.
889
+ */
890
+ velocityWindowLabels: Record<VelocityWindow, string>;
891
+ }
892
+
893
+ interface CardDetailsWidgetProps extends WidgetProviderProps {
894
+ /** Id of the card to show. */
895
+ cardId: string;
896
+ /**
897
+ * Which issuing product `cardId` belongs to. **Required, with no default** —
898
+ * it selects the endpoint the card is fetched from, and a wrong guess would
899
+ * 404 a card that exists. `CardsWidget` publishes the same required prop, so
900
+ * one value configures a list and its detail panel together.
901
+ *
902
+ * A JavaScript consumer, or a host passing a route param straight through, can
903
+ * still get a value past the type. **There is no catch-all and no default:**
904
+ * anything that is not explicitly one of the two programs fetches nothing and
905
+ * renders the panel's error state with no retry, and the reason is named on the
906
+ * console. That covers an absent prop (`undefined` / `null`) as well as an
907
+ * unrecognised one (`'prepaid'`, a case-wrong `'Credit'`), because the widget
908
+ * cannot know which product to ask about in either case.
909
+ *
910
+ * A host that resolves the program asynchronously should gate its own render on
911
+ * it rather than mounting this widget without it — an absent program is not
912
+ * read as "still loading".
913
+ */
914
+ cardProgram: CardProgram;
915
+ /**
916
+ * Called when the header's close control is pressed. Omitting it renders no
917
+ * close control at all: a standalone card page has nothing to close back to,
918
+ * while a host rendering the panel in a drawer supplies this and suppresses
919
+ * its own chrome's close button so the two do not sit side by side.
920
+ */
921
+ onClose?: () => void;
922
+ /** Overrides for the panel's own copy. */
923
+ labels?: PartialDeep$2<CardDetailsPanelLabels>;
924
+ /** Overrides for the copy this layer resolves — see `CardDetailsFeatureLabels`. */
925
+ featureLabels?: PartialDeep$2<CardDetailsFeatureLabels>;
926
+ /**
927
+ * Bank logo for the card face. The widget ships no bank artwork of its own and
928
+ * resolves none from the init response: an embeddable library must not depend
929
+ * on a Tesouro-hosted asset a host page's content-security policy can block,
930
+ * and a bundled bank-name→URL table would put internal CDN links in the
931
+ * published package (PLAT-1179, embedded ADR 0005). Omit it and the card face
932
+ * renders without a logo rather than with a placeholder.
933
+ */
934
+ bankLogoSrc?: string;
935
+ bankLogoAlt?: string;
936
+ }
937
+
938
+ /**
939
+ * Reset-period tab labels and notice copy are deliberately absent: the owner
940
+ * supplies those through `spendLimitPeriodOptions` / `spendLimitPeriodNotices`,
941
+ * so declaring them here would give consumers override keys that no component
942
+ * ever reads.
943
+ */
944
+ interface CardControlsLabels {
945
+ currencySymbol: string;
946
+ spendLimit: {
947
+ title: string;
948
+ description: string;
949
+ amountPlaceholder: string;
950
+ amountAriaLabel: string;
951
+ };
952
+ merchantCategories: {
953
+ title: string;
954
+ description: string;
955
+ };
956
+ perTransactionMaximum: {
957
+ title: string;
958
+ description: string;
959
+ amountPlaceholder: string;
960
+ amountAriaLabel: string;
961
+ };
962
+ }
963
+
964
+ type PartialDeep$1<T> = {
965
+ [K in keyof T]?: T[K] extends object ? PartialDeep$1<T[K]> : T[K];
966
+ };
967
+ interface CreateCardWidgetLabels {
968
+ header: {
969
+ title: string;
970
+ closeAriaLabel: string;
971
+ };
972
+ cardArtAlt: string;
973
+ setup: {
974
+ sectionTitle: string;
975
+ cardholderLabel: string;
976
+ cardholderPlaceholder: string;
977
+ cardFormatLabel: string;
978
+ cardFormatPlaceholder: string;
979
+ cardFormatVirtual: string;
980
+ cardFormatPhysical: string;
981
+ fundingAccountLabel: string;
982
+ fundingAccountPlaceholder: string;
983
+ };
984
+ mailing: {
985
+ sectionTitle: string;
986
+ sectionDescription: string;
987
+ businessTitle: string;
988
+ businessDescription: string;
989
+ customTitle: string;
990
+ customDescription: string;
991
+ };
992
+ manualAddress: {
993
+ streetLabel: string;
994
+ cityLabel: string;
995
+ stateLabel: string;
996
+ statePlaceholder: string;
997
+ zipLabel: string;
998
+ };
999
+ cardControls: CardControlsLabels;
1000
+ preparing: {
1001
+ title: string;
1002
+ description: string;
1003
+ };
1004
+ success: {
1005
+ title: string;
1006
+ description: string;
1007
+ createAnother: string;
1008
+ viewCard: string;
1009
+ };
1010
+ footer: {
1011
+ cancel: string;
1012
+ createCard: string;
1013
+ };
1014
+ cardholderError: {
1015
+ title: string;
1016
+ description: string;
1017
+ retry: string;
1018
+ };
1019
+ fundingAccountError: {
1020
+ title: string;
1021
+ description: string;
1022
+ retry: string;
1023
+ };
1024
+ }
1025
+
1026
+ interface CreateCardFeatureLabels {
1027
+ toast: {
1028
+ creating: string;
1029
+ success: string;
1030
+ error: string;
1031
+ /**
1032
+ * Card issued but a follow-up velocity-control POST failed. The card
1033
+ * already exists; this must not read as a create failure.
1034
+ */
1035
+ controlsWarning: string;
1036
+ /**
1037
+ * Card issued but granting company admins access to it failed. The card
1038
+ * already exists; this must not read as a create failure.
1039
+ */
1040
+ companyAdminAccessWarning: string;
1041
+ /**
1042
+ * Card issued, but BOTH the velocity-control POST(s) and the company-admin
1043
+ * access grant failed. Distinct from the two single-failure warnings above
1044
+ * so an issuer who hits both is told about both, not just whichever this
1045
+ * code checks first.
1046
+ */
1047
+ controlsAndAccessWarning: string;
1048
+ /**
1049
+ * The roster of users to grant access to a new card failed to load.
1050
+ * Shown with a retry action; Create stays disabled until it resolves so
1051
+ * a card is never issued without its required admin grants.
1052
+ */
1053
+ debitCardIssuersError: string;
1054
+ retry: string;
1055
+ };
1056
+ untitledFundingAccount: string;
1057
+ /**
1058
+ * API-required `name` on a velocity control. Not shown in this widget;
1059
+ * may surface on a later controls list.
1060
+ */
1061
+ velocityControlNames: {
1062
+ spendLimit: string;
1063
+ perTransactionMaximum: string;
1064
+ };
1065
+ /**
1066
+ * Spend-limit reset-period tab labels and notices. Owned here (not UI
1067
+ * labels) because the feature layer decides what each opaque period value
1068
+ * means.
1069
+ */
1070
+ spendLimit: {
1071
+ periodOneTime: string;
1072
+ periodDaily: string;
1073
+ periodMonthly: string;
1074
+ oneTimeWarningTitle: string;
1075
+ oneTimeWarningDescription: string;
1076
+ dailyResetNotice: string;
1077
+ monthlyResetNotice: string;
1078
+ };
1079
+ /**
1080
+ * Success-screen copy chosen from the create response's `cardStatus`.
1081
+ * Active/ready wording lives on the UI defaults; these cover statuses that
1082
+ * must not claim the card is already usable.
1083
+ */
1084
+ success: {
1085
+ pendingActivationTitle: string;
1086
+ pendingActivationDescription: string;
1087
+ createdTitle: string;
1088
+ createdDescription: string;
1089
+ };
1090
+ }
1091
+
1092
+ type CreateCardWidgetProps = WidgetProviderProps & {
1093
+ /** Static card plastic image URL (no overlays). Host / white-label supplied. */
1094
+ cardArtSrc: string;
1095
+ labels?: PartialDeep$1<CreateCardWidgetLabels>;
1096
+ featureLabels?: Partial<{
1097
+ toast: Partial<CreateCardFeatureLabels['toast']>;
1098
+ untitledFundingAccount: string;
1099
+ velocityControlNames: Partial<CreateCardFeatureLabels['velocityControlNames']>;
1100
+ spendLimit: Partial<CreateCardFeatureLabels['spendLimit']>;
1101
+ success: Partial<CreateCardFeatureLabels['success']>;
1102
+ }>;
1103
+ className?: string;
1104
+ onClose?: () => void;
1105
+ onCancel?: () => void;
1106
+ /** Fired with the new debit card id after a successful create. */
1107
+ onViewCard?: (cardId: string) => void;
1108
+ };
1109
+
1110
+ /**
1111
+ * Every key of `T` optional, recursively, so a consumer can override one nested
1112
+ * label without restating its siblings. Defined locally because the repo has no
1113
+ * shared deep-partial type and does not depend on `type-fest` — same helper the
1114
+ * two card `ui` libs declare.
1115
+ */
1116
+ type PartialDeep<T> = {
1117
+ [K in keyof T]?: T[K] extends object ? PartialDeep<T[K]> : T[K];
1118
+ };
1119
+ /**
1120
+ * Strings this layer produces rather than passes through.
1121
+ *
1122
+ * They are separate from `CardsListLabels` (the `ui` lib's) because the cells
1123
+ * reaching that library are already formatted: the em-dash, the nickname
1124
+ * fallback and the "Viewing" prefix are all written *here*, so the UI lib has
1125
+ * no key to override them with. `bank-accounts-widget`'s `featureLabels` is the
1126
+ * precedent for the split.
1127
+ *
1128
+ * The status and form-factor maps live here for the same reason. EMBD-4503's
1129
+ * amendment put them in `shared/feature` keyed on the generated unions, and the
1130
+ * row arrives with `statusLabel` / `typeLabel` resolved — so this is the only
1131
+ * layer a consumer could reach them through.
1132
+ */
1133
+ interface CardsFeatureLabels {
1134
+ /**
1135
+ * Stands in for a cell the card program carries no value for — credit has no
1136
+ * funding account, and a debit card's funding account is unresolvable without
1137
+ * the bank-account read scope.
1138
+ */
1139
+ emptyValue: string;
1140
+ /** Name shown for a card with no nickname set. */
1141
+ untitledCard: string;
1142
+ /**
1143
+ * Last-resort name for a funding account with neither a nickname nor an
1144
+ * account number to mask. An account with no nickname shows `••••1234`
1145
+ * instead, so that two unnamed accounts stay distinguishable — this is only
1146
+ * for the case where there is nothing at all to show.
1147
+ */
1148
+ untitledFundingAccount: string;
1149
+ /** Display copy per card lifecycle status; keys are the generated code terms. */
1150
+ cardStatus: Record<CardStatus, string>;
1151
+ /** Display copy per card form factor; keys are the generated code terms. */
1152
+ cardType: Record<CardType, string>;
1153
+ }
1154
+
1155
+ /**
1156
+ * What `onPaginationChange` reports. One shared type across both programs — the
1157
+ * shape does not vary by program, so per-program aliases would be published
1158
+ * surface for nothing. Named without the `Widget` segment because no widget
1159
+ * called `CardsWidget` is published any more; `CreditCardsWidget` and
1160
+ * `DebitCardsWidget` both hand back this.
1161
+ */
1162
+ interface CardsPagination {
1163
+ /** Cursor for the page on screen. Omit for the first page. */
1164
+ paginationToken?: string;
1165
+ /** Number of rows requested per page. */
1166
+ pageSize: number;
1167
+ }
1168
+ /**
1169
+ * The wider shape `pagination` / `defaultPagination` accept. Internal: a
1170
+ * `CardsPagination` handed back by `onPaginationChange` satisfies it, which is
1171
+ * the round-trip the docs describe, so the package publishes only that one.
1172
+ * Keeps the `CardsWidget` segment because the internal component keeps the name.
1173
+ */
1174
+ interface CardsWidgetPaginationInput {
1175
+ paginationToken?: string;
1176
+ pageSize?: number;
1177
+ }
1178
+
1179
+ /**
1180
+ * The internal props. Not published: `CreditCardsWidgetProps` and
1181
+ * `DebitCardsWidgetProps` are derived from this by omission, which is what makes
1182
+ * `cardProgram` an implementation detail and the debit-only create props
1183
+ * unreachable on a credit list.
1184
+ */
1185
+ interface CardsWidgetProps extends WidgetProviderProps {
1186
+ /**
1187
+ * Which issuing program the list shows — `'credit'` or `'debit'`. It selects
1188
+ * the endpoint that is read as well as which scopes gate the affordances.
1189
+ *
1190
+ * **Required, with no default**, and supplied by the wrapper rather than by a
1191
+ * consumer: `CreditCardsWidget` and `DebitCardsWidget` pin it. It was a public
1192
+ * prop until those two exports replaced it, and a default here would silently
1193
+ * pick a program, where an integrator on one route only ever wants one.
1194
+ */
1195
+ cardProgram: CardProgram;
1196
+ /**
1197
+ * Controlled cursor/page-size metadata. Supply with `onPaginationChange` when
1198
+ * a host owns the list position, e.g. URL-backed pagination.
1199
+ */
1200
+ pagination?: CardsWidgetPaginationInput;
1201
+ /**
1202
+ * Initial cursor/page-size metadata for uncontrolled usage. Omit for first
1203
+ * page with the default page size. Ignored when `pagination` is supplied.
1204
+ */
1205
+ defaultPagination?: CardsWidgetPaginationInput;
1206
+ /**
1207
+ * Called whenever the widget changes its cursor/page-size pair through pagination
1208
+ * controls or a cursor-invalidating reset such as page-size changes. Hosts that
1209
+ * persist list position should store this whole object, not the token alone.
1210
+ */
1211
+ onPaginationChange?: (pagination: CardsPagination) => void;
1212
+ /**
1213
+ * Overrides for the list's own copy, merged per nested group. Typed with the
1214
+ * `ui` lib's own deep-partial helper (each labels module declares one — the
1215
+ * repo has no shared version) so this prop follows that library's contract.
1216
+ */
1217
+ labels?: PartialDeep$3<CardsListLabels>;
1218
+ /**
1219
+ * Overrides for the copy this layer produces rather than passes through — the
1220
+ * status and form-factor vocabulary, the empty-cell placeholder, the nickname
1221
+ * fallbacks, and the pagination range prefix. Separate from `labels` because
1222
+ * the list library receives those values already formatted and so has no key
1223
+ * for them; `BankAccountsWidget.featureLabels` is the same split.
1224
+ */
1225
+ featureLabels?: PartialDeep<CardsFeatureLabels>;
1226
+ /**
1227
+ * The card whose details panel is open. Supply with `onSelectedCardIdChange`
1228
+ * when the host owns that state — a deep-linked `/cards/[id]`, say. `null`
1229
+ * closes the panel; omit the prop for uncontrolled behaviour.
1230
+ *
1231
+ * Pinning it to `null` and navigating from `onSelectedCardIdChange` is how a
1232
+ * host suppresses the built-in panel entirely and owns navigation itself: the
1233
+ * click is still reported, and because the value never comes back non-null,
1234
+ * nothing ever opens.
1235
+ */
1236
+ selectedCardId?: string | null;
1237
+ /** Initial selection when uncontrolled. Ignored when `selectedCardId` is supplied. */
1238
+ defaultSelectedCardId?: string | null;
1239
+ /**
1240
+ * Called whenever the open card changes, including on close (`null`).
1241
+ *
1242
+ * Supplying it does **not** change what renders — a host can observe row clicks
1243
+ * for analytics, or mirror the selection into a query param, and still get the
1244
+ * built-in panel. (The removed `onCardSelect` could not: its presence
1245
+ * suppressed the panel, so those two intents were unexpressible together.)
1246
+ */
1247
+ onSelectedCardIdChange?: (cardId: string | null) => void;
1248
+ /**
1249
+ * Label overrides forwarded into the nested card details panel, mirroring
1250
+ * `BankAccountsWidgetProps.accountDetailsLabels`.
1251
+ *
1252
+ * Derived from the receiving prop rather than restated, so the forwarded and
1253
+ * received types cannot drift. Naming the panel's labels type directly is not
1254
+ * an option anyway: a cross-widget `type:ui` import is banned by
1255
+ * `EMBEDDED_DEP_CONSTRAINTS`, and this indexed access reaches it through the
1256
+ * sanctioned feature → feature edge without re-exporting anything. It already
1257
+ * carries `card-details-widget`'s own deep partial, so no wrapper here.
1258
+ */
1259
+ cardDetailsLabels?: CardDetailsWidgetProps['labels'];
1260
+ /**
1261
+ * Overrides for the copy the panel's *feature* layer resolves — its status
1262
+ * vocabulary, form-factor wording, program label and copy-success toast.
1263
+ *
1264
+ * Distinct from `featureLabels`, which covers the list's own vocabulary.
1265
+ * Without this prop the panel is unreachable for that copy, so a host that
1266
+ * renames a status in the list would still read the default inside the panel.
1267
+ */
1268
+ cardDetailsFeatureLabels?: CardDetailsWidgetProps['featureLabels'];
1269
+ /**
1270
+ * Bank logo for the details panel's card face. Forwarded verbatim; the panel
1271
+ * renders no logo without it, so omitting these leaves the built-in sheet
1272
+ * showing a logo-less card rather than a placeholder.
1273
+ *
1274
+ * These stay props because the package ships no bank artwork and resolves none
1275
+ * from the init response (PLAT-1179, embedded ADR 0005).
1276
+ */
1277
+ bankLogoSrc?: string;
1278
+ bankLogoAlt?: string;
1279
+ /**
1280
+ * Plastic art for the built-in debit create sheet. Forwarded verbatim into
1281
+ * nested `CreateCardWidget`. Required for that sheet: omitting it (with no
1282
+ * host `onCreateCard`) hides Create card rather than opening a panel that
1283
+ * cannot render. Same PLAT-1179 / ADR 0005 rule as `bankLogoSrc` — the package
1284
+ * ships no card artwork.
1285
+ */
1286
+ cardArtSrc?: string;
1287
+ /**
1288
+ * Label overrides forwarded into the nested create-card panel. Indexed off
1289
+ * `CreateCardWidgetProps` so the forwarded and received types cannot drift,
1290
+ * the same feature → feature edge as `cardDetailsLabels`.
1291
+ */
1292
+ createCardLabels?: CreateCardWidgetProps['labels'];
1293
+ /**
1294
+ * Overrides for the copy the create panel's *feature* layer resolves — mutation
1295
+ * toasts, the untitled funding-account fallback, and pending-activation success
1296
+ * copy.
1297
+ */
1298
+ createCardFeatureLabels?: CreateCardWidgetProps['featureLabels'];
1299
+ /**
1300
+ * Called when Create card is clicked. When supplied, the host owns the
1301
+ * gesture: the built-in debit sheet does **not** open. Omit it on a debit list
1302
+ * with `cardArtSrc` to use the built-in `CreateCardWidget` sheet. Credit has
1303
+ * no in-package issuance widget, so credit Create card still requires this
1304
+ * callback — omitting it hides the button rather than offering a control that
1305
+ * does nothing.
1306
+ */
1307
+ onCreateCard?: () => void;
1308
+ /**
1309
+ * Called with the card's id when a row's Activate button is clicked. The button
1310
+ * renders only on cards in `PENDING_ACTIVATION`, and only when the widget token
1311
+ * also holds the program's activate scope.
1312
+ *
1313
+ * Host-owned for the same reason as `onCreateCard`: EMBD-4398 designs no
1314
+ * activation flow, and `POST /debit-cards/{id}/activate` does not exist even
1315
+ * though `debit_card:activate:org` does — so a built-in flow could serve only
1316
+ * one of the two programs.
1317
+ */
1318
+ onActivateCard?: (cardId: string) => void;
1319
+ }
1320
+
1321
+ /**
1322
+ * Derived from the internal props rather than restated, so the two cannot drift.
1323
+ *
1324
+ * Four omissions, not one. `cardProgram` is pinned below. The three create-sheet
1325
+ * props are debit-only: the built-in sheet issues against `POST /credit-cards`'s
1326
+ * sibling and `CreateCardWidget` covers debit alone, so credit's Create card
1327
+ * needs a host `onCreateCard` or the button hides. That was prose in the doc; the
1328
+ * type says it here.
1329
+ */
1330
+ type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels'>;
1331
+ /**
1332
+ * One page of an organization's **credit** cards, with a scope-gated Show my
1333
+ * cards toggle and per-row Activate affordance. Selecting a row opens that
1334
+ * card's read-only details in a sheet.
1335
+ *
1336
+ * Create card is host-owned here: pass `onCreateCard` or the button does not
1337
+ * render. Debit is {@link DebitCardsWidget}, a separate export because
1338
+ * integrators put the two programs on different routes — and because the
1339
+ * built-in create sheet is debit's alone.
1340
+ *
1341
+ * The program is pinned *after* the spread, so a JavaScript host still passing
1342
+ * the retired `cardProgram` cannot point this export at the debit endpoint.
1343
+ */
1344
+ declare function CreditCardsWidget(props: CreditCardsWidgetProps): React.JSX.Element;
1345
+
1346
+ export { CreditCardsWidget };
1347
+ export type { CardsFeatureLabels, CardsListLabels as CardsLabels, CardsPagination, CreditCardsWidgetProps };